AdventureWorks database
AdventureWorks Sample OLTP Database
Database server:
Database size: 178.75 MB
Documentation date: 14/07/2008
|
dbo.AWBuildVersion dbo.DatabaseLog dbo.ErrorLog HumanResources.Department (demo version, please register) HumanResources.Employee (demo version, please register) HumanResources.EmployeeAddress (demo version, please register) HumanResources.EmployeeDepartmentHistory (demo version, please register) HumanResources.EmployeePayHistory (demo version, please register) HumanResources.JobCandidate (demo version, please register) HumanResources.Shift (demo version, please register) Person.Address (demo version, please register) Person.AddressType (demo version, please register) Person.Contact (demo version, please register) Person.ContactType (demo version, please register) Person.CountryRegion (demo version, please register) Person.StateProvince (demo version, please register) Production.BillOfMaterials (demo version, please register) Production.Culture (demo version, please register) Production.Document (demo version, please register) Production.Illustration (demo version, please register) Production.Location (demo version, please register) Production.Product (demo version, please register) Production.ProductCategory (demo version, please register) Production.ProductCostHistory (demo version, please register) Production.ProductDescription (demo version, please register) Production.ProductDocument (demo version, please register) Production.ProductInventory (demo version, please register) Production.ProductListPriceHistory (demo version, please register) Production.ProductModel (demo version, please register) Production.ProductModelIllustration (demo version, please register) Production.ProductModelProductDescriptionCulture (demo version, please register) Production.ProductPhoto (demo version, please register) Production.ProductProductPhoto (demo version, please register) Production.ProductReview (demo version, please register) Production.ProductSubcategory (demo version, please register) Production.ScrapReason (demo version, please register) Production.TransactionHistory (demo version, please register) Production.TransactionHistoryArchive (demo version, please register) Production.UnitMeasure (demo version, please register) Production.WorkOrder (demo version, please register) Production.WorkOrderRouting (demo version, please register) Purchasing.ProductVendor (demo version, please register) Purchasing.PurchaseOrderDetail (demo version, please register) Purchasing.PurchaseOrderHeader (demo version, please register) Purchasing.ShipMethod (demo version, please register) Purchasing.Vendor (demo version, please register) Purchasing.VendorAddress (demo version, please register) Purchasing.VendorContact (demo version, please register) Sales.ContactCreditCard (demo version, please register) Sales.CountryRegionCurrency (demo version, please register) Sales.CreditCard (demo version, please register) Sales.Currency (demo version, please register) Sales.CurrencyRate (demo version, please register) Sales.Customer (demo version, please register) Sales.CustomerAddress (demo version, please register) Sales.Individual (demo version, please register) Sales.SalesOrderDetail (demo version, please register) Sales.SalesOrderHeader (demo version, please register) Sales.SalesOrderHeaderSalesReason (demo version, please register) Sales.SalesPerson (demo version, please register) Sales.SalesPersonQuotaHistory (demo version, please register) Sales.SalesReason (demo version, please register) Sales.SalesTaxRate (demo version, please register) Sales.SalesTerritory (demo version, please register) Sales.SalesTerritoryHistory (demo version, please register) Sales.ShoppingCartItem (demo version, please register) Sales.SpecialOffer (demo version, please register) Sales.SpecialOfferProduct (demo version, please register) Sales.Store (demo version, please register) Sales.StoreContact (demo version, please register)
| HumanResources.vEmployee HumanResources.vEmployeeDepartment HumanResources.vEmployeeDepartmentHistory HumanResources.vJobCandidate HumanResources.vJobCandidateEducation HumanResources.vJobCandidateEmployment Person.vAdditionalContactInfo Person.vStateProvinceCountryRegion Production.vProductAndDescription Production.vProductModelCatalogDescription Production.vProductModelInstructions Purchasing.vVendor Sales.vIndividualCustomer Sales.vIndividualDemographics Sales.vSalesPerson Sales.vSalesPersonSalesByFiscalYears Sales.vStoreWithDemographics
| dbo.uspGetBillOfMaterials dbo.uspGetEmployeeManagers dbo.uspGetManagerEmployees dbo.uspGetWhereUsedProductID dbo.uspLogError dbo.uspPrintError HumanResources.uspUpdateEmployeeHireInfo HumanResources.uspUpdateEmployeeLogin HumanResources.uspUpdateEmployeePersonalInfo
|

(up)
Table: dbo.AWBuildVersion
Current version number of the AdventureWorks sample database.
|
PK | SystemInformationID | tinyint | | | Primary key for AWBuildVersion records. |
| Database Version | nvarchar
(25)
| | | Version number of the database in 9.yy.mm.dd.00 format. |
| VersionDate | datetime | | | Date and time the record was last updated. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Indexes
| PK_AWBuildVersion_SystemInformationID | SystemInformationID | ASC | Yes | CLUSTERED |
Table definition
CREATE TABLE [dbo.AWBuildVersion] (
[SystemInformationID] [tinyint] IDENTITY (1, 1) NOT NULL ,
[Database Version] [nvarchar] (25) COLLATE Latin1_General_CS_AS NOT NULL ,
[VersionDate] [datetime] NOT NULL ,
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_AWBuildVersion_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_AWBuildVersion_SystemInformationID] PRIMARY KEY CLUSTERED
(
[SystemInformationID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
(up)
Table: dbo.DatabaseLog
Audit table tracking all DDL changes made to the AdventureWorks database. Data is captured by the database trigger ddlDatabaseTriggerLog.
|
PK | DatabaseLogID | int | | | Primary key for DatabaseLog records. |
| PostTime | datetime | | | The date and time the DDL change occurred. |
| DatabaseUser | nvarchar
(128)
| | | The user who implemented the DDL change. |
| Event | nvarchar
(128)
| | | The type of DDL statement that was executed. |
| Schema | nvarchar
(128)
| Yes | | The schema to which the changed object belongs. |
| Object | nvarchar
(128)
| Yes | | The object that was changed by the DDL statment. |
| TSQL | nvarchar | | | The exact Transact-SQL statement that was executed. |
| XmlEvent | xml | | | The raw XML data generated by database trigger. |
Indexes
| PK_DatabaseLog_DatabaseLogID | DatabaseLogID | ASC | Yes | NONCLUSTERED |
Table definition
CREATE TABLE [dbo.DatabaseLog] (
[DatabaseLogID] [int] IDENTITY (1, 1) NOT NULL ,
[PostTime] [datetime] NOT NULL ,
[DatabaseUser] [sysname] NOT NULL ,
[Event] [sysname] NOT NULL ,
[Schema] [sysname] NULL ,
[Object] [sysname] NULL ,
[TSQL] [nvarchar] (0) COLLATE Latin1_General_CS_AS NOT NULL ,
[XmlEvent] [xml] NOT NULL ,
CONSTRAINT [PK_DatabaseLog_DatabaseLogID] PRIMARY KEY NONCLUSTERED
(
[DatabaseLogID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
(up)
Table: dbo.ErrorLog
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.
|
PK | ErrorLogID | int | | | Primary key for ErrorLog records. |
| ErrorTime | datetime | | (getdate()) | The date and time at which the error occurred. |
| UserName | nvarchar
(128)
| | | The user who executed the batch in which the error occurred. |
| ErrorNumber | int | | | The error number of the error that occurred. |
| ErrorSeverity | int | Yes | | The severity of the error that occurred. |
| ErrorState | int | Yes | | The state number of the error that occurred. |
| ErrorProcedure | nvarchar
(126)
| Yes | | The name of the stored procedure or trigger where the error occurred. |
| ErrorLine | int | Yes | | The line number at which the error occurred. |
| ErrorMessage | nvarchar
(4000)
| | | The message text of the error that occurred. |
Indexes
| PK_ErrorLog_ErrorLogID | ErrorLogID | ASC | Yes | CLUSTERED |
Objects that depend on dbo.ErrorLog:
dbo.uspLogError
Table definition
CREATE TABLE [dbo.ErrorLog] (
[ErrorLogID] [int] IDENTITY (1, 1) NOT NULL ,
[ErrorTime] [datetime] NOT NULL CONSTRAINT [DF_ErrorLog_ErrorTime] DEFAULT (getdate()),
[UserName] [sysname] NOT NULL ,
[ErrorNumber] [int] NOT NULL ,
[ErrorSeverity] [int] NULL ,
[ErrorState] [int] NULL ,
[ErrorProcedure] [nvarchar] (126) COLLATE Latin1_General_CS_AS NULL ,
[ErrorLine] [int] NULL ,
[ErrorMessage] [nvarchar] (4000) COLLATE Latin1_General_CS_AS NOT NULL ,
CONSTRAINT [PK_ErrorLog_ErrorLogID] PRIMARY KEY CLUSTERED
(
[ErrorLogID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
(up)
Table: HumanResources.Department (demo version, please register)
Lookup table containing the departments within the Adventure Works Cycles company.
|
PK | DepartmentID | smallint | | | Primary key for Department records. |
| IX | Name | Name | | | Name of the department. |
| GroupName | Name | | | Name of the group to which the department belongs. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Indexes
| AK_Department_Name | Name | ASC | Yes | NONCLUSTERED |
| PK_Department_DepartmentID | DepartmentID | ASC | Yes | CLUSTERED |
Objects that depend on HumanResources.Department (demo version, please register):
HumanResources.vEmployeeDepartment
HumanResources.vEmployeeDepartmentHistory
Table definition
CREATE TABLE [HumanResources.Department] (
[DepartmentID] [smallint] IDENTITY (1, 1) NOT NULL ,
[Name] [Name] NOT NULL ,
[GroupName] [Name] NOT NULL ,
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_Department_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_Department_DepartmentID] PRIMARY KEY CLUSTERED
(
[DepartmentID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
(up)
Table: HumanResources.Employee (demo version, please register)
Employee information such as salary, department, and title.
|
PK | EmployeeID | int | | | Primary key for Employee records. |
| IX | NationalIDNumber | nvarchar
(15)
| | | Unique national identification number such as a social security number. |
| FK | ContactID | int | | | Identifies the employee in the Contact table. Foreign key to Contact.ContactID. |
| IX | LoginID | nvarchar
(256)
| | | Network login. |
| FK | ManagerID | int | Yes | | Manager to whom the employee is assigned. Foreign Key to Employee.M |
| Title | nvarchar
(50)
| | | Work title such as Buyer or Sales Representative. |
| BirthDate | datetime | | | Date of birth. |
| MaritalStatus | nchar
(1)
| | | M = Married, S = Single |
| Gender | nchar
(1)
| | | M = Male, F = Female |
| HireDate | datetime | | | Employee hired on this date. |
| SalariedFlag | Flag | | ((1)) | Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining. |
| VacationHours | smallint | | ((0)) | Number of available vacation hours. |
| SickLeaveHours | smallint | | ((0)) | Number of available sick leave hours. |
| CurrentFlag | Flag | | ((1)) | 0 = Inactive, 1 = Active |
| IX | rowguid | uniqueidentifier | | (newid()) | ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Foreign keys dependencies:
FK_Employee_Contact_ContactID: ContactID relies upon remote PK_Contact_ContactID (Person.Contact)
FK_Employee_Employee_ManagerID: ManagerID relies upon remote PK_Employee_EmployeeID (HumanResources.Employee)
Indexes
| AK_Employee_LoginID | LoginID | ASC | Yes | NONCLUSTERED |
| AK_Employee_NationalIDNumber | NationalIDNumber | ASC | Yes | NONCLUSTERED |
| AK_Employee_rowguid | rowguid | ASC | Yes | NONCLUSTERED |
| IX_Employee_ManagerID | ManagerID | ASC | | NONCLUSTERED |
| PK_Employee_EmployeeID | EmployeeID | ASC | Yes | CLUSTERED |
Check constraints
| CK_Employee_BirthDate | BirthDate | ([BirthDate]>='1930-01-01' AND [BirthDate]<=dateadd(year,(-18),getdate())) |
| CK_Employee_MaritalStatus | MaritalStatus | (upper([MaritalStatus])='S' OR upper([MaritalStatus])='M') |
| CK_Employee_HireDate | HireDate | ([HireDate]>='1996-07-01' AND [HireDate]<=dateadd(day,(1),getdate())) |
| CK_Employee_Gender | Gender | (upper([Gender])='F' OR upper([Gender])='M') |
| CK_Employee_VacationHours | VacationHours | ([VacationHours]>=(-40) AND [VacationHours]<=(240)) |
| CK_Employee_SickLeaveHours | SickLeaveHours | ([SickLeaveHours]>=(0) AND [SickLeaveHours]<=(120)) |
Triggers
Trigger name: HumanResources.dEmployee
(Created: 26 Apr 2006)
Trigger type: INSTEAD OF DELETE
Trigger active: Yes
Trigger description: INSTEAD OF DELETE trigger which keeps Employees from being deleted.
Trigger definition:
CREATE TRIGGER [HumanResources].[dEmployee] ON [HumanResources].[Employee]
INSTEAD OF DELETE NOT FOR REPLICATION AS
BEGIN
DECLARE @Count int;
SET @Count = @@ROWCOUNT;
IF @Count = 0
RETURN;
SET NOCOUNT ON;
BEGIN
RAISERROR
(N'Employees cannot be deleted. They can only be marked as not current.', -- Message
10, -- Severity.
1); -- State.
-- Rollback any active or uncommittable transactions
IF @@TRANCOUNT > 0
BEGIN
ROLLBACK TRANSACTION;
END
END;
END;
Objects that depend on HumanResources.Employee (demo version, please register):
dbo.uspGetEmployeeManagers
dbo.uspGetManagerEmployees
HumanResources.uspUpdateEmployeeHireInfo
HumanResources.uspUpdateEmployeeLogin
HumanResources.uspUpdateEmployeePersonalInfo
HumanResources.vEmployee
HumanResources.vEmployeeDepartment
HumanResources.vEmployeeDepartmentHistory
Sales.vSalesPerson
Sales.vSalesPersonSalesByFiscalYears
Table definition
CREATE TABLE [HumanResources.Employee] (
[EmployeeID] [int] IDENTITY (1, 1) NOT NULL ,
[NationalIDNumber] [nvarchar] (15) COLLATE Latin1_General_CS_AS NOT NULL ,
[ContactID] [int] NOT NULL ,
[LoginID] [nvarchar] (256) COLLATE Latin1_General_CS_AS NOT NULL ,
[ManagerID] [int] NULL ,
[Title] [nvarchar] (50) COLLATE Latin1_General_CS_AS NOT NULL ,
[BirthDate] [datetime] NOT NULL ,
[MaritalStatus] [nchar] (1) COLLATE Latin1_General_CS_AS NOT NULL ,
[Gender] [nchar] (1) COLLATE Latin1_General_CS_AS NOT NULL ,
[HireDate] [datetime] NOT NULL ,
[SalariedFlag] [Flag] NOT NULL CONSTRAINT [DF_Employee_SalariedFlag] DEFAULT ((1)),
[VacationHours] [smallint] NOT NULL CONSTRAINT [DF_Employee_VacationHours] DEFAULT ((0)),
[SickLeaveHours] [smallint] NOT NULL CONSTRAINT [DF_Employee_SickLeaveHours] DEFAULT ((0)),
[CurrentFlag] [Flag] NOT NULL CONSTRAINT [DF_Employee_CurrentFlag] DEFAULT ((1)),
[rowguid] uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT [DF_Employee_rowguid] DEFAULT (newid()),
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_Employee_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_Employee_EmployeeID] PRIMARY KEY CLUSTERED
(
[EmployeeID]
) ON [PRIMARY] ,
CONSTRAINT [FK_Employee_Contact_ContactID] FOREIGN KEY
(
[ContactID]
) REFERENCES [Contact] (
[ContactID]
),
CONSTRAINT [FK_Employee_Employee_ManagerID] FOREIGN KEY
(
[ManagerID]
) REFERENCES [Employee] (
[EmployeeID]
),
CONSTRAINT [CK_Employee_BirthDate] CHECK ([BirthDate]>='1930-01-01' AND [BirthDate]<=dateadd(year,(-18),getdate())),
CONSTRAINT [CK_Employee_Gender] CHECK (upper([Gender])='F' OR upper([Gender])='M'),
CONSTRAINT [CK_Employee_HireDate] CHECK ([HireDate]>='1996-07-01' AND [HireDate]<=dateadd(day,(1),getdate())),
CONSTRAINT [CK_Employee_MaritalStatus] CHECK (upper([MaritalStatus])='S' OR upper([MaritalStatus])='M'),
CONSTRAINT [CK_Employee_SickLeaveHours] CHECK ([SickLeaveHours]>=(0) AND [SickLeaveHours]<=(120)),
CONSTRAINT [CK_Employee_VacationHours] CHECK ([VacationHours]>=(-40) AND [VacationHours]<=(240))
) ON [PRIMARY]
GO
(up)
Table: HumanResources.EmployeeAddress (demo version, please register)
Cross-reference table mapping employees to their address(es).
|
PK FK | EmployeeID | int | | | Primary key. Foreign key to Employee.EmployeeID. |
|
PK FK | AddressID | int | | | Primary key. Foreign key to Address.AddressID. |
| IX | rowguid | uniqueidentifier | | (newid()) | ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Foreign keys dependencies:
FK_EmployeeAddress_Employee_EmployeeID: EmployeeID relies upon remote PK_Employee_EmployeeID (HumanResources.Employee)
FK_EmployeeAddress_Address_AddressID: AddressID relies upon remote PK_Address_AddressID (Person.Address)
Indexes
| AK_EmployeeAddress_rowguid | rowguid | ASC | Yes | NONCLUSTERED |
| PK_EmployeeAddress_EmployeeID_AddressID | EmployeeID | ASC | Yes | CLUSTERED |
| AddressID | ASC | Yes | CLUSTERED |
Objects that depend on HumanResources.EmployeeAddress (demo version, please register):
HumanResources.vEmployee
Sales.vSalesPerson
Table definition
CREATE TABLE [HumanResources.EmployeeAddress] (
[EmployeeID] [int] NOT NULL ,
[AddressID] [int] NOT NULL ,
[rowguid] uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT [DF_EmployeeAddress_rowguid] DEFAULT (newid()),
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_EmployeeAddress_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_EmployeeAddress_EmployeeID_AddressID] PRIMARY KEY CLUSTERED
(
[EmployeeID],
[AddressID]
) ON [PRIMARY] ,
CONSTRAINT [FK_EmployeeAddress_Address_AddressID] FOREIGN KEY
(
[AddressID]
) REFERENCES [Address] (
[AddressID]
),
CONSTRAINT [FK_EmployeeAddress_Employee_EmployeeID] FOREIGN KEY
(
[EmployeeID]
) REFERENCES [Employee] (
[EmployeeID]
)
) ON [PRIMARY]
GO
(up)
Table: HumanResources.EmployeeDepartmentHistory (demo version, please register)
Employee department transfers.
|
PK FK | EmployeeID | int | | | Employee identification number. Foreign key to Employee.EmployeeID. |
|
PK FK | DepartmentID | smallint | | | Department in which the employee worked including currently. Foreign key to Department.DepartmentID. |
|
PK FK | ShiftID | tinyint | | | Identifies which 8-hour shift the employee works. Foreign key to Shift.Shift.ID. |
|
PK | StartDate | datetime | | | Date the employee started work in the department. |
| EndDate | datetime | Yes | | Date the employee left the department. NULL = Current department. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Foreign keys dependencies:
FK_EmployeeDepartmentHistory_Employee_EmployeeID: EmployeeID relies upon remote PK_Employee_EmployeeID (HumanResources.Employee)
FK_EmployeeDepartmentHistory_Department_DepartmentID: DepartmentID relies upon remote PK_Department_DepartmentID (HumanResources.Department)
FK_EmployeeDepartmentHistory_Shift_ShiftID: ShiftID relies upon remote PK_Shift_ShiftID (HumanResources.Shift)
Indexes
| IX_EmployeeDepartmentHistory_DepartmentID | DepartmentID | ASC | | NONCLUSTERED |
| IX_EmployeeDepartmentHistory_ShiftID | ShiftID | ASC | | NONCLUSTERED |
| PK_EmployeeDepartmentHistory_EmployeeID_StartDate_DepartmentID | EmployeeID | ASC | Yes | CLUSTERED |
| DepartmentID | ASC | Yes | CLUSTERED |
| ShiftID | ASC | Yes | CLUSTERED |
| StartDate | ASC | Yes | CLUSTERED |
Check constraints
| CK_EmployeeDepartmentHistory_EndDate | StartDate | ([EndDate]>=[StartDate] OR [EndDate] IS NULL) |
| CK_EmployeeDepartmentHistory_EndDate | EndDate | ([EndDate]>=[StartDate] OR [EndDate] IS NULL) |
Objects that depend on HumanResources.EmployeeDepartmentHistory (demo version, please register):
HumanResources.vEmployeeDepartment
HumanResources.vEmployeeDepartmentHistory
Table definition
CREATE TABLE [HumanResources.EmployeeDepartmentHistory] (
[EmployeeID] [int] NOT NULL ,
[DepartmentID] [smallint] NOT NULL ,
[ShiftID] [tinyint] NOT NULL ,
[StartDate] [datetime] NOT NULL ,
[EndDate] [datetime] NULL ,
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_EmployeeDepartmentHistory_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_EmployeeDepartmentHistory_EmployeeID_StartDate_DepartmentID] PRIMARY KEY CLUSTERED
(
[EmployeeID],
[StartDate],
[DepartmentID],
[ShiftID]
) ON [PRIMARY] ,
CONSTRAINT [FK_EmployeeDepartmentHistory_Department_DepartmentID] FOREIGN KEY
(
[DepartmentID]
) REFERENCES [Department] (
[DepartmentID]
),
CONSTRAINT [FK_EmployeeDepartmentHistory_Employee_EmployeeID] FOREIGN KEY
(
[EmployeeID]
) REFERENCES [Employee] (
[EmployeeID]
),
CONSTRAINT [FK_EmployeeDepartmentHistory_Shift_ShiftID] FOREIGN KEY
(
[ShiftID]
) REFERENCES [Shift] (
[ShiftID]
),
CONSTRAINT [CK_EmployeeDepartmentHistory_EndDate] CHECK ([EndDate]>=[StartDate] OR [EndDate] IS NULL)
) ON [PRIMARY]
GO
(up)
Table: HumanResources.EmployeePayHistory (demo version, please register)
Employee pay history.
|
PK FK | EmployeeID | int | | | Employee identification number. Foreign key to Employee.EmployeeID. |
|
PK | RateChangeDate | datetime | | | Date the change in pay is effective |
| Rate | money | | | Salary hourly rate. |
| PayFrequency | tinyint | | | 1 = Salary received monthly, 2 = Salary received biweekly |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Foreign keys dependencies:
FK_EmployeePayHistory_Employee_EmployeeID: EmployeeID relies upon remote PK_Employee_EmployeeID (HumanResources.Employee)
Indexes
| PK_EmployeePayHistory_EmployeeID_RateChangeDate | EmployeeID | ASC | Yes | CLUSTERED |
| RateChangeDate | ASC | Yes | CLUSTERED |
Check constraints
| CK_EmployeePayHistory_PayFrequency | PayFrequency | ([PayFrequency]=(2) OR [PayFrequency]=(1)) |
| CK_EmployeePayHistory_Rate | Rate | ([Rate]>=(6.50) AND [Rate]<=(200.00)) |
Objects that depend on HumanResources.EmployeePayHistory (demo version, please register):
HumanResources.uspUpdateEmployeeHireInfo
Table definition
CREATE TABLE [HumanResources.EmployeePayHistory] (
[EmployeeID] [int] NOT NULL ,
[RateChangeDate] [datetime] NOT NULL ,
[Rate] [money] NOT NULL ,
[PayFrequency] [tinyint] NOT NULL ,
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_EmployeePayHistory_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_EmployeePayHistory_EmployeeID_RateChangeDate] PRIMARY KEY CLUSTERED
(
[EmployeeID],
[RateChangeDate]
) ON [PRIMARY] ,
CONSTRAINT [FK_EmployeePayHistory_Employee_EmployeeID] FOREIGN KEY
(
[EmployeeID]
) REFERENCES [Employee] (
[EmployeeID]
),
CONSTRAINT [CK_EmployeePayHistory_PayFrequency] CHECK ([PayFrequency]=(2) OR [PayFrequency]=(1)),
CONSTRAINT [CK_EmployeePayHistory_Rate] CHECK ([Rate]>=(6.50) AND [Rate]<=(200.00))
) ON [PRIMARY]
GO
(up)
Table: HumanResources.JobCandidate (demo version, please register)
Résumés submitted to Human Resources by job applicants.
|
PK | JobCandidateID | int | | | Primary key for JobCandidate records. |
| FK | EmployeeID | int | Yes | | Employee identification number if applicant was hired. Foreign key to Employee.EmployeeID. |
| Resume | xml | Yes | | Résumé in XML format. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Foreign keys dependencies:
FK_JobCandidate_Employee_EmployeeID: EmployeeID relies upon remote PK_Employee_EmployeeID (HumanResources.Employee)
Indexes
| IX_JobCandidate_EmployeeID | EmployeeID | ASC | | NONCLUSTERED |
| PK_JobCandidate_JobCandidateID | JobCandidateID | ASC | Yes | CLUSTERED |
Objects that depend on HumanResources.JobCandidate (demo version, please register):
HumanResources.vJobCandidate
HumanResources.vJobCandidateEducation
HumanResources.vJobCandidateEmployment
Table definition
CREATE TABLE [HumanResources.JobCandidate] (
[JobCandidateID] [int] IDENTITY (1, 1) NOT NULL ,
[EmployeeID] [int] NULL ,
[Resume] [xml] NULL ,
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_JobCandidate_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_JobCandidate_JobCandidateID] PRIMARY KEY CLUSTERED
(
[JobCandidateID]
) ON [PRIMARY] ,
CONSTRAINT [FK_JobCandidate_Employee_EmployeeID] FOREIGN KEY
(
[EmployeeID]
) REFERENCES [Employee] (
[EmployeeID]
)
) ON [PRIMARY]
GO
(up)
Table: HumanResources.Shift (demo version, please register)
Work shift lookup table.
|
PK | ShiftID | tinyint | | | Primary key for Shift records. |
| IX | Name | Name | | | Shift description. |
| IX | StartTime | datetime | | | Shift start time. |
| IX | EndTime | datetime | | | Shift end time. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Indexes
| AK_Shift_Name | Name | ASC | Yes | NONCLUSTERED |
| AK_Shift_StartTime_EndTime | StartTime | ASC | Yes | NONCLUSTERED |
| EndTime | ASC | Yes | NONCLUSTERED |
| PK_Shift_ShiftID | ShiftID | ASC | Yes | CLUSTERED |
Objects that depend on HumanResources.Shift (demo version, please register):
HumanResources.vEmployeeDepartmentHistory
Table definition
CREATE TABLE [HumanResources.Shift] (
[ShiftID] [tinyint] IDENTITY (1, 1) NOT NULL ,
[Name] [Name] NOT NULL ,
[StartTime] [datetime] NOT NULL ,
[EndTime] [datetime] NOT NULL ,
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_Shift_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_Shift_ShiftID] PRIMARY KEY CLUSTERED
(
[ShiftID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
(up)
Table: Person.Address (demo version, please register)
Street address information for customers, employees, and vendors.
|
PK | AddressID | int | | | Primary key for Address records. |
| IX | AddressLine1 | nvarchar
(60)
| | | First street address line. |
| IX | AddressLine2 | nvarchar
(60)
| Yes | | Second street address line. |
| IX | City | nvarchar
(30)
| | | Name of the city. |
| FK | StateProvinceID | int | | | Unique identification number for the state or province. Foreign key to StateProvince table. |
| IX | PostalCode | nvarchar
(15)
| | | Postal code for the street address. |
| IX | rowguid | uniqueidentifier | | (newid()) | ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Foreign keys dependencies:
FK_Address_StateProvince_StateProvinceID: StateProvinceID relies upon remote PK_StateProvince_StateProvinceID (Person.StateProvince)
Indexes
| AK_Address_rowguid | rowguid | ASC | Yes | NONCLUSTERED |
| IX_Address_AddressLine1_AddressLine2_City_StateProvinceID_PostalCode | AddressLine1 | ASC | Yes | NONCLUSTERED |
| AddressLine2 | ASC | Yes | NONCLUSTERED |
| City | ASC | Yes | NONCLUSTERED |
| StateProvinceID | ASC | Yes | NONCLUSTERED |
| PostalCode | ASC | Yes | NONCLUSTERED |
| IX_Address_StateProvinceID | StateProvinceID | ASC | | NONCLUSTERED |
| PK_Address_AddressID | AddressID | ASC | Yes | CLUSTERED |
Objects that depend on Person.Address (demo version, please register):
HumanResources.vEmployee
Purchasing.vVendor
Sales.vIndividualCustomer
Sales.vSalesPerson
Sales.vStoreWithDemographics
Table definition
CREATE TABLE [Person.Address] (
[AddressID] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
[AddressLine1] [nvarchar] (60) COLLATE Latin1_General_CS_AS NOT NULL ,
[AddressLine2] [nvarchar] (60) COLLATE Latin1_General_CS_AS NULL ,
[City] [nvarchar] (30) COLLATE Latin1_General_CS_AS NOT NULL ,
[StateProvinceID] [int] NOT NULL ,
[PostalCode] [nvarchar] (15) COLLATE Latin1_General_CS_AS NOT NULL ,
[rowguid] uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT [DF_Address_rowguid] DEFAULT (newid()),
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_Address_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_Address_AddressID] PRIMARY KEY CLUSTERED
(
[AddressID]
) ON [PRIMARY] ,
CONSTRAINT [FK_Address_StateProvince_StateProvinceID] FOREIGN KEY
(
[StateProvinceID]
) REFERENCES [StateProvince] (
[StateProvinceID]
)
) ON [PRIMARY]
GO
(up)
Table: Person.AddressType (demo version, please register)
Types of addresses stored in the Address table.
|
PK | AddressTypeID | int | | | Primary key for AddressType records. |
| IX | Name | Name | | | Address type description. For example, Billing, Home, or Shipping. |
| IX | rowguid | uniqueidentifier | | (newid()) | ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Indexes
| AK_AddressType_Name | Name | ASC | Yes | NONCLUSTERED |
| AK_AddressType_rowguid | rowguid | ASC | Yes | NONCLUSTERED |
| PK_AddressType_AddressTypeID | AddressTypeID | ASC | Yes | CLUSTERED |
Objects that depend on Person.AddressType (demo version, please register):
Sales.vIndividualCustomer
Sales.vStoreWithDemographics
Table definition
CREATE TABLE [Person.AddressType] (
[AddressTypeID] [int] IDENTITY (1, 1) NOT NULL ,
[Name] [Name] NOT NULL ,
[rowguid] uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT [DF_AddressType_rowguid] DEFAULT (newid()),
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_AddressType_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_AddressType_AddressTypeID] PRIMARY KEY CLUSTERED
(
[AddressTypeID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
(up) Names of each employee, customer contact, and vendor contact.
|
PK | ContactID | int | | | Primary key for Contact records. |
| NameStyle | NameStyle | | ((0)) | 0 = The data in FirstName and LastName are stored in western style (first name, last name) order. 1 = Eastern style (last name, first name) order. |
| Title | nvarchar
(8)
| Yes | | A courtesy title. For example, Mr. or Ms. |
| FirstName | Name | | | First name of the person. |
| MiddleName | Name | Yes | | Middle name or middle initial of the person. |
| LastName | Name | | | Last name of the person. |
| Suffix | nvarchar
(10)
| Yes | | Surname suffix. For example, Sr. or Jr. |
| IX | EmailAddress | nvarchar
(50)
| Yes | | E-mail address for the person. |
| EmailPromotion | int | | ((0)) | 0 = Contact does not wish to receive e-mail promotions, 1 = Contact does wish to receive e-mail promotions from AdventureWorks, 2 = Contact does wish to receive e-mail promotions from AdventureWorks and selected partners. |
| Phone | Phone | Yes | | Phone number associated with the person. |
| PasswordHash | varchar
(128)
| | | Password for the e-mail account. |
| PasswordSalt | varchar
(10)
| | | Random value concatenated with the password string before the password is hashed. |
| IX | AdditionalContactInfo | xml | Yes | | Additional contact information about the person stored in xml format. |
| IX | rowguid | uniqueidentifier | | (newid()) | ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Indexes
| AK_Contact_rowguid | rowguid | ASC | Yes | NONCLUSTERED |
| IX_Contact_EmailAddress | EmailAddress | ASC | | NONCLUSTERED |
| PK_Contact_ContactID | ContactID | ASC | Yes | CLUSTERED |
| PXML_Contact_AddContact | AdditionalContactInfo | ASC | | XML |
Check constraints
| CK_Contact_EmailPromotion | EmailPromotion | ([EmailPromotion]>=(0) AND [EmailPromotion]<=(2)) |
Objects that depend on Person.Contact (demo version, please register):
dbo.uspGetEmployeeManagers
dbo.uspGetManagerEmployees
HumanResources.vEmployee
HumanResources.vEmployeeDepartment
HumanResources.vEmployeeDepartmentHistory
Person.vAdditionalContactInfo
Purchasing.vVendor
Sales.vIndividualCustomer
Sales.vSalesPerson
Sales.vSalesPersonSalesByFiscalYears
Sales.vStoreWithDemographics
Table definition
CREATE TABLE [Person.Contact] (
[ContactID] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
[NameStyle] [NameStyle] NOT NULL CONSTRAINT [DF_Contact_NameStyle] DEFAULT ((0)),
[Title] [nvarchar] (8) COLLATE Latin1_General_CS_AS NULL ,
[FirstName] [Name] NOT NULL ,
[MiddleName] [Name] NULL ,
[LastName] [Name] NOT NULL ,
[Suffix] [nvarchar] (10) COLLATE Latin1_General_CS_AS NULL ,
[EmailAddress] [nvarchar] (50) COLLATE Latin1_General_CS_AS NULL ,
[EmailPromotion] [int] NOT NULL CONSTRAINT [DF_Contact_EmailPromotion] DEFAULT ((0)),
[Phone] [Phone] NULL ,
[PasswordHash] [varchar] (128) COLLATE Latin1_General_CS_AS NOT NULL ,
[PasswordSalt] [varchar] (10) COLLATE Latin1_General_CS_AS NOT NULL ,
[AdditionalContactInfo] [xml] NULL ,
[rowguid] uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT [DF_Contact_rowguid] DEFAULT (newid()),
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_Contact_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_Contact_ContactID] PRIMARY KEY CLUSTERED
(
[ContactID]
) ON [PRIMARY] ,
CONSTRAINT [CK_Contact_EmailPromotion] CHECK ([EmailPromotion]>=(0) AND [EmailPromotion]<=(2))
) ON [PRIMARY]
GO
(up) Lookup table containing the types of contacts stored in Contact.
|
PK | ContactTypeID | int | | | Primary key for ContactType records. |
| IX | Name | Name | | | Contact type description. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Indexes
| AK_ContactType_Name | Name | ASC | Yes | NONCLUSTERED |
| PK_ContactType_ContactTypeID | ContactTypeID | ASC | Yes | CLUSTERED |
Objects that depend on Person.ContactType (demo version, please register):
Purchasing.vVendor
Sales.vStoreWithDemographics
Table definition
CREATE TABLE [Person.ContactType] (
[ContactTypeID] [int] IDENTITY (1, 1) NOT NULL ,
[Name] [Name] NOT NULL ,
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_ContactType_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_ContactType_ContactTypeID] PRIMARY KEY CLUSTERED
(
[ContactTypeID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
(up)
Table: Person.CountryRegion (demo version, please register)
Lookup table containing the ISO standard codes for countries and regions.
|
PK | CountryRegionCode | nvarchar
(3)
| | | ISO standard code for countries and regions. |
| IX | Name | Name | | | Country or region name. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Indexes
| AK_CountryRegion_Name | Name | ASC | Yes | NONCLUSTERED |
| PK_CountryRegion_CountryRegionCode | CountryRegionCode | ASC | Yes | CLUSTERED |
Objects that depend on Person.CountryRegion (demo version, please register):
HumanResources.vEmployee
Person.vStateProvinceCountryRegion
Purchasing.vVendor
Sales.vIndividualCustomer
Sales.vSalesPerson
Sales.vStoreWithDemographics
Table definition
CREATE TABLE [Person.CountryRegion] (
[CountryRegionCode] [nvarchar] (3) COLLATE Latin1_General_CS_AS NOT NULL ,
[Name] [Name] NOT NULL ,
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_CountryRegion_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_CountryRegion_CountryRegionCode] PRIMARY KEY CLUSTERED
(
[CountryRegionCode]
) ON [PRIMARY]
) ON [PRIMARY]
GO
(up)
Table: Person.StateProvince (demo version, please register)
State and province lookup table.
|
PK | StateProvinceID | int | | | Primary key for StateProvince records. |
| IX | StateProvinceCode | nchar
(3)
| | | ISO standard state or province code. |
| FK | CountryRegionCode | nvarchar
(3)
| | | ISO standard country or region code. Foreign key to CountryRegion.CountryRegionCode. |
| IsOnlyStateProvinceFlag | Flag | | ((1)) | 0 = StateProvinceCode exists. 1 = StateProvinceCode unavailable, using CountryRegionCode. |
| IX | Name | Name | | | State or province description. |
| FK | TerritoryID | int | | | ID of the territory in which the state or province is located. Foreign key to SalesTerritory.SalesTerritoryID. |
| IX | rowguid | uniqueidentifier | | (newid()) | ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Foreign keys dependencies:
FK_StateProvince_CountryRegion_CountryRegionCode: CountryRegionCode relies upon remote PK_CountryRegion_CountryRegionCode (Person.CountryRegion)
FK_StateProvince_SalesTerritory_TerritoryID: TerritoryID relies upon remote PK_SalesTerritory_TerritoryID (Sales.SalesTerritory)
Indexes
| AK_StateProvince_Name | Name | ASC | Yes | NONCLUSTERED |
| AK_StateProvince_rowguid | rowguid | ASC | Yes | NONCLUSTERED |
| AK_StateProvince_StateProvinceCode_CountryRegionCode | StateProvinceCode | ASC | Yes | NONCLUSTERED |
| CountryRegionCode | ASC | Yes | NONCLUSTERED |
| PK_StateProvince_StateProvinceID | StateProvinceID | ASC | Yes | CLUSTERED |
Objects that depend on Person.StateProvince (demo version, please register):
HumanResources.vEmployee
Person.vStateProvinceCountryRegion
Purchasing.vVendor
Sales.vIndividualCustomer
Sales.vSalesPerson
Sales.vStoreWithDemographics
Table definition
CREATE TABLE [Person.StateProvince] (
[StateProvinceID] [int] IDENTITY (1, 1) NOT NULL ,
[StateProvinceCode] [nchar] (3) COLLATE Latin1_General_CS_AS NOT NULL ,
[CountryRegionCode] [nvarchar] (3) COLLATE Latin1_General_CS_AS NOT NULL ,
[IsOnlyStateProvinceFlag] [Flag] NOT NULL CONSTRAINT [DF_StateProvince_IsOnlyStateProvinceFlag] DEFAULT ((1)),
[Name] [Name] NOT NULL ,
[TerritoryID] [int] NOT NULL ,
[rowguid] uniqueidentifier ROWGUIDCOL NOT NULL CONSTRAINT [DF_StateProvince_rowguid] DEFAULT (newid()),
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_StateProvince_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_StateProvince_StateProvinceID] PRIMARY KEY CLUSTERED
(
[StateProvinceID]
) ON [PRIMARY] ,
CONSTRAINT [FK_StateProvince_CountryRegion_CountryRegionCode] FOREIGN KEY
(
[CountryRegionCode]
) REFERENCES [CountryRegion] (
[CountryRegionCode]
),
CONSTRAINT [FK_StateProvince_SalesTerritory_TerritoryID] FOREIGN KEY
(
[TerritoryID]
) REFERENCES [SalesTerritory] (
[TerritoryID]
)
) ON [PRIMARY]
GO
(up)
Table: Production.BillOfMaterials (demo version, please register)
Items required to make bicycles and bicycle subassemblies. It identifies the heirarchical relationship between a parent product and its components.
|
PK | BillOfMaterialsID | int | | | Primary key for BillOfMaterials records. |
| FK | ProductAssemblyID | int | Yes | | Parent product identification number. Foreign key to Product.ProductID. |
| FK | ComponentID | int | | | Component identification number. Foreign key to Product.ProductID. |
| IX | StartDate | datetime | | (getdate()) | Date the component started being used in the assembly item. |
| EndDate | datetime | Yes | | Date the component stopped being used in the assembly item. |
| FK | UnitMeasureCode | nchar
(3)
| | | Standard code identifying the unit of measure for the quantity. |
| BOMLevel | smallint | | | Indicates the depth the component is from its parent (AssemblyID). |
| PerAssemblyQty | decimal
(8.2)
| | ((1.00)) | Quantity of the component needed to create the assembly. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Foreign keys dependencies:
FK_BillOfMaterials_Product_ProductAssemblyID: ProductAssemblyID relies upon remote PK_Product_ProductID (Production.Product)
FK_BillOfMaterials_Product_ComponentID: ComponentID relies upon remote PK_Product_ProductID (Production.Product)
FK_BillOfMaterials_UnitMeasure_UnitMeasureCode: UnitMeasureCode relies upon remote PK_UnitMeasure_UnitMeasureCode (Production.UnitMeasure)
Indexes
| AK_BillOfMaterials_ProductAssemblyID_ComponentID_StartDate | ProductAssemblyID | ASC | Yes | CLUSTERED |
| ComponentID | ASC | Yes | CLUSTERED |
| StartDate | ASC | Yes | CLUSTERED |
| IX_BillOfMaterials_UnitMeasureCode | UnitMeasureCode | ASC | | NONCLUSTERED |
| PK_BillOfMaterials_BillOfMaterialsID | BillOfMaterialsID | ASC | Yes | NONCLUSTERED |
Check constraints
| CK_BillOfMaterials_EndDate | StartDate | ([EndDate]>[StartDate] OR [EndDate] IS NULL) |
| CK_BillOfMaterials_EndDate | EndDate | ([EndDate]>[StartDate] OR [EndDate] IS NULL) |
| CK_BillOfMaterials_ProductAssemblyID | ProductAssemblyID | ([ProductAssemblyID]<>[ComponentID]) |
| CK_BillOfMaterials_ProductAssemblyID | ComponentID | ([ProductAssemblyID]<>[ComponentID]) |
| CK_BillOfMaterials_BOMLevel | ProductAssemblyID | ([ProductAssemblyID] IS NULL AND [BOMLevel]=(0) AND [PerAssemblyQty]=(1.00) OR [ProductAssemblyID] IS NOT NULL AND [BOMLevel]>=(1)) |
| CK_BillOfMaterials_BOMLevel | BOMLevel | ([ProductAssemblyID] IS NULL AND [BOMLevel]=(0) AND [PerAssemblyQty]=(1.00) OR [ProductAssemblyID] IS NOT NULL AND [BOMLevel]>=(1)) |
| CK_BillOfMaterials_BOMLevel | PerAssemblyQty | ([ProductAssemblyID] IS NULL AND [BOMLevel]=(0) AND [PerAssemblyQty]=(1.00) OR [ProductAssemblyID] IS NOT NULL AND [BOMLevel]>=(1)) |
| CK_BillOfMaterials_PerAssemblyQty | PerAssemblyQty | ([PerAssemblyQty]>=(1.00)) |
Objects that depend on Production.BillOfMaterials (demo version, please register):
dbo.uspGetBillOfMaterials
dbo.uspGetWhereUsedProductID
Table definition
CREATE TABLE [Production.BillOfMaterials] (
[BillOfMaterialsID] [int] IDENTITY (1, 1) NOT NULL ,
[ProductAssemblyID] [int] NULL ,
[ComponentID] [int] NOT NULL ,
[StartDate] [datetime] NOT NULL CONSTRAINT [DF_BillOfMaterials_StartDate] DEFAULT (getdate()),
[EndDate] [datetime] NULL ,
[UnitMeasureCode] [nchar] (3) COLLATE Latin1_General_CS_AS NOT NULL ,
[BOMLevel] [smallint] NOT NULL ,
[PerAssemblyQty] [decimal](8, 2) NOT NULL CONSTRAINT [DF_BillOfMaterials_PerAssemblyQty] DEFAULT ((1.00)),
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_BillOfMaterials_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_BillOfMaterials_BillOfMaterialsID] PRIMARY KEY NONCLUSTERED
(
[BillOfMaterialsID]
) ON [PRIMARY] ,
CONSTRAINT [FK_BillOfMaterials_Product_ComponentID] FOREIGN KEY
(
[ComponentID]
) REFERENCES [Product] (
[ProductID]
),
CONSTRAINT [FK_BillOfMaterials_Product_ProductAssemblyID] FOREIGN KEY
(
[ProductAssemblyID]
) REFERENCES [Product] (
[ProductID]
),
CONSTRAINT [FK_BillOfMaterials_UnitMeasure_UnitMeasureCode] FOREIGN KEY
(
[UnitMeasureCode]
) REFERENCES [UnitMeasure] (
[UnitMeasureCode]
),
CONSTRAINT [CK_BillOfMaterials_BOMLevel] CHECK ([ProductAssemblyID] IS NULL AND [BOMLevel]=(0) AND [PerAssemblyQty]=(1.00) OR [ProductAssemblyID] IS NOT NULL AND [BOMLevel]>=(1)),
CONSTRAINT [CK_BillOfMaterials_EndDate] CHECK ([EndDate]>[StartDate] OR [EndDate] IS NULL),
CONSTRAINT [CK_BillOfMaterials_PerAssemblyQty] CHECK ([PerAssemblyQty]>=(1.00)),
CONSTRAINT [CK_BillOfMaterials_ProductAssemblyID] CHECK ([ProductAssemblyID]<>[ComponentID])
) ON [PRIMARY]
GO
(up)
Table: Production.Culture (demo version, please register)
Lookup table containing the languages in which some AdventureWorks data is stored.
|
PK | CultureID | nchar
(6)
| | | Primary key for Culture records. |
| IX | Name | Name | | | Culture description. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Indexes
| AK_Culture_Name | Name | ASC | Yes | NONCLUSTERED |
| PK_Culture_CultureID | CultureID | ASC | Yes | CLUSTERED |
Table definition
CREATE TABLE [Production.Culture] (
[CultureID] [nchar] (6) COLLATE Latin1_General_CS_AS NOT NULL ,
[Name] [Name] NOT NULL ,
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_Culture_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_Culture_CultureID] PRIMARY KEY CLUSTERED
(
[CultureID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
(up)
Table: Production.Document (demo version, please register)
Product maintenance documents.
|
PK | DocumentID | int | | | Primary key for Document records. |
| Title | nvarchar
(50)
| | | Title of the document. |
| IX | FileName | nvarchar
(400)
| | | Directory path and file name of the document |
| FileExtension | nvarchar
(8)
| | | File extension indicating the document type. For example, .doc or .txt. |
| IX | Revision | nchar
(5)
| | | Revision number of the document. |
| ChangeNumber | int | | ((0)) | Engineering change approval number. |
| Status | tinyint | | | 1 = Pending approval, 2 = Approved, 3 = Obsolete |
| DocumentSummary | nvarchar | Yes | | Document abstract. |
| Document | varbinary | Yes | | Complete document. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Indexes
| AK_Document_FileName_Revision | FileName | ASC | Yes | NONCLUSTERED |
| Revision | ASC | Yes | NONCLUSTERED |
| PK_Document_DocumentID | DocumentID | ASC | Yes | CLUSTERED |
Check constraints
| CK_Document_Status | Status | ([Status]>=(1) AND [Status]<=(3)) |
Table definition
CREATE TABLE [Production.Document] (
[DocumentID] [int] IDENTITY (1, 1) NOT NULL ,
[Title] [nvarchar] (50) COLLATE Latin1_General_CS_AS NOT NULL ,
[FileName] [nvarchar] (400) COLLATE Latin1_General_CS_AS NOT NULL ,
[FileExtension] [nvarchar] (8) COLLATE Latin1_General_CS_AS NOT NULL ,
[Revision] [nchar] (5) COLLATE Latin1_General_CS_AS NOT NULL ,
[ChangeNumber] [int] NOT NULL CONSTRAINT [DF_Document_ChangeNumber] DEFAULT ((0)),
[Status] [tinyint] NOT NULL ,
[DocumentSummary] [nvarchar] (0) COLLATE Latin1_General_CS_AS NULL ,
[Document] [varbinary] (-1) NULL ,
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_Document_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_Document_DocumentID] PRIMARY KEY CLUSTERED
(
[DocumentID]
) ON [PRIMARY] ,
CONSTRAINT [CK_Document_Status] CHECK ([Status]>=(1) AND [Status]<=(3))
) ON [PRIMARY]
GO
(up)
Table: Production.Illustration (demo version, please register)
Bicycle assembly diagrams.
|
PK | IllustrationID | int | | | Primary key for Illustration records. |
| Diagram | xml | Yes | | Illustrations used in manufacturing instructions. Stored as XML. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Indexes
| PK_Illustration_IllustrationID | IllustrationID | ASC | Yes | CLUSTERED |
Table definition
CREATE TABLE [Production.Illustration] (
[IllustrationID] [int] IDENTITY (1, 1) NOT NULL ,
[Diagram] [xml] NULL ,
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_Illustration_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_Illustration_IllustrationID] PRIMARY KEY CLUSTERED
(
[IllustrationID]
) ON [PRIMARY]
) ON [PRIMARY]
GO
(up)
Table: Production.Location (demo version, please register)
Product inventory and manufacturing locations.
|
PK | LocationID | smallint | | | Primary key for Location records. |
| IX | Name | Name | | | Location description. |
| CostRate | smallmoney | | ((0.00)) | Standard hourly cost of the manufacturing location. |
| Availability | decimal
(8.2)
| | ((0.00)) | Work capacity (in hours) of the manufacturing location. |
| ModifiedDate | datetime | | (getdate()) | Date and time the record was last updated. |
Indexes
| AK_Location_Name | Name | ASC | Yes | NONCLUSTERED |
| PK_Location_LocationID | LocationID | ASC | Yes | CLUSTERED |
Check constraints
| CK_Location_CostRate | CostRate | ([CostRate]>=(0.00)) |
| CK_Location_Availability | Availability | ([Availability]>=(0.00)) |
Table definition
CREATE TABLE [Production.Location] (
[LocationID] [smallint] IDENTITY (1, 1) NOT NULL ,
[Name] [Name] NOT NULL ,
[CostRate] [smallmoney] NOT NULL CONSTRAINT [DF_Location_CostRate] DEFAULT ((0.00)),
[Availability] [decimal](8, 2) NOT NULL CONSTRAINT [DF_Location_Availability] DEFAULT ((0.00)),
[ModifiedDate] [datetime] NOT NULL CONSTRAINT [DF_Location_ModifiedDate] DEFAULT (getdate()),
CONSTRAINT [PK_Location_LocationID] PRIMARY KEY CLUSTERED
(
[LocationID]
) ON [PRIMARY] ,
CONSTRAINT [CK_Location_Availability] CHECK ([Availability]>=(0.00)),
CONSTRAINT [CK_Location_CostRate] CHECK ([CostRate]>=(0.00))
) ON [PRIMARY]
GO
(up)
Table: Production.Product (demo version, please register)
Products sold or used in the manfacturing of sold products.
|
PK | ProductID | int | | | Primary key for Product records. |
| IX | Name | Name | | | Name of the product. |
| IX | ProductNumber | nvarchar
(25)
| | | Unique product identification number. |
| MakeFlag | Flag | | ((1)) | 0 = Product is purchased, 1 = Product is manufactured in-house. |
| FinishedGoodsFlag | Flag | | ((1)) | 0 = Product is not a salable item. 1 = Product is salable. |
| Color | nvarchar
(15)
| Yes | | Product color. |
| SafetyStockLevel | smallint | | | Minimum inventory quantity. |
| ReorderPoint | smallint | | | Inventory level that triggers a purchase order or work order. |
| StandardCost | money | | | Standard cost of the product. |
| ListPrice | money | | | Selling price. |
| Size | nvarchar
(5)
| Yes | | Product size. |
| FK | SizeUnitMeasureCode | nchar
(3)
| Yes | | Unit of measure for Size column. |
| FK | WeightUnitMeasureCode | nchar
(3)
| Yes | | Unit of measure for Weight column. |
| Weight | decimal
(8.2)
| Yes | | Product weight. |
| DaysToManufacture | int | | | Number of days required to manufacture the product. |
| ProductLine | nchar
(2)
| Yes | | R = Road, M = Mountain, T = Touring, S = Standard |
| Class | nchar
(2)
| Yes | | H = High, M = Medium, L = Low |
| Style | nchar
(2)
| Yes | | W = Womens, M = Mens, U = Universal |