Sales |
04/26/2006 |
PRIMARY |
5592 |
2384 |
31465 |
General sales order information. |
|
|
SalesOrderID |
int |
4 |
|
|
|
|
Primary key. |
|
|
RevisionNumber |
tinyint |
1 |
|
((0)) |
|
|
Incremental number to track changes to the sales order over time. |
|
|
OrderDate |
datetime |
8 |
|
(getdate()) |
|
|
Dates the sales order was created. |
|
|
DueDate |
datetime |
8 |
|
|
|
|
Date the order is due to the customer. |
|
|
ShipDate |
datetime |
8 |
|
|
|
|
Date the order was shipped to the customer. |
|
|
Status |
tinyint |
1 |
|
((1)) |
|
|
Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled |
|
|
OnlineOrderFlag |
Flag |
1 |
|
((1)) |
|
|
0 = Order placed by sales person. 1 = Order placed online by customer. |
|
|
SalesOrderNumber |
nvarchar |
25 |
|
|
|
|
Unique sales order identification number. |
|
|
PurchaseOrderNumber |
OrderNumber |
50 |
|
|
|
|
Customer purchase order number reference. |
|
|
AccountNumber |
AccountNumber |
30 |
|
|
|
|
Financial accounting number reference. |
|
|
CustomerID |
int |
4 |
|
|
|
|
Customer identification number. Foreign key to Customer.CustomerID. |
|
|
ContactID |
int |
4 |
|
|
|
|
Customer contact identification number. Foreign key to Contact.ContactID. |
|
|
SalesPersonID |
int |
4 |
|
|
|
|
Sales person who created the sales order. Foreign key to SalesPerson.SalePersonID. |
|
|
TerritoryID |
int |
4 |
|
|
|
|
Territory in which the sale was made. Foreign key to SalesTerritory.SalesTerritoryID. |
|
|
BillToAddressID |
int |
4 |
|
|
|
|
Customer billing address. Foreign key to Address.AddressID. |
|
|
ShipToAddressID |
int |
4 |
|
|
|
|
Customer shipping address. Foreign key to Address.AddressID. |
|
|
ShipMethodID |
int |
4 |
|
|
|
|
Shipping method. Foreign key to ShipMethod.ShipMethodID. |
|
|
CreditCardID |
int |
4 |
|
|
|
|
Credit card identification number. Foreign key to CreditCard.CreditCardID. |
|
|
CreditCardApprovalCode |
varchar |
15 |
|
|
|
|
Approval code provided by the credit card company. |
|
|
CurrencyRateID |
int |
4 |
|
|
|
|
Currency exchange rate used. Foreign key to CurrencyRate.CurrencyRateID. |
|
|
SubTotal |
money |
8 |
|
((0.00)) |
|
|
Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID. |
|
|
TaxAmt |
money |
8 |
|
((0.00)) |
|
|
Tax amount. |
|
|
Freight |
money |
8 |
|
((0.00)) |
|
|
Shipping cost. |
|
|
TotalDue |
money |
8 |
|
|
|
|
Total due from customer. Computed as Subtotal + TaxAmt + Freight. |
|
|
Comment |
nvarchar |
128 |
|
|
|
|
Sales representative comments. |
|
|
rowguid |
uniqueidentifier |
16 |
|
(newid()) |
|
|
ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. |
|
|
ModifiedDate |
datetime |
8 |
|
(getdate()) |
|
|
Date and time the record was last updated. |
Total: 27 column(s)
|
SalesOrderID |
1 |
1 |
|
Total: 5 index(es)
|
uSalesOrderHeader
|
Sales |
|
|
Sales.SalesOrderHeader
|
AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the SalesOrderHeader table.Updates the SalesYTD column in the SalesPerson and SalesTerritory tables. |
Total: 1 trigger(s)
|
CK_SalesOrderHeader_DueDate |
([DueDate]>=[OrderDate]) |
|
CK_SalesOrderHeader_Freight |
([Freight]>=(0.00)) |
|
CK_SalesOrderHeader_ShipDate |
([ShipDate]>=[OrderDate] OR [ShipDate] IS NULL) |
|
CK_SalesOrderHeader_Status |
([Status]>=(0) AND [Status]<=(8)) |
|
CK_SalesOrderHeader_SubTotal |
([SubTotal]>=(0.00)) |
|
CK_SalesOrderHeader_TaxAmt |
([TaxAmt]>=(0.00)) |
Total: 6 constraint(s)
Total: 2 table(s)
Total: 9 table(s)
Total: 19 object(s)
Total: 5 object(s)
CREATE TABLE [SalesOrderHeader] (
[SalesOrderID] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
[RevisionNumber] [tinyint] NOT NULL CONSTRAINT [DF_SalesOrderHeader_RevisionNumber] DEFAULT ((0)),
[OrderDate] [datetime] NOT NULL CONSTRAINT [DF_SalesOrderHeader_OrderDate] DEFAULT (getdate()),
[DueDate] [datetime] NOT NULL ,
[ShipDate] [datetime] NULL ,
[Status] [tinyint] NOT NULL CONSTRAINT [DF_SalesOrderHeader_Status] DEFAULT ((1)),
[OnlineOrderFlag] [Flag] NOT NULL CONSTRAINT [DF_SalesOrderHeader_OnlineOrderFlag] DEFAULT ((1)),
[SalesOrderNumber] AS (isnull(N'SO'+CONVERT([nvarchar](23),[SalesOrderID],0),N'*** ERROR ***')) ,
[PurchaseOrderNumber] [OrderNumber] NULL ,
[AccountNumber] [AccountNumber] NULL ,
[CustomerID] [int] NOT NULL ,
[ContactID] [int] NOT NULL ,
[SalesPersonID] [int] NULL ,
[TerritoryID] [int] NULL ,
[BillToAddressID] [int] NOT NULL ,
[ShipToAddressID] [int] NOT NULL ,
[ShipMethodID] [int] NOT NULL ,
[CreditCardID] [int] NULL ,
[CreditCardApprovalCode] [varchar] (15) COLLATE Latin1_General_CS_AS NULL ,
[CurrencyRateID] [int] NULL ,
[SubTotal] [money] NOT NULL CONSTRAINT [DF_SalesOrderHeader_SubTotal] DEFAULT ((0.00)),
[TaxAmt] [money] NOT NULL CONSTRAINT [DF_SalesOrderHeader_TaxAmt] DEFAULT ((0.00)),
[Freight] [money] NOT NULL CONSTRAINT [DF_SalesOrderHeader_Freight] DEFAULT ((0.00)),
[TotalDue] AS (isnull(([SubTotal]+[TaxAmt])+[Freight],(0))) ,
[Comment] [nvarchar] (128) COLLATE Latin1_General_CS_AS NULL ,
[rowguid] uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT [DF_SalesOrderHeader_rowguid] DEFAULT (newid()),
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_SalesOrderHeader_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_SalesOrderHeader_SalesOrderID] PRIMARY KEY CLUSTERED
(
[SalesOrderID]
) ON [PRIMARY] ,
CONSTRAINT [FK_SalesOrderHeader_Address_BillToAddressID] FOREIGN KEY
(
[BillToAddressID]
) REFERENCES [Address] (
[AddressID]
),
CONSTRAINT [FK_SalesOrderHeader_Address_ShipToAddressID] FOREIGN KEY
(
[ShipToAddressID]
) REFERENCES [Address] (
[AddressID]
),
CONSTRAINT [FK_SalesOrderHeader_Contact_ContactID] FOREIGN KEY
(
[ContactID]
) REFERENCES [Contact] (
[ContactID]
),
CONSTRAINT [FK_SalesOrderHeader_CreditCard_CreditCardID] FOREIGN KEY
(
[CreditCardID]
) REFERENCES [CreditCard] (
[CreditCardID]
),
CONSTRAINT [FK_SalesOrderHeader_CurrencyRate_CurrencyRateID] FOREIGN KEY
(
[CurrencyRateID]
) REFERENCES [CurrencyRate] (
[CurrencyRateID]
),
CONSTRAINT [FK_SalesOrderHeader_Customer_CustomerID] FOREIGN KEY
(
[CustomerID]
) REFERENCES [Customer] (
[CustomerID]
),
CONSTRAINT [FK_SalesOrderHeader_SalesPerson_SalesPersonID] FOREIGN KEY
(
[SalesPersonID]
) REFERENCES [SalesPerson] (
[SalesPersonID]
),
CONSTRAINT [FK_SalesOrderHeader_SalesTerritory_TerritoryID] FOREIGN KEY
(
[TerritoryID]
) REFERENCES [SalesTerritory] (
[TerritoryID]
),
CONSTRAINT [FK_SalesOrderHeader_ShipMethod_ShipMethodID] FOREIGN KEY
(
[ShipMethodID]
) REFERENCES [ShipMethod] (
[ShipMethodID]
),
CONSTRAINT [CK_SalesOrderHeader_DueDate] CHECK ([DueDate]>=[OrderDate]),
CONSTRAINT [CK_SalesOrderHeader_Freight] CHECK ([Freight]>=(0.00)),
CONSTRAINT [CK_SalesOrderHeader_ShipDate] CHECK ([ShipDate]>=[OrderDate] OR [ShipDate] IS NULL),
CONSTRAINT [CK_SalesOrderHeader_Status] CHECK ([Status]>=(0) AND [Status]<=(8)),
CONSTRAINT [CK_SalesOrderHeader_SubTotal] CHECK ([SubTotal]>=(0.00)),
CONSTRAINT [CK_SalesOrderHeader_TaxAmt] CHECK ([TaxAmt]>=(0.00))
) ON [PRIMARY]
GO
List of tables