Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database design: accounting transaction table

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
...
like image 943
001 Avatar asked Dec 11 '10 03:12

001


People also ask

How will you design database for accounting?

The process of designing database (for accounting) begins with a reality (or accounting reality) that is expressed using elements of a conceptual data model. The process of designing a database for accounting is best described through a flow chart (Figure : 14.4).

What is database design table?

The design process Gather all of the types of information you might want to record in the database, such as product name and order number. Divide the information into tables. Divide your information items into major entities or subjects, such as Products or Orders. Each subject then becomes a table.

What is database accounting?

A database is a shared collection of inter-related data tables which meet the various informational needs of an organization. Thus, an accounting database stores the accounting data. It is a collection of accounting data which is inter-related to depict the various aspects of the accounting information system.

What is database design with example?

Database design is the organization of data according to a database model. The designer determines what data must be stored and how the data elements interrelate. With this information, they can begin to fit the data to the database model. Database management system manages the data accordingly.


2 Answers

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.

like image 116
Justin Cave Avatar answered Oct 11 '22 10:10

Justin Cave


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.

like image 26
David Avatar answered Oct 11 '22 11:10

David