最佳解决方案-三元或二进制关系

问题描述:

我正在尝试为我的一门课程完成一个问题,它围绕着哪种关系是最好的解决方案-二元或三元。

I am trying to complete a question for one of my courses, and it revolves around which relationship is the best solution - binary or ternary.

关系示例

这是一家视频商店,拥有三个实体-视频,会员和休闲者。

So it is a video store, with three entities - Video, Member, and Casual.

会员和休闲者可以借阅视频,并记录借阅日期。

Members, and Casuals can borrow videos, and the date it was borrowed is recorded.

三元关系是否是最合适的解决方案,因为成员和临时借用视频之间没有区别?

Would a ternary relationship be the most suitable solution, as there is no distinction between a member and a casual borrowing a video?

您认为 Borrows钻石代表什么三元(3实体)关系?它介于成员客户,视频,临时客户和贷款日期之间。 会员在LOANDATE向CASUAL借了VIDEO吗? VIDEO是在LOANDATE出生的普通打卡会员吗? 在LOANDATE和CASUAL上到期的MEMBER借用视频为空,或者在LOANDATE和MEMBER上到期的CASUAL借用视频为空?与左&每个同上正确的二进制借用关系。

What ternary (3-entity) relationship do you consider the "Borrows" diamond to stand for? It's between a member client, a video, a casual client and a loan date. "MEMBER borrowed VIDEO from CASUAL on LOANDATE"? "VIDEO is of CASUAL punching MEMBER born on LOANDATE"? "MEMBER borrowed VIDEO due on LOANDATE and CASUAL is null or CASUAL borrowed VIDEO due on LOANDATE and MEMBER is null"? Ditto for each of the left & right binary "Borrows" relationships.

(我使用的是谓词(由列参数化的语句模板)来表达a的含义当插入一行时,您会得到一个命题(语句)。每个表(基础或查询结果)都包含将其谓词变为真实命题的行。关系运算符(join,union,等)选择以使用所需查询谓词的逻辑非终端(AND,OR等)来表达和计算谓词表达式。)

(I am using a predicate (statement template parameterized by columns) to express the "meaning" of a table. When you plug in a row you get a proposition (statement). Every table (base or query result) holds the rows that make its predicate into a true proposition. Relation operators (join, union, etc) are chosen to alternatively express, and to calculate, predicate expressions using logic non-terminals (AND, OR, etc) of a desired query predicate. )

有一颗钻石。它必须代表MEMBER,VIDEO和CASUAL实体加上LOANDATE之间的关系。对于三元借贷似乎很难提出一个明智的选择,不是吗?如果您想不到的话,那不是描述您情况的图表。我也无法想到仅限于这三种实体的三胞胎。

The diagram has a diamond. It has to stand for a relationship between MEMBER, VIDEO and CASUAL entities plus LOANDATE. It does seem hard to come up with a sensible one for the ternary Borrows doesn't it? If you can't think of one, then that's not a diagram that describes your situations. I can't think of one that is limited to triplets from those three kinds of entities either. Whereas the binaries make sense easily.

PS 我唯一的警告是:我给出的第三个选择实际上是数据库表中体现的典型关系。但这不仅与模型实体有关。它还涉及空值。如果我们认为这些关系是在标识实体的值之间,或者没有,那么我们可以使用空值。

PS My only caveat is: The third option I gave really is a typical relationship as embodied in database tables. But it isn't a relationship just on entities of the model. It also involves a "null" value. If we consider the relationships to be among values that identify entities or don't, then we can have that relationship that's using null.

Borrows:
    "MEMBER borrowed VIDEO due on LOANDATE and CASUAL is null
    or CASUAL borrowed VIDEO due on LOANDATE and MEMBER is null"
MEMBER  VIDEO   CASUAL   LOANDATE
=================================
  1       a      null    1/1/2000
  2       b      null    1/2/2000
 null     c    1234567   2/3/2000

我不知道您的老师打算什么。但是我怀疑他们不希望您涉及null。

I don't know what your teachers intended. But I suspect that they didn't expect you to involve null.

PPS Re二进制关系是否存在成员和成员之间的问题? CASUAL可以同时借用同一视频吗?我不确定您在想什么。但是,该关系仅包含根据其语句模板做出真实语句的行。它描述了情况。它不能使情况成为某种方式。 业务规则(和物理学!)限制了出现的情况。但是您确实需要记录足够的信息来开展业务。并且可以告知DBMS不可能的数据库状态,以便可以拒绝它们。

PPS Re "Would the binary relationship have a problem where a MEMBER and a CASUAL could BORROW the same VIDEO at the same time?" I'm not sure what you are thinking. But the relationship just contains the rows that make a true statement from its statement template. It describes the situation. It cannot cause the situation to be a certain way. The "business rules" (and physics!) limit the situations that arise. But you do need to record enough information to run the business. And the DBMS can be told about impossible database states so it can reject them.