数据库设计:会计交易表

发布于 2024-10-06 19:08:29 字数 357 浏览 1 评论 0原文

将交易分录存储到复式记账会计数据库中。

我提出了两个解决方案选项 1 和选项 2,我被告知大多数银行套餐选择选项 2 进行数据库设计。不过,相比选项 2,我更喜欢选项 1,因为它很有意义,而且效率更高!

即对于 2 次资金流动,选项 1 需要 2 条记录,而选项 2 需要 4 条记录。

我想知道为什么银行会选择选项2而不是选项1?这是什么原因?

Option 1)
TRANSACTION
Credit_AccountId
Debit_AccountId
Amount
...

Option 2)
TRANSACTION
AccountId
Amount
...

Storing the transaction entry into a double entry accounting database.

I came up with two solutions option 1 and option 2, I was told most banking package chooses option 2 for their database design. However I prefer option 1 over option 2 because it simply makes sense and it is more efficient!

I.e For the 2 movement of funds, option 1 requires 2 records vs option 2 requires 4 records.

I would like to know why the bank would choose option 2 over option 1? what is the reason for this?

Option 1)
TRANSACTION
Credit_AccountId
Debit_AccountId
Amount
...

Option 2)
TRANSACTION
AccountId
Amount
...

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

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

发布评论

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

评论(2

变身佩奇 2024-10-13 19:08:29

从插入的角度来看,选项 1 可能会更有效一些。但由于大量会计交易将影响两个以上的账户,因此收益可能远低于 2:1。

对于这些更复杂的交易,选项 2 会更清晰。也就是说,会计师通常会发现三行

  • 借方 A $100
  • 贷方 B $60
  • 贷方 C $40

比两行

  • 借方 A $60 贷方 B $60
  • 借方 A $40 贷方 C $40

更清晰。有点不清楚如何将借方和贷方与单个帐户相匹配。也就是说,

  • 借方 A $100
  • 借方 B $30
  • 贷方 C $60
  • 贷方 D $70

可以表示为

  • 借方 A $60 贷方 C $60
  • 借方 A $40 贷方 D $40
  • 借方 B $30 贷方 D $30

但也有其他可能的方式来构造数据的数据模型 2。

此外,如果您尝试通过聚合交易来确定特定帐户的当前余额,则选项 2 会更有效。

Option 1 will potentially be a bit more efficient from an insert perspective. But since a lot of accounting transactions are going to affect more than two accounts, the benefit is likely to be substantially less than 2:1.

Option 2 will be clearer for these more complex transactions. That is, an accountant would normally find three rows

  • Debit A $100
  • Credit B $60
  • Credit C $40

more clear than two rows

  • Debit A $60 Credit B $60
  • Debit A $40 Credit C $40

If you have multiple accounts on both sides, it would also be a bit unclear how to match up the debits and credits to a single account. That is,

  • Debit A $100
  • Debit B $30
  • Credit C $60
  • Credit D $70

could be represented as

  • Debit A $60 Credit C $60
  • Debit A $40 Credit D $40
  • Debit B $30 Credit D $30

but there are also other possible ways to construct the data for data model 2.

Additionally, option 2 is going to be more efficient if you're trying to determine the current balance of a particular account by aggregating the transactions.

神也荒唐 2024-10-13 19:08:29

在一般会计数据库设计中,将借项和贷项存储在单个字段中(即选项 2)是合乎逻辑且高效的,因为这将简化聚合、数字操作和报告。每个借记和贷记交易都应该附加一个日期时间字段,以过滤掉特定期间。从 Smashwords 获取这本书,标题为“会计数据库设计”。它提供了一些关于会计系统设计的好示例以及一些有趣的财务报告 SQL 查询。

In a general accounting database design, it is logical and efficient to store your debits and credits in a single fields (i.e. option 2), as this would simplify aggregation,number manipulations and reporting. There should be a datetime field attached to each debit and credit transactions to filter out a particular period. Get the book from Smashwords, titled, accounting database design. It provides some good samples on accounting system design and some interesting sql query for financial reporting.

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