为历史分层数据启动和停止日期字段与单个日期字段

时间:2013-02-01 17:37:10

标签: sql hierarchy

在开发历史和分层SQL表时,最好是为每个日期使用开始和结束日期字段或单个日期字段吗?各有利弊,但我正在寻找更优化,更优雅的证据,并最有效地考虑角落案例。

示例 -

-- Start/Stop
create table roster (
    id bigint identity primary key,
    start_date date not null,
    stop_date date not null,
    employee_id int not null references employee (id),
    supervisor_id int not null references employee (id),
    unique(start_date, stop_date, employee_id)
)

-- Single Date
create table roster (
    id bigint identity primary key,
    row_date date not null,
    employee_id int not null references employee (id),
    supervisor_id int not null references employee (id),
    unique(row_date, employee_id)
)

0 个答案:

没有答案