如何建模这个数据库关系? (Sybase PowerDesigner)

发布于 2024-08-05 12:15:10 字数 553 浏览 8 评论 0原文

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)?
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)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倾听心声的旋律 2024-08-12 12:15:10

该密钥(id_doctor、id_office、id_shift)允许医生轮班在多个办公室工作。尝试将医生和轮班办公室的表作为依赖字段。然而,这将允许一个办公室有多名医生轮班,我不确定这是否被允许。

That key (id_doctor, id_office, id_shift) would allow a doctor to work in many offices in one shift. Try a key for that table of doctor and shift - office being a dependent field. However this would allow an office to have multiple doctors in a shift and I am not certain if that is allowed.

梦里寻她 2024-08-12 12:15:10

OFFICE SCHEDULE 的主键应该是 (id_office, id_shift)。 id_doctor 应该在表中,但不是主键的一部分。这将强制执行这样的规则:给定一个办公室并轮班后,该办公室最多只能有一名医生。

当然,除了构成主键的两个之外,所有这三个都是外键。

The primary key of OFFICE SCHEDULE should be (id_office, id_shift). id_doctor should be in the table, but not part of the primary key. This will enforce the rule that given an office and given a shift there can be at most one doctor in that office.

Of course, all three of these are foreign keys in addition to the two that form the primary key.

想你只要分分秒秒 2024-08-12 12:15:10

我会将您的主键更改为仅包含办公室和轮班,同时还对医生和轮班添加单独的独特约束。

I would change your primary key to only include office and shift, but also add a separate unique contraint on doctor and shift together.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文