Northwind Database (Document! X Sample)
AdventureWorks Database / Purchasing Schema / Purchasing.PurchaseOrderHeader Table
In This Topic
    Purchasing.PurchaseOrderHeader Table
    In This Topic
    Description
    General purchase order information. See PurchaseOrderDetail.
    Properties
    Creation Date27/10/2017 14:33
    File GroupPRIMARY
    Text File Group
    System Object
    Published for Replication
    Rows4012
    Data Space Used336.00 KB
    Index Space Used160.00 KB
    Columns
     Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
    Primary Key Primary key.Integer4   
     Incremental number to track changes to the purchase order over time.UnsignedTinyInt1 
    ((0))
     
     Order current status. 1 = Pending; 2 = Approved; 3 = Rejected; 4 = CompleteUnsignedTinyInt1 
    ((1))
     
     Employee who created the purchase order. Foreign key to Employee.BusinessEntityID.Integer4   
     Vendor with whom the purchase order is placed. Foreign key to Vendor.BusinessEntityID.Integer4   
     Shipping method. Foreign key to ShipMethod.ShipMethodID.Integer4   
     Purchase order creation date.DBTimeStamp4 
    (getdate())
     
     Estimated shipment date from the vendor.DBTimeStamp4  
     Purchase order subtotal. Computed as SUM(PurchaseOrderDetail.LineTotal)for the appropriate PurchaseOrderID.Currency8 
    ((0.00))
     
     Tax amount.Currency8 
    ((0.00))
     
     Shipping cost.Currency8 
    ((0.00))
     
     Total due to vendor. Computed as Subtotal + TaxAmt + Freight.Currency8  
    (isnull(([SubTotal]+[TaxAmt])+[Freight],(0)))
     Date and time the record was last updated.DBTimeStamp4 
    (getdate())
     
    Indexes
    IndexDescriptionPrimaryUnique
    Nonclustered index.  
    Nonclustered index.  
    Primary key (clustered) constraint
    Check Constraints
    NameDescriptionExpression
    Check constraint [Freight] >= (0.00)
    ([Freight]>=(0.00))
    Check constraint [ShipDate] >= [OrderDate] OR [ShipDate] IS NULL
    ([ShipDate]>=[OrderDate] OR [ShipDate] IS NULL)
    Check constraint [Status] BETWEEN (1) AND (4)
    ([Status]>=(1) AND [Status]<=(4))
    Check constraint [SubTotal] >= (0.00)
    ([SubTotal]>=(0.00))
    Check constraint [TaxAmt] >= (0.00)
    ([TaxAmt]>=(0.00))
    Triggers
    TriggerDescription
    AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the PurchaseOrderHeader table.
    Relationships
    RelationshipDescription
    Foreign key constraint referencing Employee.EmployeeID.
    Foreign key constraint referencing ShipMethod.ShipMethodID.
    Foreign key constraint referencing Vendor.VendorID.
    Objects that depend on Purchasing.PurchaseOrderHeader
     Database ObjectObject TypeDescriptionDep Level
    iPurchaseOrderDetail triggeriPurchaseOrderDetailTriggerAFTER INSERT trigger that inserts a row in the TransactionHistory table and updates the PurchaseOrderHeader.SubTotal column.3
    Purchasing.PurchaseOrderDetail tablePurchasing.PurchaseOrderDetailTableIndividual products associated with a specific purchase order. See PurchaseOrderHeader.2
    uPurchaseOrderDetail triggeruPurchaseOrderDetailTriggerAFTER UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in PurchaseOrderDetail and updates the PurchaseOrderHeader.SubTotal column.3
    uPurchaseOrderHeader triggeruPurchaseOrderHeaderTriggerAFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the PurchaseOrderHeader table.2
    Objects that Purchasing.PurchaseOrderHeader depends on
     Database ObjectObject TypeDescriptionDep Level
    dbo.AccountNumber datatypedbo.AccountNumberUser Defined Data Type 2
    HumanResources.Employee tableHumanResources.EmployeeTableEmployee information such as salary, department, and title.3
    dbo.ErrorLog tabledbo.ErrorLogTableAudit 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.3
    dbo.Flag datatypedbo.FlagUser Defined Data Type 4
    dbo.NameStyle datatypedbo.NameStyleUser Defined Data Type 5
    Person.Person tablePerson.PersonTableHuman beings involved with AdventureWorks: employees, customer contacts, and vendor contacts.4
    Purchasing.ShipMethod tablePurchasing.ShipMethodTableShipping company lookup table.2
    dbo.uspLogError proceduredbo.uspLogErrorStored ProcedureLogs 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.2
    dbo.uspPrintError proceduredbo.uspPrintErrorStored ProcedurePrints 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.2
    Purchasing.Vendor tablePurchasing.VendorTableCompanies from whom Adventure Works Cycles purchases parts or other goods.1
    SQL
    SET ANSI_NULLS ON
    SET QUOTED_IDENTIFIER ON
    CREATE TABLE [Purchasing].[PurchaseOrderHeader](
        [PurchaseOrderID] [int] IDENTITY(1,1) NOT NULL,
        [RevisionNumber] [tinyint] NOT NULL,
        [Status] [tinyint] NOT NULL,
        [EmployeeID] [int] NOT NULL,
        [VendorID] [int] NOT NULL,
        [ShipMethodID] [int] NOT NULL,
        [OrderDate] [datetime] NOT NULL,
        [ShipDate] [datetime] NULL,
        [SubTotal] [money] NOT NULL,
        [TaxAmt] [money] NOT NULL,
        [Freight] [money] NOT NULL,
        [TotalDue]  AS (isnull(([SubTotal]+[TaxAmt])+[Freight],(0))) PERSISTED NOT NULL,
        [ModifiedDate] [datetime] NOT NULL,
     CONSTRAINT [PK_PurchaseOrderHeader_PurchaseOrderID] PRIMARY KEY CLUSTERED 
    (
        [PurchaseOrderID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] ADD  CONSTRAINT [DF_PurchaseOrderHeader_RevisionNumber]  DEFAULT ((0)) FOR [RevisionNumber]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] ADD  CONSTRAINT [DF_PurchaseOrderHeader_Status]  DEFAULT ((1)) FOR [Status]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] ADD  CONSTRAINT [DF_PurchaseOrderHeader_OrderDate]  DEFAULT (getdate()) FOR [OrderDate]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] ADD  CONSTRAINT [DF_PurchaseOrderHeader_SubTotal]  DEFAULT ((0.00)) FOR [SubTotal]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] ADD  CONSTRAINT [DF_PurchaseOrderHeader_TaxAmt]  DEFAULT ((0.00)) FOR [TaxAmt]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] ADD  CONSTRAINT [DF_PurchaseOrderHeader_Freight]  DEFAULT ((0.00)) FOR [Freight]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] ADD  CONSTRAINT [DF_PurchaseOrderHeader_ModifiedDate]  DEFAULT (getdate()) FOR [ModifiedDate]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseOrderHeader_Employee_EmployeeID] FOREIGN KEY([EmployeeID])
    REFERENCES [HumanResources].[Employee] ([BusinessEntityID])
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] CHECK CONSTRAINT [FK_PurchaseOrderHeader_Employee_EmployeeID]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseOrderHeader_ShipMethod_ShipMethodID] FOREIGN KEY([ShipMethodID])
    REFERENCES [Purchasing].[ShipMethod] ([ShipMethodID])
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] CHECK CONSTRAINT [FK_PurchaseOrderHeader_ShipMethod_ShipMethodID]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseOrderHeader_Vendor_VendorID] FOREIGN KEY([VendorID])
    REFERENCES [Purchasing].[Vendor] ([BusinessEntityID])
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] CHECK CONSTRAINT [FK_PurchaseOrderHeader_Vendor_VendorID]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader]  WITH CHECK ADD  CONSTRAINT [CK_PurchaseOrderHeader_Freight] CHECK  (([Freight]>=(0.00)))
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] CHECK CONSTRAINT [CK_PurchaseOrderHeader_Freight]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader]  WITH CHECK ADD  CONSTRAINT [CK_PurchaseOrderHeader_ShipDate] CHECK  (([ShipDate]>=[OrderDate] OR [ShipDate] IS NULL))
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] CHECK CONSTRAINT [CK_PurchaseOrderHeader_ShipDate]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader]  WITH CHECK ADD  CONSTRAINT [CK_PurchaseOrderHeader_Status] CHECK  (([Status]>=(1) AND [Status]<=(4)))
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] CHECK CONSTRAINT [CK_PurchaseOrderHeader_Status]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader]  WITH CHECK ADD  CONSTRAINT [CK_PurchaseOrderHeader_SubTotal] CHECK  (([SubTotal]>=(0.00)))
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] CHECK CONSTRAINT [CK_PurchaseOrderHeader_SubTotal]
    ALTER TABLE [Purchasing].[PurchaseOrderHeader]  WITH CHECK ADD  CONSTRAINT [CK_PurchaseOrderHeader_TaxAmt] CHECK  (([TaxAmt]>=(0.00)))
    ALTER TABLE [Purchasing].[PurchaseOrderHeader] CHECK CONSTRAINT [CK_PurchaseOrderHeader_TaxAmt]
    See Also