Description
Employee department transfers.
Table properties
| name | value |
|---|
| name | [HumanResources].[EmployeeDepartmentHistory] |
| created | Mar 19 2009 9:09PM |
| modified | Mar 19 2009 9:10PM
|
| ansi nulls | on
|
| quoted identifier | on
|
| row count | 296 |
| Size of data | 16 kb |
| Size of indexes | 48 kb |
| Maximum size of a single row | 21 bytes |
Columns
| column | datatype | length | bytes | default | nulls | PK | FK | UQ | computed | comment |
|---|
| BusinessEntityID | int | 10 | 4 | | no
| composite PK
| Employee.BusinessEntityID
|
| no
| Employee identification number. Foreign key to Employee.BusinessEntityID.
|
| DepartmentID | smallint | 5 | 2 | | no
| composite PK
| Department.DepartmentID
|
| no
| Department in which the employee worked including currently. Foreign key to Department.DepartmentID.
|
| ShiftID | tinyint | 3 | 1 | | no
| composite PK
| Shift.ShiftID
|
| no
| Identifies which 8-hour shift the employee works. Foreign key to Shift.Shift.ID.
|
| StartDate | date | 10 | 3 | | no
| composite PK
| |
| no
| Date the employee started work in the department.
|
| EndDate | date | 10 | 3 | | yes
|
| |
| no
| Date the employee left the department. NULL = Current department.
|
| ModifiedDate | datetime | 23 | 8 | (getdate()) | no
|
| |
| no
| Date and time the record was last updated.
|
Indexes
References
Foreign key graph
Foreign keys
| name | columns | foreign columns | type | comment |
|---|
| FK_EmployeeDepartmentHistory_Employee_BusinessEntityID | BusinessEntityID | Employee.BusinessEntityID |
| Foreign key constraint referencing Employee.EmployeeID.
|
| FK_EmployeeDepartmentHistory_Department_DepartmentID | DepartmentID | Department.DepartmentID |
| Foreign key constraint referencing Department.DepartmentID.
|
| FK_EmployeeDepartmentHistory_Shift_ShiftID | ShiftID | Shift.ShiftID |
| Foreign key constraint referencing Shift.ShiftID
|
Check constraints
Defaults
Dependency graph
Objects that depend on [HumanResources].[EmployeeDepartmentHistory]
Sample rows
| BusinessEntityID | DepartmentID | ShiftID | StartDate | EndDate | ModifiedDate |
|---|
| 1
| 16
| 1
| 2/15/1999 12:00:00 AM
| NULL
| 2/14/1999 12:00:00 AM
|
| 2
| 1
| 1
| 3/3/1998 12:00:00 AM
| NULL
| 3/2/1998 12:00:00 AM
|
| 3
| 1
| 1
| 12/12/1997 12:00:00 AM
| NULL
| 12/11/1997 12:00:00 AM
|
| 4
| 1
| 1
| 1/5/1998 12:00:00 AM
| 6/30/2000 12:00:00 AM
| 6/28/2000 12:00:00 AM
|
| 4
| 2
| 1
| 7/1/2000 12:00:00 AM
| NULL
| 6/30/2000 12:00:00 AM
|
| 5
| 1
| 1
| 2/6/1998 12:00:00 AM
| NULL
| 2/5/1998 12:00:00 AM
|
| 6
| 1
| 1
| 2/24/1998 12:00:00 AM
| NULL
| 2/23/1998 12:00:00 AM
|
| 7
| 6
| 1
| 3/12/1999 12:00:00 AM
| NULL
| 3/11/1999 12:00:00 AM
|
| 8
| 6
| 1
| 1/30/1999 12:00:00 AM
| NULL
| 1/29/1999 12:00:00 AM
|
| 9
| 6
| 1
| 2/17/1999 12:00:00 AM
| NULL
| 2/16/1999 12:00:00 AM
|
Code
CREATE TABLE [HumanResources].[EmployeeDepartmentHistory](
[BusinessEntityID] [int] NOT NULL,
[DepartmentID] [smallint] NOT NULL,
[BusinessEntityID] [int] NOT NULL,
[ShiftID] [tinyint] NOT NULL,
[StartDate] [date] NOT NULL,
[EndDate] [date] NULL,
[ModifiedDate] [datetime] NOT NULL,
CONSTRAINT [PK_EmployeeDepartmentHistory_BusinessEntityID_StartDate_DepartmentID] PRIMARY KEY CLUSTERED
(
[BusinessEntityID] ASC,
[StartDate] ASC,
[DepartmentID] ASC,
[ShiftID] 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].[EmployeeDepartmentHistory] WITH CHECK ADD CONSTRAINT [FK_EmployeeDepartmentHistory_Department_DepartmentID] FOREIGN KEY([DepartmentID])
REFERENCES [HumanResources].[Department] ([DepartmentID])
ALTER TABLE [HumanResources].[EmployeeDepartmentHistory] CHECK CONSTRAINT [FK_EmployeeDepartmentHistory_Department_DepartmentID]
ALTER TABLE [HumanResources].[EmployeeDepartmentHistory] WITH CHECK ADD CONSTRAINT [FK_EmployeeDepartmentHistory_Employee_BusinessEntityID] FOREIGN KEY([BusinessEntityID])
REFERENCES [HumanResources].[Employee] ([BusinessEntityID])
ALTER TABLE [HumanResources].[EmployeeDepartmentHistory] CHECK CONSTRAINT [FK_EmployeeDepartmentHistory_Employee_BusinessEntityID]
ALTER TABLE [HumanResources].[EmployeeDepartmentHistory] WITH CHECK ADD CONSTRAINT [FK_EmployeeDepartmentHistory_Shift_ShiftID] FOREIGN KEY([ShiftID])
REFERENCES [HumanResources].[Shift] ([ShiftID])
ALTER TABLE [HumanResources].[EmployeeDepartmentHistory] CHECK CONSTRAINT [FK_EmployeeDepartmentHistory_Shift_ShiftID]
ALTER TABLE [HumanResources].[EmployeeDepartmentHistory] WITH CHECK ADD CONSTRAINT [CK_EmployeeDepartmentHistory_EndDate] CHECK (([EndDate]>=[StartDate] OR [EndDate] IS NULL))
ALTER TABLE [HumanResources].[EmployeeDepartmentHistory] CHECK CONSTRAINT [CK_EmployeeDepartmentHistory_EndDate]
ALTER TABLE [HumanResources].[EmployeeDepartmentHistory] ADD CONSTRAINT [DF_EmployeeDepartmentHistory_ModifiedDate] DEFAULT (getdate()) FOR [ModifiedDate]