听起来好像你可以将任务和摘要视为超类型“形式”的子类型。 (我使用超和亚型在他们的关系型数据库的设计感,而不是在他们的面向对象编程的感觉。)
create table forms (
form_id integer not null,
form_type char(1) not null check (form_type in ('T', 'B')),
other_form_columns char(1),
primary key (form_id, form_type)
);
create table tasks (
form_id integer not null,
form_type char(1) not null default 'T' check (form_type = 'T'),
other_task_columns char(1),
primary key (form_id, form_type),
foreign key (form_id, form_type) references forms (form_id, form_type)
);
create table briefs (
form_id integer not null,
form_type char(1) not null default 'B' check (form_type = 'B'),
other_brief_columns char(1),
primary key (form_id, form_type),
foreign key (form_id, form_type) references forms (form_id, form_type)
);
已经这样做了,你可以创建修订的表引用“形式”中的主键。
create table revisions (
form_id integer not null,
form_type char(1) not null,
revision_num integer not null check (revision_num > 0),
revision_status varchar(20) not null,
other_revision_columns char(1),
primary key (form_id, form_type, revision_num, revision_status),
foreign key (form_id, form_type) references forms (form_id, form_type)
);
这种特殊的结构假设
- 你可以为每个 版本号以上的状态,以及任务的
- 修订和内裤的修订意味着同样的事情。
如果任务修订版与简要修订版不同,那么您需要一张表作为任务修订版,另一张表用于简要修订版。他们的主键不会引用超类型表“forms”;他们会引用子类型表“任务”和“简报”。
我想我会使用上面的两个选项的组合,并为每个表具有列的表格表,然后使用表格表的pk链接到修订表。我有其他表需要链接到每个表,所以我可以使用表格作为所有这些的中心枢纽。谢谢@Damien_The_Unbeliever – 2011-03-16 12:03:08