Difference between revisions of "HumanResources.Employee (table)"

From dbscript Online Help
Jump to: navigation, search
 
(10 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
|-
+
|- valign="top"
 
| '''Table
 
| '''Table
 
| HumanResources.Employee
 
| HumanResources.Employee
|-
+
|- valign="top"
 +
| '''Description
 +
| Employee information such as salary, department, and title.
 
|}
 
|}
  
 
+
=== Columns ===
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
|- style="background:silver"
Line 15: Line 17:
 
| '''Nullable
 
| '''Nullable
 
| '''Default
 
| '''Default
| '''PK
+
| '''Description
| '''Index
+
 
+
|- valign="top"
|-
 
 
| EmployeeID
 
| EmployeeID
 
| int
 
| int
 
| not null
 
| not null
 
|  
 
|  
| PK_Employee_EmployeeID
+
| Primary key for Employee records.
|
+
|- valign="top"
|-
 
 
| NationalIDNumber
 
| NationalIDNumber
 
| nvarchar(15)
 
| nvarchar(15)
 
| not null
 
| not null
 
|  
 
|  
|  
+
| Unique national identification number such as a social security number.
| AK_Employee_NationalIDNumber
+
|- valign="top"
|-
 
 
| ContactID
 
| ContactID
 
| int
 
| int
 
| not null
 
| not null
 
|  
 
|  
|  
+
| Identifies the employee in the Contact table. Foreign key to Contact.ContactID.
|
+
|- valign="top"
|-
 
 
| LoginID
 
| LoginID
 
| nvarchar(256)
 
| nvarchar(256)
 
| not null
 
| not null
 
|  
 
|  
|  
+
| Network login.
| AK_Employee_LoginID
+
|- valign="top"
|-
 
 
| ManagerID
 
| ManagerID
 
| int
 
| int
 
| null
 
| null
 
|  
 
|  
|  
+
| Manager to whom the employee is assigned. Foreign Key to Employee.M
| IX_Employee_ManagerID
+
|- valign="top"
|-
 
 
| Title
 
| Title
 
| nvarchar(50)
 
| nvarchar(50)
 
| not null
 
| not null
 
|  
 
|  
|  
+
| Work title such as Buyer or Sales Representative.
|
+
|- valign="top"
|-
 
 
| BirthDate
 
| BirthDate
 
| datetime
 
| datetime
 
| not null
 
| not null
 
|  
 
|  
|  
+
| Date of birth.
|
+
|- valign="top"
|-
 
 
| MaritalStatus
 
| MaritalStatus
 
| nchar(1)
 
| nchar(1)
 
| not null
 
| not null
 
|  
 
|  
|  
+
| M = Married, S = Single
|
+
|- valign="top"
|-
 
 
| Gender
 
| Gender
 
| nchar(1)
 
| nchar(1)
 
| not null
 
| not null
 
|  
 
|  
|  
+
| M = Male, F = Female
|
+
|- valign="top"
|-
 
 
| HireDate
 
| HireDate
 
| datetime
 
| datetime
 
| not null
 
| not null
 
|  
 
|  
|  
+
| Employee hired on this date.
|
+
|- valign="top"
|-
 
 
| SalariedFlag
 
| SalariedFlag
 
| dbo.Flag
 
| dbo.Flag
 
| not null
 
| not null
 
| ((1))
 
| ((1))
|  
+
| Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining.
|
+
|- valign="top"
|-
 
 
| VacationHours
 
| VacationHours
 
| smallint
 
| smallint
 
| not null
 
| not null
 
| ((0))
 
| ((0))
|  
+
| Number of available vacation hours.
|
+
|- valign="top"
|-
 
 
| SickLeaveHours
 
| SickLeaveHours
 
| smallint
 
| smallint
 
| not null
 
| not null
 
| ((0))
 
| ((0))
|  
+
| Number of available sick leave hours.
|
+
|- valign="top"
|-
 
 
| CurrentFlag
 
| CurrentFlag
 
| dbo.Flag
 
| dbo.Flag
 
| not null
 
| not null
 
| ((1))
 
| ((1))
|  
+
| 0 = Inactive, 1 = Active
|
+
|- valign="top"
|-
 
 
| rowguid
 
| rowguid
 
| uniqueidentifier
 
| uniqueidentifier
 
| not null
 
| not null
 
| (newid())
 
| (newid())
|  
+
| ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.
| AK_Employee_rowguid
+
|- valign="top"
|-
 
 
| ModifiedDate
 
| ModifiedDate
 
| datetime
 
| datetime
 
| not null
 
| not null
 
| (getdate())
 
| (getdate())
 +
| Date and time the record was last updated.
 +
|}
 +
 +
=== Primary Key ===
 +
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 +
|- style="background:silver"
 +
| '''Primary Key
 +
| '''Columns
 +
|- valign="top"
 +
| PK_Employee_EmployeeID
 +
| EmployeeID
 +
|}
 +
 +
=== Indexes ===
 +
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 +
|- style="background:silver"
 +
| '''Index
 +
| '''Type
 +
| '''Columns
 +
 +
|- valign="top"
 +
| AK_Employee_LoginID
 +
| Unique
 +
| LoginID
 +
|- valign="top"
 +
| AK_Employee_NationalIDNumber
 +
| Unique
 +
| NationalIDNumber
 +
|- valign="top"
 +
| AK_Employee_rowguid
 +
| Unique
 +
| rowguid
 +
|- valign="top"
 +
| IX_Employee_ManagerID
 
|  
 
|  
|  
+
| ManagerID
 
|}
 
|}
  
 +
=== Check Constraints ===
 +
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 +
|- style="background:silver"
 +
| '''Check Constraint
 +
| '''Expression
 +
| '''Description
  
 +
|- valign="top"
 +
| CK_Employee_BirthDate
 +
| ([BirthDate]>='1930-01-01' AND [BirthDate]<=dateadd(year,(-18),getdate()))
 +
| Check constraint [BirthDate] >= '1930-01-01' AND [BirthDate] <= dateadd(year,(-18),GETDATE())
 +
|- valign="top"
 +
| CK_Employee_Gender
 +
| (upper([Gender])='F' OR upper([Gender])='M')
 +
| Check constraint [Gender]='f' OR [Gender]='m' OR [Gender]='F' OR [Gender]='M'
 +
|- valign="top"
 +
| CK_Employee_HireDate
 +
| ([HireDate]>='1996-07-01' AND [HireDate]<=dateadd(day,(1),getdate()))
 +
| Check constraint [HireDate] >= '1996-07-01' AND [HireDate] <= dateadd(day,(1),GETDATE())
 +
|- valign="top"
 +
| CK_Employee_MaritalStatus
 +
| (upper([MaritalStatus])='S' OR upper([MaritalStatus])='M')
 +
| Check constraint [MaritalStatus]='s' OR [MaritalStatus]='m' OR [MaritalStatus]='S' OR [MaritalStatus]='M'
 +
|- valign="top"
 +
| CK_Employee_SickLeaveHours
 +
| ([SickLeaveHours]>=(0) AND [SickLeaveHours]<=(120))
 +
| Check constraint [SickLeaveHours] >= (0) AND [SickLeaveHours] <= (120)
 +
|- valign="top"
 +
| CK_Employee_VacationHours
 +
| ([VacationHours]>=(-40) AND [VacationHours]<=(240))
 +
| Check constraint [VacationHours] >= (-40) AND [VacationHours] <= (240)
 +
|}
  
 +
=== Foreign Keys ===
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
|- style="background:silver"
Line 139: Line 191:
 
| '''Column
 
| '''Column
 
| '''Referenced Column
 
| '''Referenced Column
+
 
|-
+
|- valign="top"
 
| [[Person.Contact_(table)|Person.Contact]]
 
| [[Person.Contact_(table)|Person.Contact]]
 
| ContactID
 
| ContactID
 
| ContactID
 
| ContactID
|-
+
|- valign="top"
 
| [[HumanResources.Employee_(table)|HumanResources.Employee]]
 
| [[HumanResources.Employee_(table)|HumanResources.Employee]]
 
| ManagerID
 
| ManagerID
Line 150: Line 202:
 
|}
 
|}
  
 
+
=== Detail Tables ===
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
|- style="background:silver"
Line 156: Line 208:
 
| '''Column
 
| '''Column
 
| '''Referencing Column
 
| '''Referencing Column
+
 
|-
+
|- valign="top"
 
| [[HumanResources.Employee_(table)|HumanResources.Employee]]
 
| [[HumanResources.Employee_(table)|HumanResources.Employee]]
 
| EmployeeID
 
| EmployeeID
 
| ManagerID
 
| ManagerID
|-
+
|- valign="top"
 
| [[HumanResources.EmployeeAddress_(table)|HumanResources.EmployeeAddress]]
 
| [[HumanResources.EmployeeAddress_(table)|HumanResources.EmployeeAddress]]
 
| EmployeeID
 
| EmployeeID
 
| EmployeeID
 
| EmployeeID
|-
+
|- valign="top"
 
| [[HumanResources.EmployeeDepartmentHistory_(table)|HumanResources.EmployeeDepartmentHistory]]
 
| [[HumanResources.EmployeeDepartmentHistory_(table)|HumanResources.EmployeeDepartmentHistory]]
 
| EmployeeID
 
| EmployeeID
 
| EmployeeID
 
| EmployeeID
|-
+
|- valign="top"
 
| [[HumanResources.EmployeePayHistory_(table)|HumanResources.EmployeePayHistory]]
 
| [[HumanResources.EmployeePayHistory_(table)|HumanResources.EmployeePayHistory]]
 
| EmployeeID
 
| EmployeeID
 
| EmployeeID
 
| EmployeeID
|-
+
|- valign="top"
 
| [[HumanResources.JobCandidate_(table)|HumanResources.JobCandidate]]
 
| [[HumanResources.JobCandidate_(table)|HumanResources.JobCandidate]]
 
| EmployeeID
 
| EmployeeID
 
| EmployeeID
 
| EmployeeID
|-
+
|- valign="top"
 
| [[Purchasing.PurchaseOrderHeader_(table)|Purchasing.PurchaseOrderHeader]]
 
| [[Purchasing.PurchaseOrderHeader_(table)|Purchasing.PurchaseOrderHeader]]
 
| EmployeeID
 
| EmployeeID
 
| EmployeeID
 
| EmployeeID
|-
+
|- valign="top"
 
| [[Sales.SalesPerson_(table)|Sales.SalesPerson]]
 
| [[Sales.SalesPerson_(table)|Sales.SalesPerson]]
 
| EmployeeID
 
| EmployeeID
Line 187: Line 239:
 
|}
 
|}
  
 
+
=== Triggers ===
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
|- style="background:silver"
| '''Triggers
+
| '''Trigger
 
| '''Type
 
| '''Type
+
 
|-
+
|- valign="top"
 
| dEmployee
 
| dEmployee
 
| INSTEAD OF DELETE
 
| INSTEAD OF DELETE
 
|}
 
|}
 +
 +
==== Trigger dEmployee ====
 +
<pre>
 +
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;
 +
</pre>
 +
 +
=== References ===
 +
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 +
|- style="background:silver"
 +
| '''Dependency Type
 +
| '''Object Type
 +
| '''Referenced Object
 +
 +
|- valign="top"
 +
| Data Type
 +
| Type
 +
| [[dbo.Flag_(type)|dbo.Flag]]
 +
 +
|- valign="top"
 +
| Schema
 +
| Schema
 +
| [[HumanResources_(schema)|HumanResources]]
 +
 +
|}
 +
 +
=== Dependencies ===
 +
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 +
|- style="background:silver"
 +
| '''Reference Type
 +
| '''Object Type
 +
| '''Referencing Object
 +
 +
|- valign="top"
 +
| Select
 +
| View
 +
| [[HumanResources.vEmployee_(view)|HumanResources.vEmployee]]
 +
 +
|- valign="top"
 +
| Select
 +
| View
 +
| [[HumanResources.vEmployeeDepartment_(view)|HumanResources.vEmployeeDepartment]]
 +
 +
|- valign="top"
 +
| Select
 +
| View
 +
| [[HumanResources.vEmployeeDepartmentHistory_(view)|HumanResources.vEmployeeDepartmentHistory]]
 +
 +
|- valign="top"
 +
| Select
 +
| View
 +
| [[Sales.vSalesPerson_(view)|Sales.vSalesPerson]]
 +
 +
|- valign="top"
 +
| Select
 +
| View
 +
| [[Sales.vSalesPersonSalesByFiscalYears_(view)|Sales.vSalesPersonSalesByFiscalYears]]
 +
 +
|- valign="top"
 +
| Select
 +
| Procedure
 +
| [[dbo.uspGetEmployeeManagers_(procedure)|dbo.uspGetEmployeeManagers]]
 +
 +
|- valign="top"
 +
| Select
 +
| Procedure
 +
| [[dbo.uspGetManagerEmployees_(procedure)|dbo.uspGetManagerEmployees]]
 +
 +
|- valign="top"
 +
| Update
 +
| Procedure
 +
| [[HumanResources.uspUpdateEmployeeHireInfo_(procedure)|HumanResources.uspUpdateEmployeeHireInfo]]
 +
 +
|- valign="top"
 +
| Update
 +
| Procedure
 +
| [[HumanResources.uspUpdateEmployeeLogin_(procedure)|HumanResources.uspUpdateEmployeeLogin]]
 +
 +
|- valign="top"
 +
| Update
 +
| Procedure
 +
| [[HumanResources.uspUpdateEmployeePersonalInfo_(procedure)|HumanResources.uspUpdateEmployeePersonalInfo]]
 +
 +
|- valign="top"
 +
| Select
 +
| SQL table-valued-function
 +
| [[dbo.ufnGetContactInformation_(function)|dbo.ufnGetContactInformation]]
 +
 +
|}
 +
 +
 
== automatically generated ==
 
== automatically generated ==
  
Line 203: Line 368:
 
| '''Table
 
| '''Table
 
| HumanResources.Employee
 
| HumanResources.Employee
|-
+
|- valign="top"
 
 
 
| '''Description
 
| '''Description
 
| Employee information such as salary, department, and title.
 
| Employee information such as salary, department, and title.
 
|-
 
|-
 
 
|}
 
|}
  
Line 225: Line 388:
 
| not null
 
| not null
 
|  
 
|  
| Primary key for Employee records.PK_Employee_EmployeeID
+
| Primary key for Employee records.<br />PK_Employee_EmployeeID
 
|- valign="top"
 
|- valign="top"
 
| NationalIDNumber
 
| NationalIDNumber
Line 231: Line 394:
 
| not null
 
| not null
 
|  
 
|  
| Unique national identification number such as a social security number.AK_Employee_NationalIDNumber
+
| Unique national identification number such as a social security number.<br />AK_Employee_NationalIDNumber
 
|- valign="top"
 
|- valign="top"
 
| ContactID
 
| ContactID
Line 237: Line 400:
 
| not null
 
| not null
 
|  
 
|  
| Identifies the employee in the Contact table. Foreign key to Contact.ContactID.
+
| Identifies the employee in the Contact table. Foreign key to Contact.ContactID.<br />
 
|- valign="top"
 
|- valign="top"
 
| LoginID
 
| LoginID
Line 243: Line 406:
 
| not null
 
| not null
 
|  
 
|  
| Network login.AK_Employee_LoginID
+
| Network login.<br />AK_Employee_LoginID
 
|- valign="top"
 
|- valign="top"
 
| ManagerID
 
| ManagerID
Line 249: Line 412:
 
| null
 
| null
 
|  
 
|  
| Manager to whom the employee is assigned. Foreign Key to Employee.MIX_Employee_ManagerID
+
| Manager to whom the employee is assigned. Foreign Key to Employee.M<br />IX_Employee_ManagerID
 
|- valign="top"
 
|- valign="top"
 
| Title
 
| Title
Line 255: Line 418:
 
| not null
 
| not null
 
|  
 
|  
| Work title such as Buyer or Sales Representative.
+
| Work title such as Buyer or Sales Representative.<br />
 
|- valign="top"
 
|- valign="top"
 
| BirthDate
 
| BirthDate
Line 261: Line 424:
 
| not null
 
| not null
 
|  
 
|  
| Date of birth.
+
| Date of birth.<br />
 
|- valign="top"
 
|- valign="top"
 
| MaritalStatus
 
| MaritalStatus
Line 267: Line 430:
 
| not null
 
| not null
 
|  
 
|  
| M = Married, S = Single
+
| M = Married, S = Single<br />
 
|- valign="top"
 
|- valign="top"
 
| Gender
 
| Gender
Line 273: Line 436:
 
| not null
 
| not null
 
|  
 
|  
| M = Male, F = Female
+
| M = Male, F = Female<br />
 
|- valign="top"
 
|- valign="top"
 
| HireDate
 
| HireDate
Line 279: Line 442:
 
| not null
 
| not null
 
|  
 
|  
| Employee hired on this date.
+
| Employee hired on this date.<br />
 
|- valign="top"
 
|- valign="top"
 
| SalariedFlag
 
| SalariedFlag
Line 285: Line 448:
 
| not null
 
| not null
 
| (1)
 
| (1)
| Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining.
+
| Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining.<br />
 
|- valign="top"
 
|- valign="top"
 
| VacationHours
 
| VacationHours
Line 291: Line 454:
 
| not null
 
| not null
 
| (0)
 
| (0)
| Number of available vacation hours.
+
| Number of available vacation hours.<br />
 
|- valign="top"
 
|- valign="top"
 
| SickLeaveHours
 
| SickLeaveHours
Line 297: Line 460:
 
| not null
 
| not null
 
| (0)
 
| (0)
| Number of available sick leave hours.
+
| Number of available sick leave hours.<br />
 
|- valign="top"
 
|- valign="top"
 
| CurrentFlag
 
| CurrentFlag
Line 303: Line 466:
 
| not null
 
| not null
 
| (1)
 
| (1)
| 0 = Inactive, 1 = Active
+
| 0 = Inactive, 1 = Active<br />
 
|- valign="top"
 
|- valign="top"
 
| rowguid
 
| rowguid
Line 309: Line 472:
 
| not null
 
| not null
 
| (NEWID())
 
| (NEWID())
| ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.AK_Employee_rowguid
+
| ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.<br />AK_Employee_rowguid
 
|- valign="top"
 
|- valign="top"
 
| ModifiedDate
 
| ModifiedDate
Line 315: Line 478:
 
| not null
 
| not null
 
| (GETDATE())
 
| (GETDATE())
| Date and time the record was last updated.
+
| Date and time the record was last updated.<br />
 
|}
 
|}
  
Line 387: Line 550:
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
|- style="background:silver"
 +
| '''Dependency Type
 +
| '''Object Type
 
| '''Referenced Object
 
| '''Referenced Object
| '''Object Type
+
 
| '''Dependency Type
 
 
 
|-
 
|-
 +
| Data Type
 +
| Type
 
| [[dbo.Flag_(type)|dbo.Flag]]
 
| [[dbo.Flag_(type)|dbo.Flag]]
| Type
+
 
| Data Type
+
|-
 +
| Schema
 +
| Schema
 +
| [[HumanResources_(schema)|HumanResources]]
 +
 
 
|}
 
|}
  
Line 400: Line 569:
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
|- style="background:silver"
 +
| '''Reference Type
 +
| '''Object Type
 
| '''Referencing Object
 
| '''Referencing Object
| '''Object Type
+
 
| '''Reference Type
 
 
 
|-
 
|-
 +
| Select
 +
| View
 
| [[HumanResources.vEmployee_(view)|HumanResources.vEmployee]]
 
| [[HumanResources.vEmployee_(view)|HumanResources.vEmployee]]
 +
 +
|-
 +
| Select
 
| View
 
| View
 +
| [[HumanResources.vEmployeeDepartment_(view)|HumanResources.vEmployeeDepartment]]
 +
 +
|-
 
| Select
 
| Select
 +
| View
 +
| [[HumanResources.vEmployeeDepartmentHistory_(view)|HumanResources.vEmployeeDepartmentHistory]]
 +
 
|-
 
|-
| [[HumanResources.vEmployeeDepartment_(view)|HumanResources.vEmployeeDepartment]]
+
| Select
 
| View
 
| View
 +
| [[Sales.vSalesPerson_(view)|Sales.vSalesPerson]]
 +
 +
|-
 
| Select
 
| Select
|-
 
| [[HumanResources.vEmployeeDepartmentHistory_(view)|HumanResources.vEmployeeDepartmentHistory]]
 
 
| View
 
| View
| Select
+
| [[Sales.vSalesPersonSalesByFiscalYears_(view)|Sales.vSalesPersonSalesByFiscalYears]]
 +
 
 
|-
 
|-
| [[Sales.vSalesPerson_(view)|Sales.vSalesPerson]]
 
| View
 
 
| Select
 
| Select
 +
| Procedure
 +
| [[dbo.uspGetEmployeeManagers_(procedure)|dbo.uspGetEmployeeManagers]]
 +
 
|-
 
|-
| [[Sales.vSalesPersonSalesByFiscalYears_(view)|Sales.vSalesPersonSalesByFiscalYears]]
 
| View
 
 
| Select
 
| Select
 +
| Procedure
 +
| [[dbo.uspGetManagerEmployees_(procedure)|dbo.uspGetManagerEmployees]]
 +
 
|-
 
|-
| [[dbo.uspGetEmployeeManagers_(procedure)|dbo.uspGetEmployeeManagers]]
+
| Update
 
| Procedure
 
| Procedure
| Select
+
| [[HumanResources.uspUpdateEmployeeHireInfo_(procedure)|HumanResources.uspUpdateEmployeeHireInfo]]
 +
 
 
|-
 
|-
| [[dbo.uspGetManagerEmployees_(procedure)|dbo.uspGetManagerEmployees]]
+
| Update
 
| Procedure
 
| Procedure
| Select
+
| [[HumanResources.uspUpdateEmployeeLogin_(procedure)|HumanResources.uspUpdateEmployeeLogin]]
 +
 
 
|-
 
|-
| [[HumanResources.uspUpdateEmployeeHireInfo_(procedure)|HumanResources.uspUpdateEmployeeHireInfo]]
 
| Procedure
 
 
| Update
 
| Update
|-
 
| [[HumanResources.uspUpdateEmployeeLogin_(procedure)|HumanResources.uspUpdateEmployeeLogin]]
 
 
| Procedure
 
| Procedure
| Update
 
|-
 
 
| [[HumanResources.uspUpdateEmployeePersonalInfo_(procedure)|HumanResources.uspUpdateEmployeePersonalInfo]]
 
| [[HumanResources.uspUpdateEmployeePersonalInfo_(procedure)|HumanResources.uspUpdateEmployeePersonalInfo]]
| Procedure
+
 
| Update
 
 
|-
 
|-
 +
| Select
 +
| SQL table-valued-function
 
| [[dbo.ufnGetContactInformation_(function)|dbo.ufnGetContactInformation]]
 
| [[dbo.ufnGetContactInformation_(function)|dbo.ufnGetContactInformation]]
| SQL table-valued-function
+
 
| Select
 
 
|}
 
|}

Latest revision as of 00:15, 24 June 2010

wikibot[edit]

Table HumanResources.Employee
Description Employee information such as salary, department, and title.

Columns[edit]

Column Data Type Nullable Default Description
EmployeeID int not null Primary key for Employee records.
NationalIDNumber nvarchar(15) not null Unique national identification number such as a social security number.
ContactID int not null Identifies the employee in the Contact table. Foreign key to Contact.ContactID.
LoginID nvarchar(256) not null Network login.
ManagerID int null Manager to whom the employee is assigned. Foreign Key to Employee.M
Title nvarchar(50) not null Work title such as Buyer or Sales Representative.
BirthDate datetime not null Date of birth.
MaritalStatus nchar(1) not null M = Married, S = Single
Gender nchar(1) not null M = Male, F = Female
HireDate datetime not null Employee hired on this date.
SalariedFlag dbo.Flag not null ((1)) Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining.
VacationHours smallint not null ((0)) Number of available vacation hours.
SickLeaveHours smallint not null ((0)) Number of available sick leave hours.
CurrentFlag dbo.Flag not null ((1)) 0 = Inactive, 1 = Active
rowguid uniqueidentifier not null (newid()) ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.
ModifiedDate datetime not null (getdate()) Date and time the record was last updated.

Primary Key[edit]

Primary Key Columns
PK_Employee_EmployeeID EmployeeID

Indexes[edit]

Index Type Columns
AK_Employee_LoginID Unique LoginID
AK_Employee_NationalIDNumber Unique NationalIDNumber
AK_Employee_rowguid Unique rowguid
IX_Employee_ManagerID ManagerID

Check Constraints[edit]

Check Constraint Expression Description
CK_Employee_BirthDate ([BirthDate]>='1930-01-01' AND [BirthDate]<=dateadd(year,(-18),getdate())) Check constraint [BirthDate] >= '1930-01-01' AND [BirthDate] <= dateadd(year,(-18),GETDATE())
CK_Employee_Gender (upper([Gender])='F' OR upper([Gender])='M') Check constraint [Gender]='f' OR [Gender]='m' OR [Gender]='F' OR [Gender]='M'
CK_Employee_HireDate ([HireDate]>='1996-07-01' AND [HireDate]<=dateadd(day,(1),getdate())) Check constraint [HireDate] >= '1996-07-01' AND [HireDate] <= dateadd(day,(1),GETDATE())
CK_Employee_MaritalStatus (upper([MaritalStatus])='S' OR upper([MaritalStatus])='M') Check constraint [MaritalStatus]='s' OR [MaritalStatus]='m' OR [MaritalStatus]='S' OR [MaritalStatus]='M'
CK_Employee_SickLeaveHours ([SickLeaveHours]>=(0) AND [SickLeaveHours]<=(120)) Check constraint [SickLeaveHours] >= (0) AND [SickLeaveHours] <= (120)
CK_Employee_VacationHours ([VacationHours]>=(-40) AND [VacationHours]<=(240)) Check constraint [VacationHours] >= (-40) AND [VacationHours] <= (240)

Foreign Keys[edit]

Relation Column Referenced Column
Person.Contact ContactID ContactID
HumanResources.Employee ManagerID EmployeeID

Detail Tables[edit]

Detail Table Column Referencing Column
HumanResources.Employee EmployeeID ManagerID
HumanResources.EmployeeAddress EmployeeID EmployeeID
HumanResources.EmployeeDepartmentHistory EmployeeID EmployeeID
HumanResources.EmployeePayHistory EmployeeID EmployeeID
HumanResources.JobCandidate EmployeeID EmployeeID
Purchasing.PurchaseOrderHeader EmployeeID EmployeeID
Sales.SalesPerson EmployeeID SalesPersonID

Triggers[edit]

Trigger Type
dEmployee INSTEAD OF DELETE

Trigger dEmployee[edit]

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;

References[edit]

Dependency Type Object Type Referenced Object
Data Type Type dbo.Flag
Schema Schema HumanResources

Dependencies[edit]

Reference Type Object Type Referencing Object
Select View HumanResources.vEmployee
Select View HumanResources.vEmployeeDepartment
Select View HumanResources.vEmployeeDepartmentHistory
Select View Sales.vSalesPerson
Select View Sales.vSalesPersonSalesByFiscalYears
Select Procedure dbo.uspGetEmployeeManagers
Select Procedure dbo.uspGetManagerEmployees
Update Procedure HumanResources.uspUpdateEmployeeHireInfo
Update Procedure HumanResources.uspUpdateEmployeeLogin
Update Procedure HumanResources.uspUpdateEmployeePersonalInfo
Select SQL table-valued-function dbo.ufnGetContactInformation


automatically generated[edit]

Table HumanResources.Employee
Description Employee information such as salary, department, and title.


Column Data Type Nullable Default Description / PK / Index
EmployeeID int not null Primary key for Employee records.
PK_Employee_EmployeeID
NationalIDNumber nvarchar(15) not null Unique national identification number such as a social security number.
AK_Employee_NationalIDNumber
ContactID int not null Identifies the employee in the Contact table. Foreign key to Contact.ContactID.
LoginID nvarchar(256) not null Network login.
AK_Employee_LoginID
ManagerID int null Manager to whom the employee is assigned. Foreign Key to Employee.M
IX_Employee_ManagerID
Title nvarchar(50) not null Work title such as Buyer or Sales Representative.
BirthDate datetime not null Date of birth.
MaritalStatus nchar(1) not null M = Married, S = Single
Gender nchar(1) not null M = Male, F = Female
HireDate datetime not null Employee hired on this date.
SalariedFlag Flag not null (1) Job classification. 0 = Hourly, not exempt from collective bargaining. 1 = Salaried, exempt from collective bargaining.
VacationHours smallint not null (0) Number of available vacation hours.
SickLeaveHours smallint not null (0) Number of available sick leave hours.
CurrentFlag Flag not null (1) 0 = Inactive, 1 = Active
rowguid uniqueidentifier not null (NEWID()) ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.
AK_Employee_rowguid
ModifiedDate datetime not null (GETDATE()) Date and time the record was last updated.


Relation Column Referenced Column
Person.Contact ContactID ContactID
HumanResources.Employee ManagerID EmployeeID


Detail Table Column Referencing Column
HumanResources.Employee EmployeeID ManagerID
HumanResources.EmployeeAddress EmployeeID EmployeeID
HumanResources.EmployeeDepartmentHistory EmployeeID EmployeeID
HumanResources.EmployeePayHistory EmployeeID EmployeeID
HumanResources.JobCandidate EmployeeID EmployeeID
Purchasing.PurchaseOrderHeader EmployeeID EmployeeID
Sales.SalesPerson EmployeeID SalesPersonID


Triggers Type
dEmployee INSTEAD OF DELETE


Dependency Type Object Type Referenced Object
Data Type Type dbo.Flag
Schema Schema HumanResources


Reference Type Object Type Referencing Object
Select View HumanResources.vEmployee
Select View HumanResources.vEmployeeDepartment
Select View HumanResources.vEmployeeDepartmentHistory
Select View Sales.vSalesPerson
Select View Sales.vSalesPersonSalesByFiscalYears
Select Procedure dbo.uspGetEmployeeManagers
Select Procedure dbo.uspGetManagerEmployees
Update Procedure HumanResources.uspUpdateEmployeeHireInfo
Update Procedure HumanResources.uspUpdateEmployeeLogin
Update Procedure HumanResources.uspUpdateEmployeePersonalInfo
Select SQL table-valued-function dbo.ufnGetContactInformation