Northwind Database (Document! X Sample)
AdventureWorks Database / HumanResources Schema / HumanResources.Employee Table
In This Topic
    HumanResources.Employee Table
    In This Topic
    Description
    Employee information such as salary, department, and title.
    Properties
    Creation Date27/10/2017 14:33
    File GroupPRIMARY
    Text File Group
    System Object
    Published for Replication
    Rows290
    Data Space Used56.00 KB
    Index Space Used136.00 KB
    Columns
     Column NameDescriptionDatatypeLengthAllow NullsDefaultFormula
    Primary Key Primary key for Employee records. Foreign key to BusinessEntity.BusinessEntityID.Integer4   
     Unique national identification number such as a social security number.VarWChar15   
     Network login.VarWChar256   
     Where the employee is located in corporate hierarchy.UserDefined892  
     The depth of the employee in the corporate hierarchy.SmallInt2 
    ([OrganizationNode].[GetLevel]())
     Work title such as Buyer or Sales Representative.VarWChar50   
     Date of birth.DBDate8   
     M = Married, S = SingleWChar1   
     M = Male, F = FemaleWChar1   
     Employee hired on this date.DBDate8   
     Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining.dbo.Flag1 
    ((1))
     
     Number of available vacation hours.SmallInt2 
    ((0))
     
     Number of available sick leave hours.SmallInt2 
    ((0))
     
     0 = Inactive, 1 = Activedbo.Flag1 
    ((1))
     
     ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.GUID16 
    (newid())
     
     Date and time the record was last updated.DBTimeStamp4 
    (getdate())
     
    Indexes
    IndexDescriptionPrimaryUnique
    Unique nonclustered index. 
    Unique nonclustered index. 
    Unique nonclustered index. Used to support replication samples. 
    Unique nonclustered index.  
    Unique nonclustered index.  
    Primary key (clustered) constraint
    Check Constraints
    NameDescriptionExpression
    Check constraint [BirthDate] >= '1930-01-01' AND [BirthDate] <= dateadd(year,(-18),GETDATE())
    ([BirthDate]>='1930-01-01' AND [BirthDate]<=dateadd(year,(-18),getdate()))
    Check constraint [Gender]='f' OR [Gender]='m' OR [Gender]='F' OR [Gender]='M'
    (upper([Gender])='F' OR upper([Gender])='M')
    Check constraint [HireDate] >= '1996-07-01' AND [HireDate] <= dateadd(day,(1),GETDATE())
    ([HireDate]>='1996-07-01' AND [HireDate]<=dateadd(day,(1),getdate()))
    Check constraint [MaritalStatus]='s' OR [MaritalStatus]='m' OR [MaritalStatus]='S' OR [MaritalStatus]='M'
    (upper([MaritalStatus])='S' OR upper([MaritalStatus])='M')
    Check constraint [SickLeaveHours] >= (0) AND [SickLeaveHours] <= (120)
    ([SickLeaveHours]>=(0) AND [SickLeaveHours]<=(120))
    Check constraint [VacationHours] >= (-40) AND [VacationHours] <= (240)
    ([VacationHours]>=(-40) AND [VacationHours]<=(240))
    Triggers
    TriggerDescription
    INSTEAD OF DELETE trigger which keeps Employees from being deleted.
    Relationships
    RelationshipDescription
    Foreign key constraint referencing Employee.BusinessEntityID.
    Foreign key constraint referencing Person.BusinessEntityID.
    Foreign key constraint referencing Employee.EmployeeID.
    Foreign key constraint referencing Employee.EmployeeID.
    Foreign key constraint referencing Employee.EmployeeID.
    Foreign key constraint referencing Employee.EmployeeID.
    Foreign key constraint referencing Employee.EmployeeID.
    Objects that depend on HumanResources.Employee
     Database ObjectObject TypeDescriptionDep Level
    Sales.Customer tableSales.CustomerTableCurrent customer information. Also see the Person and Store tables.2
    dEmployee triggerdEmployeeTriggerINSTEAD OF DELETE trigger which keeps Employees from being deleted.2
    Production.Document tableProduction.DocumentTableProduct maintenance documents.1
    HumanResources.EmployeeDepartmentHistory tableHumanResources.EmployeeDepartmentHistoryTableEmployee department transfers.2
    HumanResources.EmployeePayHistory tableHumanResources.EmployeePayHistoryTableEmployee pay history.2
    iPurchaseOrderDetail triggeriPurchaseOrderDetailTriggerAFTER INSERT trigger that inserts a row in the TransactionHistory table and updates the PurchaseOrderHeader.SubTotal column.3
    HumanResources.JobCandidate tableHumanResources.JobCandidateTableRésumés submitted to Human Resources by job applicants.2
    Production.ProductDocument tableProduction.ProductDocumentTableCross-reference table mapping products to related product documents.2
    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.SalesOrderHeader tableSales.SalesOrderHeaderTableGeneral sales order information.1
    Sales.SalesOrderHeaderSalesReason tableSales.SalesOrderHeaderSalesReasonTableCross-reference table mapping sales orders to sales reason codes.3
    Sales.SalesPerson tableSales.SalesPersonTableSales representative current information.2
    Sales.SalesPersonQuotaHistory tableSales.SalesPersonQuotaHistoryTableSales performance tracking.2
    Sales.SalesTerritoryHistory tableSales.SalesTerritoryHistoryTableSales representative transfers to other sales territories.1
    Sales.Store tableSales.StoreTableCustomers (resellers) of Adventure Works products.1
    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
    dbo.uspSearchCandidateResumes proceduredbo.uspSearchCandidateResumesStored Procedure 3
    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.2
    HumanResources.uspUpdateEmployeeLogin procedureHumanResources.uspUpdateEmployeeLoginStored ProcedureUpdates the Employee table with the values specified in the input parameters for the given BusinessEntityID.2
    HumanResources.uspUpdateEmployeePersonalInfo procedureHumanResources.uspUpdateEmployeePersonalInfoStored ProcedureUpdates the Employee table with the values specified in the input parameters for the given EmployeeID.2
    HumanResources.vEmployee viewHumanResources.vEmployeeViewEmployee names and addresses.2
    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.2
    HumanResources.vJobCandidate viewHumanResources.vJobCandidateViewJob candidate names and resumes.3
    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.3
    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.3
    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.3
    Sales.vStoreWithAddresses viewSales.vStoreWithAddressesViewStores (including store addresses) that sell Adventure Works Cycles products to consumers.1
    Sales.vStoreWithContacts viewSales.vStoreWithContactsViewStores (including store contacts) that sell Adventure Works Cycles products to consumers.1
    Sales.vStoreWithDemographics viewSales.vStoreWithDemographicsViewStores (including demographics) that sell Adventure Works Cycles products to consumers.1
    Objects that HumanResources.Employee depends on
     Database ObjectObject TypeDescriptionDep Level
    Person.BusinessEntity tablePerson.BusinessEntityTableSource of the ID that connects vendors, customers, and employees with address and contact information.2
    dbo.Flag datatypedbo.FlagUser Defined Data Type 4
    dbo.Name datatypedbo.NameUser Defined Data Type 2
    dbo.NameStyle datatypedbo.NameStyleUser Defined Data Type 5
    Person.Person tablePerson.PersonTableHuman beings involved with AdventureWorks: employees, customer contacts, and vendor contacts.4
    SQL
    SET ANSI_NULLS ON
    SET QUOTED_IDENTIFIER ON
    CREATE TABLE [HumanResources].[Employee](
        [BusinessEntityID] [int] NOT NULL,
        [NationalIDNumber] [nvarchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [LoginID] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [OrganizationNode] [hierarchyid] NULL,
        [OrganizationLevel]  AS ([OrganizationNode].[GetLevel]()),
        [JobTitle] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
        [BirthDate] [date] 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] [date] 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_BusinessEntityID] PRIMARY KEY CLUSTERED 
    (
        [BusinessEntityID] 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] 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]
    ALTER TABLE [HumanResources].[Employee]  WITH CHECK ADD  CONSTRAINT [FK_Employee_Person_BusinessEntityID] FOREIGN KEY([BusinessEntityID])
    REFERENCES [Person].[Person] ([BusinessEntityID])
    ALTER TABLE [HumanResources].[Employee] CHECK CONSTRAINT [FK_Employee_Person_BusinessEntityID]
    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]
    See Also