Description
Employee department transfers.
Table properties
| name | value |
|---|
| name | [HumanResources].[EmployeeDepartmentHistory] |
| created | Mar 19 2009 9:08PM |
| modified | Mar 19 2009 9:08PM
|
| 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 | 31 bytes |
Columns
| column | datatype | length | bytes | default | nulls | PK | FK | UQ | computed | comment |
|---|
| EmployeeID | int | 10 | 4 | | no
| composite PK
| Employee.EmployeeID
|
| no
| Employee identification number. Foreign key to Employee.EmployeeID.
|
| 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 | datetime | 23 | 8 | | no
| composite PK
| |
| no
| Date the employee started work in the department.
|
| EndDate | datetime | 23 | 8 | | 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_Department_DepartmentID | DepartmentID | Department.DepartmentID |
| Foreign key constraint referencing Department.DepartmentID.
|
| FK_EmployeeDepartmentHistory_Employee_EmployeeID | EmployeeID | Employee.EmployeeID |
| Foreign key constraint referencing Employee.EmployeeID.
|
| 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
| EmployeeID | DepartmentID | ShiftID | StartDate | EndDate | ModifiedDate |
|---|
| 1
| 7
| 1
| 7/31/1996 12:00:00 AM
| NULL
| 7/30/1996 12:00:00 AM
|
| 2
| 4
| 1
| 2/26/1997 12:00:00 AM
| NULL
| 2/25/1997 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
| 2
| 1
| 1/11/1998 12:00:00 AM
| NULL
| 1/10/1998 12:00:00 AM
|
| 6
| 5
| 1
| 1/20/1998 12:00:00 AM
| 8/15/1999 12:00:00 AM
| 8/13/1999 12:00:00 AM
|
| 6
| 4
| 1
| 8/16/1999 12:00:00 AM
| NULL
| 8/15/1999 12:00:00 AM
|
| 7
| 7
| 3
| 1/26/1998 12:00:00 AM
| NULL
| 1/25/1998 12:00:00 AM
|
| 8
| 7
| 1
| 2/6/1998 12:00:00 AM
| NULL
| 2/5/1998 12:00:00 AM
|
Code
CREATE TABLE [HumanResources].[EmployeeDepartmentHistory](
[EmployeeID] [int] NOT NULL,
[DepartmentID] [smallint] NOT NULL,
[EmployeeID] [int] NOT NULL,
[ShiftID] [tinyint] NOT NULL,
[StartDate] [datetime] NOT NULL,
[EndDate] [datetime] NULL,
[ModifiedDate] [datetime] NOT NULL,
CONSTRAINT [PK_EmployeeDepartmentHistory_EmployeeID_StartDate_DepartmentID] PRIMARY KEY CLUSTERED
(
[EmployeeID] 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_EmployeeID] FOREIGN KEY([EmployeeID])
REFERENCES [HumanResources].[Employee] ([EmployeeID])
ALTER TABLE [HumanResources].[EmployeeDepartmentHistory] CHECK CONSTRAINT [FK_EmployeeDepartmentHistory_Employee_EmployeeID]
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]