数据库设计:会计交易表
将交易分录存储到复式记账会计数据库中。
我提出了两个解决方案选项 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从插入的角度来看,选项 1 可能会更有效一些。但由于大量会计交易将影响两个以上的账户,因此收益可能远低于 2:1。
对于这些更复杂的交易,选项 2 会更清晰。也就是说,会计师通常会发现三行
比两行
更清晰。有点不清楚如何将借方和贷方与单个帐户相匹配。也就是说,
可以表示为
但也有其他可能的方式来构造数据的数据模型 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
more clear than two rows
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,
could be represented as
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.
在一般会计数据库设计中,将借项和贷项存储在单个字段中(即选项 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.