You are here:

MySQL/How to store Accounts transactions in DB



I am designing a small web application which will provide double entry system. Now I am confused that should I use only one column for Debit & Credit amounts or separate columns.

If I use separate columns for both debit & credit amounts, then as you know a single entry can have only debit or credit amount, so one column will always be null or zero.

On other hand if I use only one column than I have to store one amount as positive & other as negative. Which amount should be negative? debit or credit. Which is best practice.

Please provide some recommendations.


Firstly storing accounts in a db is a really bad idea. 1 for security and 2 if the db crashes the accounts are gone and the tax man would not accept this as a reason for loss of accounts.

Two columns would be best and have 0.00 in the one that's not required for that entry. This way the db can be added up correctly.


All Answers

Answers by Expert:

Ask Experts


stuart gregory


PHP html, xhtml, css coding and MySQL


My experiance is all first had as I am web developer and I have, and do build many websites all using php and mysql. This ranges from building a simple search engine to secure php login scripts. Some websites like are complete database driven websites.

I have a large number of websites which I host and maintain, such as.

Web application development. (Open University) BSC Honers Computing and development (Open University)

©2016 All rights reserved.