Properties

Owner: Purchasing 
Creation Date: 04/26/2006 
Located On: PRIMARY 
Data Size KB: 512 
Index Size KB: 168 
Rows: 8845 
Description: Individual products associated with a specific purchase order. See PurchaseOrderHeader. 

Columns

Name Data Type Length NULL Default IsIdentity IsGUID Description
    PurchaseOrderID  int          Primary key. Foreign key to PurchaseOrderHeader.PurchaseOrderID. 
    PurchaseOrderDetailID  int          Primary key. One line number per purchased product. 
    DueDate  datetime          Date the product is expected to be received. 
    OrderQty  smallint          Quantity ordered. 
    ProductID  int          Product identification number. Foreign key to Product.ProductID. 
    UnitPrice  money          Vendor's selling price of a single product. 
    LineTotal  money          Per product subtotal. Computed as OrderQty * UnitPrice. 
    ReceivedQty  decimal          Quantity actually received from the vendor. 
    RejectedQty  decimal          Quantity rejected during inspection. 
    StockedQty  decimal          Quantity accepted into inventory. Computed as ReceivedQty - RejectedQty. 
    ModifiedDate  datetime    (getdate())      Date and time the record was last updated. 
Total: 11 column(s)

Identity column

Name Seed Increment Not for replication
  PurchaseOrderDetailID   

Indexes

Index Primary Unique Description
  PK_PurchaseOrderDetail_PurchaseOrderID_PurchaseOrderDetailID      Primary key (clustered) constraint 
  IX_PurchaseOrderDetail_ProductID      Nonclustered index. 
Total: 2 index(es)

Triggers

Name Owner Instead Of Disabled Table/View Description
  iPurchaseOrderDetail  Purchasing      Purchasing.PurchaseOrderDetail  AFTER INSERT trigger that inserts a row in the TransactionHistory table and updates the PurchaseOrderHeader.SubTotal column. 
  uPurchaseOrderDetail  Purchasing      Purchasing.PurchaseOrderDetail  AFTER UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in PurchaseOrderDetail and updates the PurchaseOrderHeader.SubTotal column. 
Total: 2 trigger(s)

Check Constraints

Name Expression
  CK_PurchaseOrderDetail_OrderQty  ([OrderQty]>(0)) 
  CK_PurchaseOrderDetail_ReceivedQty  ([ReceivedQty]>=(0.00)) 
  CK_PurchaseOrderDetail_RejectedQty  ([RejectedQty]>=(0.00)) 
  CK_PurchaseOrderDetail_UnitPrice  ([UnitPrice]>=(0.00)) 
Total: 4 constraint(s)

Referenced Tables

Table Foreign Key Primary Key or Unique Constraint
  Production.Product  FK_PurchaseOrderDetail_Product_ProductID  PK_Product_ProductID 
  Purchasing.PurchaseOrderHeader  FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID  PK_PurchaseOrderHeader_PurchaseOrderID 
Total: 2 table(s)

Objects that [Purchasing].[PurchaseOrderDetail] depends on

Object Name Owner Object Type Dep Level
  AccountNumber  dbo  User Defined type 
  Flag  dbo  User Defined type 
  Name  dbo  User Defined type 
  NameStyle  dbo  User Defined type 
  Phone  dbo  User Defined type 
  Contact  Person  Table 
  ProductCategory  Production  Table 
  ProductModel  Production  Table 
  ShipMethod  Purchasing  Table 
  UnitMeasure  Production  Table 
  Vendor  Purchasing  Table 
  Employee  HumanResources  Table 
  ProductSubcategory  Production  Table 
  Product  Production  Table 
  PurchaseOrderHeader  Purchasing  Table 
Total: 15 object(s)

Objects that depend on [Purchasing].[PurchaseOrderDetail]

Object Name Owner Object Type Dep Level
  iPurchaseOrderDetail  Purchasing  Trigger 
  uPurchaseOrderDetail  Purchasing  Trigger 
Total: 2 object(s)

SQL

CREATE TABLE [PurchaseOrderDetail] (
    [PurchaseOrderID] [int] NOT NULL ,
    [PurchaseOrderDetailID] [int] IDENTITY (1, 1) NOT NULL ,
    [DueDate] [datetime] NOT NULL ,
    [OrderQty] [smallint] NOT NULL ,
    [ProductID] [int] NOT NULL ,
    [UnitPrice] [money] NOT NULL ,
    [LineTotal] AS (isnull([OrderQty]*[UnitPrice],(0.00))) ,
    [ReceivedQty] [decimal](8, 2) NOT NULL ,
    [RejectedQty] [decimal](8, 2) NOT NULL ,
    [StockedQty] AS (isnull([ReceivedQty]-[RejectedQty],(0.00))) ,
    [ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_PurchaseOrderDetail_ModifiedDate] DEFAULT (getdate()),
    CONSTRAINT [PK_PurchaseOrderDetail_PurchaseOrderID_PurchaseOrderDetailID] PRIMARY KEY  CLUSTERED
    (
        [PurchaseOrderID],
        [PurchaseOrderDetailID]
    )  ON [PRIMARY] ,
    CONSTRAINT [FK_PurchaseOrderDetail_Product_ProductID] FOREIGN KEY
    (
        [ProductID]
    ) REFERENCES [Product] (
        [ProductID]
    ),
    CONSTRAINT [FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID] FOREIGN KEY
    (
        [PurchaseOrderID]
    ) REFERENCES [PurchaseOrderHeader] (
        [PurchaseOrderID]
    ),
    CONSTRAINT [CK_PurchaseOrderDetail_OrderQty] CHECK ([OrderQty]>(0)),
    CONSTRAINT [CK_PurchaseOrderDetail_ReceivedQty] CHECK ([ReceivedQty]>=(0.00)),
    CONSTRAINT [CK_PurchaseOrderDetail_RejectedQty] CHECK ([RejectedQty]>=(0.00)),
    CONSTRAINT [CK_PurchaseOrderDetail_UnitPrice] CHECK ([UnitPrice]>=(0.00))
) ON [PRIMARY]
GO


See Also

List of tables