在开发历史和分层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)
)