I'm doing a conceptual model in Sybase PowerDesigner. The restriction is following: One doctor can work in only one office at a time during his working time (shift). I guess Doctor - Office relationship should be many-many, but what about time restriction ("during his working time")? Should it be a new table SHIFT? So I guess I should have four tables (DOCTOR, OFFICE, SHIFT and OFFICE SCHEDULE). OFFICE SCHEDULE should be a table connecting all 3 other entities and should have composite primary key (id_doctor, id_office, id_shift)?
答案 0 :(得分:1)
该密钥(id_doctor,id_office,id_shift)将允许医生在一个班次的许多办公室工作。尝试一张关于医生和轮班的办公室的钥匙 - 办公室是一个依赖的领域。然而,这将允许办公室在轮班中拥有多名医生,我不确定是否允许这样做。
答案 1 :(得分:0)
我会将您的主键更改为仅包括办公室和班次,但也会在医生处添加一个独立的约束并一起转移。
答案 2 :(得分:0)
OFFICE SCHEDULE的主键应该是(id_office,id_shift)。 id_doctor应该在表中,但不是主键的一部分。这将强制执行给予办公室的规则,并且在该办公室中最多只能有一名医生。
当然,除了构成主键的两个外键之外,所有这三个都是外键。