Sales |
04/26/2006 |
PRIMARY |
9864 |
5144 |
121317 |
Individual products associated with a specific sales order. See SalesOrderHeader. |
|
|
SalesOrderID |
int |
4 |
|
|
|
|
Primary key. Foreign key to SalesOrderHeader.SalesOrderID. |
|
|
SalesOrderDetailID |
int |
4 |
|
|
|
|
Primary key. One incremental unique number per product sold. |
|
|
CarrierTrackingNumber |
nvarchar |
25 |
|
|
|
|
Shipment tracking number supplied by the shipper. |
|
|
OrderQty |
smallint |
2 |
|
|
|
|
Quantity ordered per product. |
|
|
ProductID |
int |
4 |
|
|
|
|
Product sold to customer. Foreign key to Product.ProductID. |
|
|
SpecialOfferID |
int |
4 |
|
|
|
|
Promotional code. Foreign key to SpecialOffer.SpecialOfferID. |
|
|
UnitPrice |
money |
8 |
|
|
|
|
Selling price of a single product. |
|
|
UnitPriceDiscount |
money |
8 |
|
((0.0)) |
|
|
Discount amount. |
|
|
LineTotal |
numeric |
17 |
|
|
|
|
Per product subtotal. Computed as UnitPrice * (1 - UnitPriceDiscount) * OrderQty. |
|
|
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: 11 column(s)
|
SalesOrderDetailID |
1 |
1 |
|
Total: 3 index(es)
|
iduSalesOrderDetail
|
Sales |
|
|
Sales.SalesOrderDetail
|
AFTER INSERT, DELETE, UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in SalesOrderDetail and updates the SalesOrderHeader.SubTotal column. |
Total: 1 trigger(s)
|
CK_SalesOrderDetail_OrderQty |
([OrderQty]>(0)) |
|
CK_SalesOrderDetail_UnitPrice |
([UnitPrice]>=(0.00)) |
|
CK_SalesOrderDetail_UnitPriceDiscount |
([UnitPriceDiscount]>=(0.00)) |
Total: 3 constraint(s)
Total: 2 table(s)
Total: 27 object(s)
Total: 1 object(s)
CREATE TABLE [SalesOrderDetail] (
[SalesOrderID] [int] NOT NULL ,
[SalesOrderDetailID] [int] IDENTITY (1, 1) NOT NULL ,
[CarrierTrackingNumber] [nvarchar] (25) COLLATE Latin1_General_CS_AS NULL ,
[OrderQty] [smallint] NOT NULL ,
[ProductID] [int] NOT NULL ,
[SpecialOfferID] [int] NOT NULL ,
[UnitPrice] [money] NOT NULL ,
[UnitPriceDiscount] [money] NOT NULL CONSTRAINT [DF_SalesOrderDetail_UnitPriceDiscount] DEFAULT ((0.0)),
[LineTotal] AS (isnull(([UnitPrice]*((1.0)-[UnitPriceDiscount]))*[OrderQty],(0.0))) ,
[rowguid] uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT [DF_SalesOrderDetail_rowguid] DEFAULT (newid()),
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_SalesOrderDetail_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_SalesOrderDetail_SalesOrderID_SalesOrderDetailID] PRIMARY KEY CLUSTERED
(
[SalesOrderID],
[SalesOrderDetailID]
) ON [PRIMARY] ,
CONSTRAINT [FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID] FOREIGN KEY
(
[SalesOrderID]
) REFERENCES [SalesOrderHeader] (
[SalesOrderID]
) ON DELETE CASCADE ,
CONSTRAINT [FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID] FOREIGN KEY
(
[SpecialOfferID],
[ProductID]
) REFERENCES [SpecialOfferProduct] (
[SpecialOfferID],
[ProductID]
),
CONSTRAINT [CK_SalesOrderDetail_OrderQty] CHECK ([OrderQty]>(0)),
CONSTRAINT [CK_SalesOrderDetail_UnitPrice] CHECK ([UnitPrice]>=(0.00)),
CONSTRAINT [CK_SalesOrderDetail_UnitPriceDiscount] CHECK ([UnitPriceDiscount]>=(0.00))
) ON [PRIMARY]
GO
List of tables