ER 数据模型 - 被图表混淆
我对此图有点困惑 http://www.b-eye -network.com/images/content/i030ht0104.gif(文章中的最后一个图表)
1 - 在“ACCOUNTING ENTRY”表中,它显示“DebitEntry”和“CreditEntry” i) 是这两列还是
ii) 这是两行数据吗?或者 iii) 它是两个独立的表,Acounting_entry_credit 和 Accounting_entry_debit?
与“ACCOUNT”表相同的问题,它显示资产帐户、生计帐户、权益帐户?它们是 3 列还是 3 行?
im a little confused by this diagram http://www.b-eye-network.com/images/content/i030ht0104.gif (Last diagram in the article)
1 - In the "ACCOUNTING ENTRY" table it shows "DebitEntry" and "CreditEntry"
i) is this two column or
ii) is this two rows of data? or
iii) is it two separate tables on its own, Acounting_entry_credit and Accounting_entry_debit?
Same question with the "ACCOUNT" table, it shows asset account, livabilities account, equaity account? are they 3 columns or are they 3 rows?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
原则上,任何明智的设计都不会将两个不同的数据值(例如“借方条目”和“贷方条目”)放在同一列中。
看起来“借方分录”和“贷方分录”框是从“会计分录”表“继承”的表。我的解释是“DEBIT ENTRY”和“CREDIT ENTRY”都是包含 ID、AMOUNT 和 OPERATOR 列的表。然后,“ACCOUNTING TRANSACTION”表将引用这些表中的行。
因此,看起来每个大框定义了表的“类型”,每个嵌套框定义了 ERD 中的特定表。我猜他们是这样画的,这样他们就不必一遍又一遍地重复列定义。
然后,每个“帐户”类型(资产、负债和权益)都有一个 ID 和一个 COMMENT 字段。它们还与包含帐号和描述的“帐户类型”表有关系。
Principally, no sane design would ever put two different data values like "DEBIT ENTRY" and "CREDIT ENTRY" in the same column.
It looks like the "DEBIT ENTRY" and "CREDIT ENTRY" boxes are tables that 'inherit' from the "Accounting Entry" table. How I would interpret this is both "DEBIT ENTRY" and "CREDIT ENTRY" are tables that contain the columns ID, AMOUNT, and OPERATOR. Rows in these tables are then referenced by the "ACCOUNTING TRANSACTION" table.
So it looks like each large box defines a 'type' of table and each nested box defines a specific table in the ERD. I guess they drew it that way so they wouldn't have to repeat the column definitions over and over.
Then each 'Account' type (Asset, Liability, & Equity) has an ID and a COMMENT field. They each also have a relationship with the "ACCOUNT TYPE" table which contains the Account Number and a description.
这有点模糊,因为文章一直在谈论超类型和子类型,但从未真正说明哪些可能的方法在数据库中实现继承的意思。
但总的来说,文章指出:
对我来说,这看起来和听起来就像引用同一个表的两个外键:
具有适当的约束,确保文本中所述的条件。但当然还有更好的设计方法。例如:
entry_type
表示贷方或借方,以及适当的约束。编辑:通常,您会期望这种 ERD 表示一种不同类型的关系:从集合到固定数量的相同类型但在集合上下文中具有不同含义的组件。典型的例子是一个航段,只有一个出发机场和(希望)只有一个目的地机场,当然机场就是机场。
请注意谁引用谁的区别。对于本文中的模型,这意味着
accounting_transaction
恰好引用一个debit_entry
和一个credit_entry
,这似乎并不是什么作者的意图。It's a little murky because the article keeps talking about supertypes and subtypes and never really states which of the possible ways to implement inheritance in databases is meant.
But in general terms, the article states:
To me this looks and sounds like two foreign keys that reference the same table:
with appropriate constraints ensuring the condition stated in the text. But of course there are better ways of designing this. For example:
with
entry_type
signifying credit or debit, and again appropriate constraints.Edit: Normally, you'd expect an ERD of this kind to signify a different kind of relationship: that from a collection to a fixed number of components that are of the same type but have different meanings in the context of the collection. The classic example is a flight leg that has exactly one departure airport and (hopefully) exactly one destination airport, where of course an airport is an airport.
Note the difference in who references whom. For the model in the article this would mean that an
accounting_transaction
references exactly onedebit_entry
and exactly onecredit_entry
, which doesn't seem to be what the author intended.<--- 我一开始也这么认为,但仔细观察“ACCOUNTING_TRANSACTION”表,让单个交易关系同时“贷方和借方”并没有真正意义。
因此,“DebitEntry”和“CreditEntry”实际上是两个单独的表,但它们引用相同的“会计事务 ID”,这是有意义的,“会计事务必须由一个或多个借方条目组成,并且必须由一个或多个借方条目组成”更多信用条目。”
示例
<--- I thought it was like this at first too, but looking closely at "ACCOUNTING_TRANSACTION" table, it wouldnt really make sense to have a single transaction relationship to be "both credit and debit" at the same time.
So "DebitEntry" and "CreditEntry" are actually two seperate tables, but they reference the same "Accounting Transaction ID" which would make sense, "An accounting transaction must be composed of one or more debit entries and it must be composed of one or more credit entries."
Example