Database reference - AdventureWorks

AdventureWorks -  tables -  [HumanResources].[Employee]

Description

Employee information such as salary, department, and title. 

Table properties

namevalue
name[HumanResources].[Employee]
createdMar 19 2009 9:08PM
modifiedMar 19 2009 9:08PM 
ansi nullson 
quoted identifieron 
row count290
Size of data56 kb
Size of indexes120 kb
Maximum size of a single row1,348 bytes

Columns

columndatatypelengthbytesdefaultnullsPKFKUQcomputedcomment
EmployeeIDint identity(1,1)104 no  yes    no  Primary key for Employee records. 
NationalIDNumbernvarchar(15)1560 no      no  Unique national identification number such as a social security number. 
ContactIDint104 no    Contact.ContactID      no  Identifies the employee in the Contact table. Foreign key to Contact.ContactID. 
LoginIDnvarchar(256)2561024 no      no  Network login. 
ManagerIDint104 yes    Employee.EmployeeID      no  Manager to whom the employee is assigned. Foreign Key to Employee.M 
Titlenvarchar(50)50200 no      no  Work title such as Buyer or Sales Representative. 
BirthDatedatetime238 no      no  Date of birth. 
MaritalStatusnchar(1)14 no      no  M = Married, S = Single 
Gendernchar(1)14 no      no  M = Male, F = Female 
HireDatedatetime238 no      no  Employee hired on this date. 
SalariedFlagFlag10((1))no      no  Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining. 
VacationHourssmallint52((0))no      no  Number of available vacation hours. 
SickLeaveHourssmallint52((0))no      no  Number of available sick leave hours. 
CurrentFlagFlag10((1))no      no  0 = Inactive, 1 = Active 
rowguiduniqueidentifier3616(newid())no      no  ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. 
ModifiedDatedatetime238(getdate())no      no  Date and time the record was last updated. 

Indexes

namedescriptioncolumncomment
AK_Employee_LoginIDnonclustered, unique located on PRIMARYLoginIDUnique nonclustered index. 
AK_Employee_NationalIDNumbernonclustered, unique located on PRIMARYNationalIDNumberUnique nonclustered index. 
AK_Employee_rowguidnonclustered, unique located on PRIMARYrowguidUnique nonclustered index. Used to support replication samples. 
IX_Employee_ManagerIDnonclustered located on PRIMARYManagerIDNonclustered index. 
PK_Employee_EmployeeIDclustered, unique, primary key located on PRIMARYEmployeeIDClustered index created by a primary key constraint. 

References

name
Employee
Contact

Referenced by

name
Employee
EmployeeAddress
EmployeeDepartmentHistory
EmployeePayHistory
JobCandidate
PurchaseOrderHeader
SalesPerson

Foreign key graph

EmployeeContactEmployeeEmployeeEmployeeAddressEmployeeDepartmentHistoryEmployeePayHistoryJobCandidatePurchaseOrderHeaderSalesPerson

Foreign keys

namecolumnsforeign columnstypecomment
FK_Employee_Contact_ContactIDContactIDContact.ContactID   Foreign key constraint referencing Contact.ContactID. 
FK_Employee_Employee_ManagerIDManagerIDEmployee.EmployeeID   Foreign key constraint referencing Employee.ManagerID. 

Check constraints

namecolumncomment
CK_Employee_BirthDateBirthDate    Check constraint [BirthDate] >= '1930-01-01' AND [BirthDate] <= dateadd(year,(-18),GETDATE()) 
CK_Employee_MaritalStatusMaritalStatus    Check constraint [MaritalStatus]='s' OR [MaritalStatus]='m' OR [MaritalStatus]='S' OR [MaritalStatus]='M' 
CK_Employee_HireDateHireDate    Check constraint [HireDate] >= '1996-07-01' AND [HireDate] <= dateadd(day,(1),GETDATE()) 
CK_Employee_GenderGender    Check constraint [Gender]='f' OR [Gender]='m' OR [Gender]='F' OR [Gender]='M' 
CK_Employee_VacationHoursVacationHours    Check constraint [VacationHours] >= (-40) AND [VacationHours] <= (240) 
CK_Employee_SickLeaveHoursSickLeaveHours    Check constraint [SickLeaveHours] >= (0) AND [SickLeaveHours] <= (120) 

Triggers

namecomment
dEmployeeINSTEAD OF DELETE trigger which keeps Employees from being deleted. 

Defaults

default namecolumncomment
DF_Employee_SalariedFlagSalariedFlagDefault constraint value of 1 (TRUE) 
DF_Employee_VacationHoursVacationHoursDefault constraint value of 0 
DF_Employee_SickLeaveHoursSickLeaveHoursDefault constraint value of 0 
DF_Employee_CurrentFlagCurrentFlagDefault constraint value of 1 
DF_Employee_rowguidrowguidDefault constraint value of NEWID() 
DF_Employee_ModifiedDateModifiedDateDefault constraint value of GETDATE() 

Dependency graph

Objects that [HumanResources].[Employee] depends on

nameobject typelevel
Flagtype1

Objects that depend on [HumanResources].[Employee]

nameobject typelevel
uspGetEmployeeManagersstored procedure1
uspGetManagerEmployeesstored procedure1
uspUpdateEmployeeHireInfostored procedure1
uspUpdateEmployeeLoginstored procedure1
uspUpdateEmployeePersonalInfostored procedure1
ufnGetContactInformationmulti-statement table valued function1
dEmployeetrigger1
vEmployeeview1
vEmployeeDepartmentview1
vEmployeeDepartmentHistoryview1
vSalesPersonview1
vSalesPersonSalesByFiscalYearsview1

Sample rows

EmployeeIDNationalIDNumberContactIDLoginIDManagerIDTitleBirthDateMaritalStatusGenderHireDateSalariedFlagVacationHoursSickLeaveHoursCurrentFlagrowguidModifiedDate
14417807  1209  adventure-works\guy1  16  Production Technician - WC60  5/15/1972 12:00:00 AM  7/31/1996 12:00:00 AM  False  21  30  True  aae1d04a-c237-4974-b4d5-935247737718  7/31/2004 12:00:00 AM 
253022876  1030  adventure-works\kevin0  Marketing Assistant  6/3/1977 12:00:00 AM  2/26/1997 12:00:00 AM  False  42  41  True  1b480240-95c0-410f-a717-eb29943c8886  7/31/2004 12:00:00 AM 
509647174  1002  adventure-works\roberto0  12  Engineering Manager  12/13/1964 12:00:00 AM  12/12/1997 12:00:00 AM  True  21  True  9bbbfb2c-efbb-4217-9ab7-f97689328841  7/31/2004 12:00:00 AM 
112457891  1290  adventure-works\rob0  Senior Tool Designer  1/23/1965 12:00:00 AM  1/5/1998 12:00:00 AM  False  48  80  True  59747955-87b8-443f-8ed4-f8ad3afdf3a9  7/31/2004 12:00:00 AM 
480168528  1009  adventure-works\thierry0  263  Tool Designer  8/29/1949 12:00:00 AM  1/11/1998 12:00:00 AM  False  24  True  1d955171-e773-4fad-8382-40fd898d5d4d  7/31/2004 12:00:00 AM 
24756624  1028  adventure-works\david0  109  Marketing Manager  4/19/1965 12:00:00 AM  1/20/1998 12:00:00 AM  True  40  40  True  e87029aa-2cba-4c03-b948-d83af0313e28  7/31/2004 12:00:00 AM 
309738752  1070  adventure-works\jolynn0  21  Production Supervisor - WC60  2/16/1946 12:00:00 AM  1/26/1998 12:00:00 AM  False  82  61  True  2cc71b96-f421-485e-9832-8723337749bb  7/31/2004 12:00:00 AM 
690627818  1071  adventure-works\ruth0  185  Production Technician - WC10  7/6/1946 12:00:00 AM  2/6/1998 12:00:00 AM  False  83  61  True  3e3b6905-209e-442e-b8a8-9a0980241c6a  7/31/2004 12:00:00 AM 
695256908  1005  adventure-works\gail0  Design Engineer  10/29/1942 12:00:00 AM  2/6/1998 12:00:00 AM  True  22  True  ec84ae09-f9b8-4a15-b4a9-6ccbab919b08  7/31/2004 12:00:00 AM 
10  912265825  1076  adventure-works\barry0  185  Production Technician - WC10  4/27/1946 12:00:00 AM  2/7/1998 12:00:00 AM  False  88  64  True  756a60ae-378f-43d8-9f93-1e821d1eaf52  7/31/2004 12:00:00 AM 

Code

CREATE TABLE [HumanResources].[Employee](
    [EmployeeID] [int] IDENTITY(1,1) NOT NULL,
    [NationalIDNumber] [nvarchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [ContactID] [int] NOT NULL,
    [LoginID] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [EmployeeID] [int] IDENTITY(1,1) NOT NULL,
    [NationalIDNumber] [nvarchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [ContactID] [int] NOT NULL,
    [ManagerID] [int] NULL,
    [Title] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [BirthDate] [datetime] NOT NULL,
    [MaritalStatus] [nchar](1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [Gender] [nchar](1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
    [HireDate] [datetime] NOT NULL,
    [SalariedFlag] [dbo].[Flag] NOT NULL,
    [VacationHours] [smallint] NOT NULL,
    [SickLeaveHours] [smallint] NOT NULL,
    [CurrentFlag] [dbo].[Flag] NOT NULL,
    [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
    [ModifiedDate] [datetime] NOT NULL,
 CONSTRAINT [PK_Employee_EmployeeID] PRIMARY KEY CLUSTERED 
(
    [EmployeeID] 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 [HumanResources].[Employee]  WITH CHECK ADD  CONSTRAINT [FK_Employee_Contact_ContactID] FOREIGN KEY([ContactID])
REFERENCES [Person].[Contact] ([ContactID])
ALTER TABLE [HumanResources].[Employee] CHECK CONSTRAINT [FK_Employee_Contact_ContactID]
ALTER TABLE [HumanResources].[Employee]  WITH CHECK ADD  CONSTRAINT [FK_Employee_Employee_ManagerID] FOREIGN KEY([ManagerID])
REFERENCES [HumanResources].[Employee] ([EmployeeID])
ALTER TABLE [HumanResources].[Employee] CHECK CONSTRAINT [FK_Employee_Employee_ManagerID]
ALTER TABLE [HumanResources].[Employee]  WITH CHECK ADD  CONSTRAINT [CK_Employee_BirthDate] CHECK  (([BirthDate]>='1930-01-01' AND [BirthDate]<=dateadd(year,(-18),getdate())))
ALTER TABLE [HumanResources].[Employee] CHECK CONSTRAINT [CK_Employee_BirthDate]
ALTER TABLE [HumanResources].[Employee]  WITH CHECK ADD  CONSTRAINT [CK_Employee_Gender] CHECK  ((upper([Gender])='F' OR upper([Gender])='M'))
ALTER TABLE [HumanResources].[Employee] CHECK CONSTRAINT [CK_Employee_Gender]
ALTER TABLE [HumanResources].[Employee]  WITH CHECK ADD  CONSTRAINT [CK_Employee_HireDate] CHECK  (([HireDate]>='1996-07-01' AND [HireDate]<=dateadd(day,(1),getdate())))
ALTER TABLE [HumanResources].[Employee] CHECK CONSTRAINT [CK_Employee_HireDate]
ALTER TABLE [HumanResources].[Employee]  WITH CHECK ADD  CONSTRAINT [CK_Employee_MaritalStatus] CHECK  ((upper([MaritalStatus])='S' OR upper([MaritalStatus])='M'))
ALTER TABLE [HumanResources].[Employee] CHECK CONSTRAINT [CK_Employee_MaritalStatus]
ALTER TABLE [HumanResources].[Employee]  WITH CHECK ADD  CONSTRAINT [CK_Employee_SickLeaveHours] CHECK  (([SickLeaveHours]>=(0) AND [SickLeaveHours]<=(120)))
ALTER TABLE [HumanResources].[Employee] CHECK CONSTRAINT [CK_Employee_SickLeaveHours]
ALTER TABLE [HumanResources].[Employee]  WITH CHECK ADD  CONSTRAINT [CK_Employee_VacationHours] CHECK  (([VacationHours]>=(-40) AND [VacationHours]<=(240)))
ALTER TABLE [HumanResources].[Employee] CHECK CONSTRAINT [CK_Employee_VacationHours]
ALTER TABLE [HumanResources].[Employee] ADD  CONSTRAINT [DF_Employee_SalariedFlag]  DEFAULT ((1)) FOR [SalariedFlag]
ALTER TABLE [HumanResources].[Employee] ADD  CONSTRAINT [DF_Employee_VacationHours]  DEFAULT ((0)) FOR [VacationHours]
ALTER TABLE [HumanResources].[Employee] ADD  CONSTRAINT [DF_Employee_SickLeaveHours]  DEFAULT ((0)) FOR [SickLeaveHours]
ALTER TABLE [HumanResources].[Employee] ADD  CONSTRAINT [DF_Employee_CurrentFlag]  DEFAULT ((1)) FOR [CurrentFlag]
ALTER TABLE [HumanResources].[Employee] ADD  CONSTRAINT [DF_Employee_rowguid]  DEFAULT (newid()) FOR [rowguid]
ALTER TABLE [HumanResources].[Employee] ADD  CONSTRAINT [DF_Employee_ModifiedDate]  DEFAULT (getdate()) FOR [ModifiedDate]

Powered by Yoyodyne © 1971