Vous êtes sur la page 1sur 3

Type 2 Dimension

“emp” is a dimension table with “deptno” as Type 2 attribute, if an employee moves from a dept to another dept, update the previous record
with old dept no as expired (flag it as expired with an expiration date) and insert new record with a new dept no as current record.

Columns

empid : Surrogate Key (Primary Key in Dimension Table)

empno: Business Key (Primary Key in OLTP)

deptno: Type 2 Attribute

currentflag: Y current record, N expired (IBM Doc: not required if you have “expirationdate” defined)

effective date: date when the record was created / effective from (IBM Doc: Only 1 effective date column is allowed )

expirationdate:date when the record expired. (IBM Doc: not required if you have “currentflag” defined)

1
Table Structure:

2
Script to create Table (SQL Server)

USE [Database Name]


GO
/****** Object: Table [dbo].[emp] Script Date: 11/26/2009 07:08:36 ******/
CREATE TABLE [dbo].[emp](
[empid] [int] NOT NULL,
[empno] [int] NOT NULL,
[empname] [varchar](20) NOT NULL,
[salary] [decimal](10, 2) NOT NULL,
[deptno] [int] NOT NULL,
[currentflag] [varchar](1) NOT NULL,
[effectivedate] [datetime] NOT NULL,
[expirationdate] [datetime] NOT NULL,
CONSTRAINT [PK_emp] PRIMARY KEY CLUSTERED
(
[empid] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

Vous aimerez peut-être aussi