AdventureWorks
Production.WorkOrder Table
Description
Manufacturing work orders.
Properties
Creation Date08/01/2010 08:40
File GroupPRIMARY
Text File Group
System Object
Published for Replication
Rows72591
Data Space Used4,184.00 KB
Index Space Used1,704.00 KB
Columns
 Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
Primary Key WorkOrderIDPrimary key for WorkOrder records.int4   
 ProductIDProduct identification number. Foreign key to Product.ProductID.int4   
 OrderQtyProduct quantity to build.int4   
 StockedQtyQuantity built and put in inventory.int4  
(isnull([OrderQty]-[ScrappedQty],(0)))
 ScrappedQtyQuantity that failed inspection.smallint2   
 StartDateWork order start date.datetime4   
 EndDateWork order end date.datetime4  
 DueDateWork order due date.datetime4   
 ScrapReasonIDReason for inspection failure.smallint2  
 ModifiedDateDate and time the record was last updated.datetime4 
(getdate())
 
Indexes
IndexDescriptionPrimaryUnique
IX_WorkOrder_ProductIDNonclustered index.  
IX_WorkOrder_ScrapReasonIDNonclustered index.  
PK_WorkOrder_WorkOrderIDPrimary key (clustered) constraint
Check Constraints
NameDescriptionExpression
CK_WorkOrder_EndDateCheck constraint [EndDate] >= [StartDate] OR [EndDate] IS NULL
([EndDate]>=[StartDate] OR [EndDate] IS NULL)
CK_WorkOrder_OrderQtyCheck constraint [OrderQty] > (0)
([OrderQty]>(0))
CK_WorkOrder_ScrappedQtyCheck constraint [ScrappedQty] >= (0)
([ScrappedQty]>=(0))
Triggers
TriggerDescription
iWorkOrderAFTER INSERT trigger that inserts a row in the TransactionHistory table.
uWorkOrderAFTER UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in the WorkOrder table.
Relationships
RelationshipDescription
FK_WorkOrder_Product_ProductIDForeign key constraint referencing Product.ProductID.
FK_WorkOrder_ScrapReason_ScrapReasonIDForeign key constraint referencing ScrapReason.ScrapReasonID.
FK_WorkOrderRouting_WorkOrder_WorkOrderIDForeign key constraint referencing WorkOrder.WorkOrderID.
Objects that depend on Production.WorkOrder
 Database ObjectObject TypeDescriptionDep Level
iWorkOrder triggeriWorkOrderTriggerAFTER INSERT trigger that inserts a row in the TransactionHistory table.1
uWorkOrder triggeruWorkOrderTriggerAFTER UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in the WorkOrder table.1
Production.WorkOrderRouting tableProduction.WorkOrderRoutingTableWork order details.1
Objects that Production.WorkOrder depends on
 Database ObjectObject TypeDescriptionDep Level
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.2
dbo.Flag datatypedbo.FlagUser Defined Data Type 2
dbo.Name datatypedbo.NameUser Defined Data Type 2
Production.Product tableProduction.ProductTableProducts sold or used in the manfacturing of sold products.1
Production.ProductCategory tableProduction.ProductCategoryTableHigh-level product categorization.3
Production.ProductModel tableProduction.ProductModelTableProduct model classification.2
Production.ProductSubcategory tableProduction.ProductSubcategoryTableProduct subcategories. See ProductCategory table.2
Production.ScrapReason tableProduction.ScrapReasonTableManufacturing failure reasons lookup table.1
Production.TransactionHistory tableProduction.TransactionHistoryTableRecord of each purchase order, sales order, or work order transaction year to date.1
Production.UnitMeasure tableProduction.UnitMeasureTableUnit of measure 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.1
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.1
SQL
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [Production].[WorkOrder](
	[WorkOrderID] [int] IDENTITY(1,1) NOT NULL,
	[ProductID] [int] NOT NULL,
	[OrderQty] [int] NOT NULL,
	[StockedQty]  AS (isnull([OrderQty]-[ScrappedQty],(0))),
	[ScrappedQty] [smallint] NOT NULL,
	[StartDate] [datetime] NOT NULL,
	[EndDate] [datetime] NULL,
	[DueDate] [datetime] NOT NULL,
	[ScrapReasonID] [smallint] NULL,
	[ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_WorkOrder_WorkOrderID] PRIMARY KEY CLUSTERED 
(
	[WorkOrderID] 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 [Production].[WorkOrder]  WITH CHECK ADD  CONSTRAINT [FK_WorkOrder_Product_ProductID] FOREIGN KEY([ProductID])
REFERENCES [Product] ([ProductID])
ALTER TABLE [Production].[WorkOrder] CHECK CONSTRAINT [FK_WorkOrder_Product_ProductID]
ALTER TABLE [Production].[WorkOrder]  WITH CHECK ADD  CONSTRAINT [FK_WorkOrder_ScrapReason_ScrapReasonID] FOREIGN KEY([ScrapReasonID])
REFERENCES [ScrapReason] ([ScrapReasonID])
ALTER TABLE [Production].[WorkOrder] CHECK CONSTRAINT [FK_WorkOrder_ScrapReason_ScrapReasonID]
ALTER TABLE [Production].[WorkOrder]  WITH CHECK ADD  CONSTRAINT [CK_WorkOrder_EndDate] CHECK  (([EndDate]>=[StartDate] OR [EndDate] IS NULL))
ALTER TABLE [Production].[WorkOrder] CHECK CONSTRAINT [CK_WorkOrder_EndDate]
ALTER TABLE [Production].[WorkOrder]  WITH CHECK ADD  CONSTRAINT [CK_WorkOrder_OrderQty] CHECK  (([OrderQty]>(0)))
ALTER TABLE [Production].[WorkOrder] CHECK CONSTRAINT [CK_WorkOrder_OrderQty]
ALTER TABLE [Production].[WorkOrder]  WITH CHECK ADD  CONSTRAINT [CK_WorkOrder_ScrappedQty] CHECK  (([ScrappedQty]>=(0)))
ALTER TABLE [Production].[WorkOrder] CHECK CONSTRAINT [CK_WorkOrder_ScrappedQty]
ALTER TABLE [Production].[WorkOrder] ADD  CONSTRAINT [DF_WorkOrder_ModifiedDate]  DEFAULT (getdate()) FOR [ModifiedDate]
See Also

Related Objects

Production Schema
AdventureWorks Database

 

 


© 2012 All Rights Reserved.

Send comments on this topic.