Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database schema design for a double entry accounting system? [closed]

Does anybody know or have any links to websites describing details of how to design a database schema for a double entry accounting system ??.

I did find a bunch of articles but non were very explanatory enough. Would appreciate it if someone could help me on this.

like image 797
soden Avatar asked Mar 22 '10 17:03

soden


People also ask

What is database schema design?

Database schema design organizes the data into separate entities, determines how to create relationships between organized entities, and how to apply the constraints on the data. Designers create database schemas to give other database users, such as programmers and analysts, a logical understanding of the data.

What is the process of accounting data using the double-entry system?

Double-entry bookkeeping is a method of recording transactions where for every business transaction, an entry is recorded in at least two accounts as a debit or credit. In a double-entry system, the amounts recorded as debits must be equal to the amounts recorded as credits.

What is double-entry in database?

In a 'double entry' system each value is stored twice, once as a credit (a positive value), once as a debit (a negative value). There are a number of rules that control these values. These rules would be recognised by any trained accountant although they may not understand how it is stored in a relational database.

What is the format of double-entry system?

In a double-entry accounting system, transactions are composed of debits and credits. The debits and credits must be equal in order for the system to remain balanced. For example, if a business pays its electricity bill for $1,200, then it will record an increase to “utilities expense” and a decrease to “cash”.


1 Answers

Create the following tables

  • account
  • transaction
  • line_item
  • contact (can be a customer a supplier, or an employee).

To keep things simple, we will leave out the account_type table, contact_type table, etc.

Identify the relationships between the tables and set them up

  • a contact can have many transactions, but each transaction can only have one contact (one-to-many relationship)
  • an account can have many transactions, and one transaction can affect many accounts; line_item is the join table between transaction table and account table (a many-to-many relationship)
  • a transaction can have many line items, but each line item must relate to one transaction.

We have the following schema (a one-to-many relationship):

CONTACT ———< TRANSACTION ———< LINE_ITEM >——— ACCOUNT 

Add appropriate fields to each table

  • Contact
    • contactID
    • name
    • addr1
    • addr2
    • city
    • state
    • zip
    • phone
    • fax
    • email
  • Transaction
    • transactionID
    • date
    • memo1
    • contactID
    • ref
  • Line_item
    • line_itemID
    • transactionID
    • accountID
    • amount
    • memo2
  • Account
    • accountID
    • account_name
    • account_type

Create as many new transactions as needed

For example to add a new transaction in the database, add a new record in the transaction table and fill in the fields, select a contact name, enter a date, etc. Then add new child records to the parent transaction record for each account affected. Each transaction record must have at least two child records (in a double-entry bookkeeping system). If I purchased some cheese for $20 cash, add a child record to the transaction record in the child record, select the Cash account and record −20.00 (negative) in the amount field. Add a new child record, select the Groceries account and record 20.00 (positive) in the amount field. The sum of the child records should be zero (i.e., 20.00 − 20.00 = 0.00).

Create reports in the database based on the data stored in the above tables

The query to give me all records in the database organized so that transaction line item child records are grouped by account, sorted by date then by transaction ID. Create a calculation field that gives the running total of the amount field in the transaction line_items records and any other calculation fields you find necessary. If you prefer to show amounts in debit/credit format, create two calculation fields in the database query have one field called debit, and another called credit. In the debit calculation field, enter the formula "if the amount in the amount field from the line_item table is positive, show the amount, otherwise null". In the credit calculation field, enter the formula "if the amount in the amount field from the line-Item table is negative, show the amount, otherwise null".

Based on this rather simple database design, you can continuously add more fields, tables and reports to add more complexity to your database to track yours or your business finances.

like image 94
bkire Avatar answered Sep 22 '22 02:09

bkire