如何对受第三方实体约束的 1:N 关系进行建模?

发布于 2024-11-05 02:45:54 字数 327 浏览 0 评论 0原文

我的困境:我正在对一个会计数据库进行建模,其中客户与帐户实体的关系是一对多(1:N),但客户与办公室位置的关系是唯一的(一对一,1:1) 。我尝试找出三元关系,并将其解析为通过二元关系附加到其他三个的弱实体。我最终得到这样的结果:

OFFICE_LOC ---SERVES(M:N)=== CLIENT

OFFICE_LOC ---ANCHORS(1:N)=== ACCOUNT (WE)

CLIENT ===OWNS(1:N)= == 帐户(我们)

我很难弄清楚如何对客户在每个 office_loc 只能拥有一个帐户的条件进行建模,尽管一般来说他们可以拥有多个帐户。

My predicament: I am Chen-modelling an accounting database in which the client to account entity relationship is one-to-many (1:N), but the client to office_location relationship is unique (one-to-one, 1:1). I've tried figuring a ternary relationship and also resolving it into a weak entity attached to the other three through binary relationships. I end up with something like this:

OFFICE_LOC ---SERVES(M:N)=== CLIENT

OFFICE_LOC ---ANCHORS(1:N)=== ACCOUNT (WE)

CLIENT ===OWNS(1:N)=== ACCOUNT (WE)

I am having a tough time figuring out how to model the condition that a client can have only one account per office_loc even though they can have many accounts, generally speaking.

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

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

发布评论

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

评论(1

黯然 2024-11-12 02:45:54

我不知道您是否具体询问如何在 Chen 建模中对某些内容进行建模(我对此一无所知),或者您是否询问如何对这种关系进行数据建模。如果前者忽略这个答案,如果后者...

Client <---Client_2_Account--->帐户

除了客户和帐户的 fkey 字段之外,Client_2_Account 多对多表还将具有 Office_Location fkey 字段。对 client/office_location 的复合键和 account 的唯一键设置唯一约束。这样,一个客户在一个办公地点只能拥有一个帐户记录,并且每个帐户记录只能由一个客户拥有。

I don't know if your asking specifically how to model something in Chen modelling (which I know NOTHING about) or if you're asking how to data model this relationship. If the former ignore this answer, if the latter...

Client <---Client_2_Account---> Account

The Client_2_Account many-to-many table will have an Office_Location fkey field in addition to the fkey fields for client and account. Put a unique constraint on the compound key of client/office_location and a unique key on account. Then a client can have only one account record for an office location and each account record can be owned by only one client.

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