General sales order information.
Creation Date | 27/10/2017 14:33 |
File Group | PRIMARY |
Text File Group | |
System Object | |
Published for Replication | |
Rows | 31465 |
Data Space Used | 5,480.00 KB |
Index Space Used | 2,728.00 KB |
Column Name | Description | Datatype | Length | Allow Nulls | Default | Formula | |
---|---|---|---|---|---|---|---|
SalesOrderID | Primary key. | Integer | 4 | ||||
RevisionNumber | Incremental number to track changes to the sales order over time. | UnsignedTinyInt | 1 | ((0)) | |||
OrderDate | Dates the sales order was created. | DBTimeStamp | 4 | (getdate()) | |||
DueDate | Date the order is due to the customer. | DBTimeStamp | 4 | ||||
ShipDate | Date the order was shipped to the customer. | DBTimeStamp | 4 | ||||
Status | Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled | UnsignedTinyInt | 1 | ((1)) | |||
OnlineOrderFlag | 0 = Order placed by sales person. 1 = Order placed online by customer. | dbo.Flag | 1 | ((1)) | |||
SalesOrderNumber | Unique sales order identification number. | VarWChar | 25 | (isnull(N'SO'+CONVERT([nvarchar](23),[SalesOrderID]),N'*** ERROR ***')) | |||
PurchaseOrderNumber | Customer purchase order number reference. | dbo.OrderNumber | 25 | ||||
AccountNumber | Financial accounting number reference. | dbo.AccountNumber | 15 | ||||
CustomerID | Customer identification number. Foreign key to Customer.BusinessEntityID. | Integer | 4 | ||||
SalesPersonID | Sales person who created the sales order. Foreign key to SalesPerson.BusinessEntityID. | Integer | 4 | ||||
TerritoryID | Territory in which the sale was made. Foreign key to SalesTerritory.SalesTerritoryID. | Integer | 4 | ||||
BillToAddressID | Customer billing address. Foreign key to Address.AddressID. | Integer | 4 | ||||
ShipToAddressID | Customer shipping address. Foreign key to Address.AddressID. | Integer | 4 | ||||
ShipMethodID | Shipping method. Foreign key to ShipMethod.ShipMethodID. | Integer | 4 | ||||
CreditCardID | Credit card identification number. Foreign key to CreditCard.CreditCardID. | Integer | 4 | ||||
CreditCardApprovalCode | Approval code provided by the credit card company. | VarChar | 15 | ||||
CurrencyRateID | Currency exchange rate used. Foreign key to CurrencyRate.CurrencyRateID. | Integer | 4 | ||||
SubTotal | Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID. | Currency | 8 | ((0.00)) | |||
TaxAmt | Tax amount. | Currency | 8 | ((0.00)) | |||
Freight | Shipping cost. | Currency | 8 | ((0.00)) | |||
TotalDue | Total due from customer. Computed as Subtotal + TaxAmt + Freight. | Currency | 8 | (isnull(([SubTotal]+[TaxAmt])+[Freight],(0))) | |||
Comment | Sales representative comments. | VarWChar | 128 | ||||
rowguid | ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. | GUID | 16 | (newid()) | |||
ModifiedDate | Date and time the record was last updated. | DBTimeStamp | 4 | (getdate()) |
Index | Description | Primary | Unique |
---|---|---|---|
AK_SalesOrderHeader_rowguid | Unique nonclustered index. Used to support replication samples. | ||
AK_SalesOrderHeader_SalesOrderNumber | Unique nonclustered index. | ||
IX_SalesOrderHeader_CustomerID | Nonclustered index. | ||
IX_SalesOrderHeader_SalesPersonID | Nonclustered index. | ||
PK_SalesOrderHeader_SalesOrderID | Primary key (clustered) constraint |
Name | Description | Expression |
---|---|---|
CK_SalesOrderHeader_DueDate | Check constraint [DueDate] >= [OrderDate] | ([DueDate]>=[OrderDate]) |
CK_SalesOrderHeader_Freight | Check constraint [Freight] >= (0.00) | ([Freight]>=(0.00)) |
CK_SalesOrderHeader_ShipDate | Check constraint [ShipDate] >= [OrderDate] OR [ShipDate] IS NULL | ([ShipDate]>=[OrderDate] OR [ShipDate] IS NULL) |
CK_SalesOrderHeader_Status | Check constraint [Status] BETWEEN (0) AND (8) | ([Status]>=(0) AND [Status]<=(8)) |
CK_SalesOrderHeader_SubTotal | Check constraint [SubTotal] >= (0.00) | ([SubTotal]>=(0.00)) |
CK_SalesOrderHeader_TaxAmt | Check constraint [TaxAmt] >= (0.00) | ([TaxAmt]>=(0.00)) |
Trigger | Description |
---|---|
uSalesOrderHeader | AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the SalesOrderHeader table.Updates the SalesYTD column in the SalesPerson and SalesTerritory tables. |
Relationship | Description |
---|---|
FK_SalesOrderHeader_Address_BillToAddressID | Foreign key constraint referencing Address.AddressID. |
FK_SalesOrderHeader_Address_ShipToAddressID | Foreign key constraint referencing Address.AddressID. |
FK_SalesOrderHeader_CreditCard_CreditCardID | Foreign key constraint referencing CreditCard.CreditCardID. |
FK_SalesOrderHeader_CurrencyRate_CurrencyRateID | Foreign key constraint referencing CurrencyRate.CurrencyRateID. |
FK_SalesOrderHeader_Customer_CustomerID | Foreign key constraint referencing Customer.CustomerID. |
FK_SalesOrderHeader_SalesPerson_SalesPersonID | Foreign key constraint referencing SalesPerson.SalesPersonID. |
FK_SalesOrderHeader_SalesTerritory_TerritoryID | Foreign key constraint referencing SalesTerritory.TerritoryID. |
FK_SalesOrderHeader_ShipMethod_ShipMethodID | Foreign key constraint referencing ShipMethod.ShipMethodID. |
Database Object | Object Type | Description | Dep Level | |
---|---|---|---|---|
iduSalesOrderDetail | Trigger | AFTER INSERT, DELETE, UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in SalesOrderDetail and updates the SalesOrderHeader.SubTotal column. | 2 | |
Sales.SalesOrderDetail | Table | Individual products associated with a specific sales order. See SalesOrderHeader. | 1 | |
Sales.SalesOrderHeaderSalesReason | Table | Cross-reference table mapping sales orders to sales reason codes. | 1 | |
uSalesOrderHeader | Trigger | AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the SalesOrderHeader table.Updates the SalesYTD column in the SalesPerson and SalesTerritory tables. | 1 | |
Sales.vSalesPersonSalesByFiscalYears | View | Uses PIVOT to return aggregated sales information for each sales representative. | 1 |
Database Object | Object Type | Description | Dep Level | |
---|---|---|---|---|
dbo.AccountNumber | User Defined Data Type | 1 | ||
Person.Address | Table | Street address information for customers, employees, and vendors. | 1 | |
Person.BusinessEntity | Table | Source of the ID that connects vendors, customers, and employees with address and contact information. | 3 | |
Sales.CreditCard | Table | Customer credit card information. | 1 | |
Sales.Currency | Table | Lookup table containing standard ISO currencies. | 2 | |
Sales.CurrencyRate | Table | Currency exchange rates. | 1 | |
Sales.Customer | Table | Current customer information. Also see the Person and Store tables. | 1 | |
HumanResources.Employee | Table | Employee information such as salary, department, and title. | 2 | |
dbo.ErrorLog | Table | Audit table tracking errors in the the AdventureWorks database that are caught by the CATCH block of a TRY...CATCH construct. Data is inserted by stored procedure dbo.uspLogError when it is executed from inside the CATCH block of a TRY...CATCH construct. | 2 | |
dbo.Flag | User Defined Data Type | 1 | ||
dbo.NameStyle | User Defined Data Type | 3 | ||
dbo.OrderNumber | User Defined Data Type | 1 | ||
Person.Person | Table | Human beings involved with AdventureWorks: employees, customer contacts, and vendor contacts. | 2 | |
Sales.SalesPerson | Table | Sales representative current information. | 1 | |
Sales.SalesTerritory | Table | Sales territory lookup table. | 1 | |
Purchasing.ShipMethod | Table | Shipping company lookup table. | 1 | |
Person.StateProvince | Table | State and province lookup table. | 2 | |
Sales.Store | Table | Customers (resellers) of Adventure Works products. | 2 | |
dbo.ufnGetAccountingEndDate | User Defined Function | Scalar function used in the uSalesOrderHeader trigger to set the starting account date. | 1 | |
dbo.ufnGetAccountingStartDate | User Defined Function | Scalar function used in the uSalesOrderHeader trigger to set the ending account date. | 1 | |
dbo.ufnLeadingZeros | User Defined Function | Scalar function used by the Sales.Customer table to help set the account number. | 2 | |
dbo.uspLogError | Stored Procedure | Logs error information in the ErrorLog table about the error that caused execution to jump to the CATCH block of a TRY...CATCH construct. Should be executed from within the scope of a CATCH block otherwise it will return without inserting error information. | 1 | |
dbo.uspPrintError | Stored Procedure | Prints error information about the error that caused execution to jump to the CATCH block of a TRY...CATCH construct. Should be executed from within the scope of a CATCH block otherwise it will return without printing any error information. | 1 |
|