I am going to create a database for a double entry accounting system in MySQL.
I recently read an article: http://homepages.tcp.co.uk/~m-wigley/gc_wp_ded.html
I found in this article that it would be convenient to have three tables ACCOUNT, JOURNAL, and POSTING:
ACCOUNT(accountID, accountName) JOURNAL(journalID, journalType) POSTING(postingID, journalID, accountID, amount)
the article describes that if the account is debited, the value of the "amount" field will be positive, otherwise it will be negative.
Now for the POSTING table above, I have two other options.
(1) POSTING(postingID, journalID, accountID, isDr, amount)
in this option, the isDr field is logical. if the account is debited, the isDr field will be set to true, otherwise false. and the "amount" field will always have a positive value.
(2) POSTING(postingID, journalID, accountID, debitAmount, creditAmount)
here, if the account is debited, I will store the amount in the "debitAmount" field, otherwise I will save it in the "creditAmount" field.
so which one of the three is better to use?