AdventureWorks
HumanResources.Employee Table
Description
Employee information such as salary, department, and title.
Properties
Creation Date08/01/2010 08:40
File GroupPRIMARY
Text File Group
System Object
Published for Replication
Rows290
Data Space Used56.00 KB
Index Space Used120.00 KB
Columns
 Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
Primary Key EmployeeIDPrimary key for Employee records.int4   
 NationalIDNumberUnique national identification number such as a social security number.nvarchar15   
 ContactIDIdentifies the employee in the Contact table. Foreign key to Contact.ContactID.int4   
 LoginIDNetwork login.nvarchar256   
 ManagerIDManager to whom the employee is assigned. Foreign Key to Employee.Mint4  
 TitleWork title such as Buyer or Sales Representative.nvarchar50   
 BirthDateDate of birth.datetime4   
 MaritalStatusM = Married, S = Singlenchar1   
 GenderM = Male, F = Femalenchar1   
 HireDateEmployee hired on this date.datetime4   
 SalariedFlagJob classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining.dbo.Flag1 
((1))
 
 VacationHoursNumber of available vacation hours.smallint2 
((0))
 
 SickLeaveHoursNumber of available sick leave hours.smallint2 
((0))
 
 CurrentFlag0 = Inactive, 1 = Activedbo.Flag1 
((1))
 
 rowguidROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.uniqueidentifier16 
(newid())
 
 ModifiedDateDate and time the record was last updated.datetime4 
(getdate())
 
Indexes
IndexDescriptionPrimaryUnique
AK_Employee_LoginIDUnique nonclustered index. 
AK_Employee_NationalIDNumberUnique nonclustered index. 
AK_Employee_rowguidUnique nonclustered index. Used to support replication samples. 
IX_Employee_ManagerIDNonclustered index.  
PK_Employee_EmployeeIDPrimary key (clustered) constraint
Check Constraints
NameDescriptionExpression
CK_Employee_BirthDateCheck constraint [BirthDate] >= '1930-01-01' AND [BirthDate] <= dateadd(year,(-18),GETDATE())
([BirthDate]>='1930-01-01' AND [BirthDate]<=dateadd(year,(-18),getdate()))
CK_Employee_GenderCheck constraint [Gender]='f' OR [Gender]='m' OR [Gender]='F' OR [Gender]='M'
(upper([Gender])='F' OR upper([Gender])='M')
CK_Employee_HireDateCheck constraint [HireDate] >= '1996-07-01' AND [HireDate] <= dateadd(day,(1),GETDATE())
([HireDate]>='1996-07-01' AND [HireDate]<=dateadd(day,(1),getdate()))
CK_Employee_MaritalStatusCheck constraint [MaritalStatus]='s' OR [MaritalStatus]='m' OR [MaritalStatus]='S' OR [MaritalStatus]='M'
(upper([MaritalStatus])='S' OR upper([MaritalStatus])='M')
CK_Employee_SickLeaveHoursCheck constraint [SickLeaveHours] >= (0) AND [SickLeaveHours] <= (120)
([SickLeaveHours]>=(0) AND [SickLeaveHours]<=(120))
CK_Employee_VacationHoursCheck constraint [VacationHours] >= (-40) AND [VacationHours] <= (240)
([VacationHours]>=(-40) AND [VacationHours]<=(240))
Triggers
TriggerDescription
dEmployeeINSTEAD OF DELETE trigger which keeps Employees from being deleted.
Relationships
RelationshipDescription
FK_Employee_Contact_ContactIDForeign key constraint referencing Contact.ContactID.
FK_Employee_Employee_ManagerIDForeign key constraint referencing Employee.ManagerID.
FK_EmployeeAddress_Employee_EmployeeIDForeign key constraint referencing Employee.EmployeeID.
FK_EmployeeDepartmentHistory_Employee_EmployeeIDForeign key constraint referencing Employee.EmployeeID.
FK_EmployeePayHistory_Employee_EmployeeIDForeign key constraint referencing Employee.EmployeeID.
FK_JobCandidate_Employee_EmployeeIDForeign key constraint referencing Employee.EmployeeID.
FK_PurchaseOrderHeader_Employee_EmployeeIDForeign key constraint referencing Employee.EmployeeID.
FK_SalesPerson_Employee_SalesPersonIDForeign key constraint referencing Employee.EmployeeID.
Objects that depend on HumanResources.Employee
 Database ObjectObject TypeDescriptionDep Level
dEmployee triggerdEmployeeTriggerINSTEAD OF DELETE trigger which keeps Employees from being deleted.1
HumanResources.EmployeeAddress tableHumanResources.EmployeeAddressTableCross-reference table mapping employees to their address(es).1
HumanResources.EmployeeDepartmentHistory tableHumanResources.EmployeeDepartmentHistoryTableEmployee department transfers.1
HumanResources.EmployeePayHistory tableHumanResources.EmployeePayHistoryTableEmployee pay history.1
iduSalesOrderDetail triggeriduSalesOrderDetailTriggerAFTER INSERT, DELETE, UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in SalesOrderDetail and updates the SalesOrderHeader.SubTotal column.4
Sales.Individual tableSales.IndividualTableDemographic data about customers that purchase Adventure Works products online.3
iPurchaseOrderDetail triggeriPurchaseOrderDetailTriggerAFTER INSERT trigger that inserts a row in the TransactionHistory table and updates the PurchaseOrderHeader.SubTotal column.3
iStore triggeriStoreTriggerAFTER INSERT trigger inserting Store only if the Customer does not exist in the Individual table.3
iuIndividual triggeriuIndividualTriggerAFTER INSERT, UPDATE trigger inserting Individual only if the Customer does not exist in the Store table and setting the ModifiedDate column in the Individual table to the current date.4
HumanResources.JobCandidate tableHumanResources.JobCandidateTableRésumés submitted to Human Resources by job applicants.1
Purchasing.PurchaseOrderDetail tablePurchasing.PurchaseOrderDetailTableIndividual products associated with a specific purchase order. See PurchaseOrderHeader.2
Purchasing.PurchaseOrderHeader tablePurchasing.PurchaseOrderHeaderTableGeneral purchase order information. See PurchaseOrderDetail.1
Sales.SalesOrderDetail tableSales.SalesOrderDetailTableIndividual products associated with a specific sales order. See SalesOrderHeader.3
Sales.SalesOrderHeader tableSales.SalesOrderHeaderTableGeneral sales order information.2
Sales.SalesOrderHeaderSalesReason tableSales.SalesOrderHeaderSalesReasonTableCross-reference table mapping sales orders to sales reason codes.3
Sales.SalesPerson tableSales.SalesPersonTableSales representative current information.1
Sales.SalesPersonQuotaHistory tableSales.SalesPersonQuotaHistoryTableSales performance tracking.2
Sales.SalesTerritoryHistory tableSales.SalesTerritoryHistoryTableSales representative transfers to other sales territories.2
Sales.Store tableSales.StoreTableCustomers (resellers) of Adventure Works products.2
Sales.StoreContact tableSales.StoreContactTableCross-reference table mapping stores and their employees.3
dbo.ufnGetContactInformation functiondbo.ufnGetContactInformationUser Defined FunctionTable value function returning the first name, last name, job title and contact type for a given contact.1
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
uSalesOrderHeader triggeruSalesOrderHeaderTriggerAFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the SalesOrderHeader table.Updates the SalesYTD column in the SalesPerson and SalesTerritory tables.3
dbo.uspGetEmployeeManagers proceduredbo.uspGetEmployeeManagersStored ProcedureStored procedure using a recursive query to return the direct and indirect managers of the specified employee.1
dbo.uspGetManagerEmployees proceduredbo.uspGetManagerEmployeesStored ProcedureStored procedure using a recursive query to return the direct and indirect employees of the specified manager.1
HumanResources.uspUpdateEmployeeHireInfo procedureHumanResources.uspUpdateEmployeeHireInfoStored ProcedureUpdates the Employee table and inserts a new row in the EmployeePayHistory table with the values specified in the input parameters.1
HumanResources.uspUpdateEmployeeLogin procedureHumanResources.uspUpdateEmployeeLoginStored ProcedureUpdates the Employee table with the values specified in the input parameters for the given EmployeeID.1
HumanResources.uspUpdateEmployeePersonalInfo procedureHumanResources.uspUpdateEmployeePersonalInfoStored ProcedureUpdates the Employee table with the values specified in the input parameters for the given EmployeeID.1
HumanResources.vEmployee viewHumanResources.vEmployeeViewEmployee names and addresses.1
HumanResources.vEmployeeDepartment viewHumanResources.vEmployeeDepartmentViewReturns employee name, title, and current department.1
HumanResources.vEmployeeDepartmentHistory viewHumanResources.vEmployeeDepartmentHistoryViewReturns employee name and current and previous departments.1
Sales.vIndividualCustomer viewSales.vIndividualCustomerViewIndividual customers (names and addresses) that purchase Adventure Works Cycles products online.4
Sales.vIndividualDemographics viewSales.vIndividualDemographicsViewDisplays the content from each element in the xml column Demographics for each customer in the Sales.Individual table.4
HumanResources.vJobCandidate viewHumanResources.vJobCandidateViewJob candidate names and resumes.2
HumanResources.vJobCandidateEducation viewHumanResources.vJobCandidateEducationViewDisplays the content from each education related element in the xml column Resume in the HumanResources.JobCandidate table. The content has been localized into French, Simplified Chinese and Thai. Some data may not display correctly unless supplemental language support is installed.2
HumanResources.vJobCandidateEmployment viewHumanResources.vJobCandidateEmploymentViewDisplays the content from each employement history related element in the xml column Resume in the HumanResources.JobCandidate table. The content has been localized into French, Simplified Chinese and Thai. Some data may not display correctly unless supplemental language support is installed.2
Sales.vSalesPerson viewSales.vSalesPersonViewSales representiatives (names and addresses) and their sales-related information.1
Sales.vSalesPersonSalesByFiscalYears viewSales.vSalesPersonSalesByFiscalYearsViewUses PIVOT to return aggregated sales information for each sales representative.1
Sales.vStoreWithDemographics viewSales.vStoreWithDemographicsViewStores (names and addresses) that sell Adventure Works Cycles products to consumers.3
Objects that HumanResources.Employee depends on
 Database ObjectObject TypeDescriptionDep Level
Person.Contact tablePerson.ContactTableNames of each employee, customer contact, and vendor contact.1
dbo.Flag datatypedbo.FlagUser Defined Data Type 1
dbo.Name datatypedbo.NameUser Defined Data Type 2
dbo.NameStyle datatypedbo.NameStyleUser Defined Data Type 2
dbo.Phone datatypedbo.PhoneUser Defined Data Type 2
SQL
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
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,
	[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 [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 [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]
See Also

Related Objects

HumanResources Schema
AdventureWorks Database

 

 


© 2012 All Rights Reserved.

Send comments on this topic.