ER 数据模型 - 被图表混淆

发布于 2024-08-21 15:14:45 字数 533 浏览 3 评论 0原文

我对此图有点困惑 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 行?

来源:http://www.tdan.com/view-articles/5227/

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?

Source: http://www.tdan.com/view-articles/5227/

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

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

发布评论

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

评论(3

你的心境我的脸 2024-08-28 15:14:45

原则上,任何明智的设计都不会将两个不同的数据值(例如“借方条目”和“贷方条目”)放在同一列中。

看起来“借方分录”和“贷方分录”框是从“会计分录”表“继承”的表。我的解释是“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.

装迷糊 2024-08-28 15:14:45

这有点模糊,因为文章一直在谈论超类型和子类型,但从未真正说明哪些可能的方法在数据库中实现继承的意思。

但总的来说,文章指出:

一笔会计交易必须由一个或多个借方分录组成,并且必须由一个或多个贷方分录组成。

对我来说,这看起来和听起来就像引用同一个表的两个外键:

create table accounting_transaction (
    id integer primary key,
    date date not null,
    description text
);
create table accounting_entry (
    id integer primary key, 
    amount float not null,
    operator text,
    credit_id integer references accounting_transaction(id),
    debit_id integer references accounting_transaction(id)
);

具有适当的约束,确保文本中所述的条件。但当然还有更好的设计方法。例如:

create table accounting_entry (
    id integer primary key, 
    amount float not null,
    operator text,
    entry_type integer,
    transaction_id integer references accounting_transaction(id)
);

entry_type 表示贷方或借方,以及适当的约束。

编辑:通常,您会期望这种 ERD 表示一种不同类型的关系:从集合到固定数量的相同类型但在集合上下文中具有不同含义的组件。典型的例子是一个航段,只有一个出发机场和(希望)只有一个目的地机场,当然机场就是机场。

create table flight_leg(
    id integer primary key,
    departure_airport integer references airport(id),
    destination_airport integer references airport(id)
);
create table airport(
    id integer primary key,
    iata_code varchar(3) not null,
    name text
);

请注意谁引用谁的区别。对于本文中的模型,这意味着 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:

An accounting transaction must be composed of one or more debit entries and it must be composed of one or more credit entries.

To me this looks and sounds like two foreign keys that reference the same table:

create table accounting_transaction (
    id integer primary key,
    date date not null,
    description text
);
create table accounting_entry (
    id integer primary key, 
    amount float not null,
    operator text,
    credit_id integer references accounting_transaction(id),
    debit_id integer references accounting_transaction(id)
);

with appropriate constraints ensuring the condition stated in the text. But of course there are better ways of designing this. For example:

create table accounting_entry (
    id integer primary key, 
    amount float not null,
    operator text,
    entry_type integer,
    transaction_id integer references accounting_transaction(id)
);

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.

create table flight_leg(
    id integer primary key,
    departure_airport integer references airport(id),
    destination_airport integer references airport(id)
);
create table airport(
    id integer primary key,
    iata_code varchar(3) not null,
    name text
);

Note the difference in who references whom. For the model in the article this would mean that an accounting_transaction references exactly one debit_entry and exactly one credit_entry, which doesn't seem to be what the author intended.

べ映画 2024-08-28 15:14:45
create table accounting_entry (
    id integer primary key, 
    amount float not null,
    operator text,
    credit_id integer references accounting_transaction(id),
    debit_id integer references accounting_transaction(id)
);z

<--- 我一开始也这么认为,但仔细观察“ACCOUNTING_TRANSACTION”表,让单个交易关系同时“贷方和借方”并没有真正意义。

因此,“DebitEntry”和“CreditEntry”实际上是两个单独的表,但它们引用相同的“会计事务 ID”,这是有意义的,“会计事务必须由一个或多个借方条目组成,并且必须由一个或多个借方条目组成”更多信用条目。”

示例

>>ACCOUNTING_ENTRY_DEBIT
ID---ACCOUNTTRANSACTIONID-----ACCOUNTID---------AMOUNT-----OPERATOR
102--------2------------------------1---------------1,000-----Plus

>>ACCOUNTING_ENTRY_CREDIT
ID---ACCOUNTTRANSACTIONID-----ACCOUNTID---------AMOUNT-----OPERATOR
105--------2------------------------2---------------1,000-----Minus
create table accounting_entry (
    id integer primary key, 
    amount float not null,
    operator text,
    credit_id integer references accounting_transaction(id),
    debit_id integer references accounting_transaction(id)
);z

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

>>ACCOUNTING_ENTRY_DEBIT
ID---ACCOUNTTRANSACTIONID-----ACCOUNTID---------AMOUNT-----OPERATOR
102--------2------------------------1---------------1,000-----Plus

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