for save debit and credit in database programmer use diffrent logic some i will describe below.
AccountCode Debit Credit
----------------------------------------------------------
01001001 1000 0
or
AccountCode Amount
--------------------------------------------
01001001 1000
01001001 -1000
possitive for debit and negetive for credit.
or
AccountCode Type Amount
------------------------------------------------------------
01001001 1 1000
01001001 2 1000
type 1 means debit and type 2 means credit.
thanks and i welcome your further logics in comments.