Page 1 of 1

How should I design my database?

Posted: Mon Mar 24, 2008 9:56 pm
by Sequalit
I need to be able to store transaction data, such as a deposit or a withdrawal. Both have 3 feilds, date, desciption, and amount.

Should I create two tables, a deposit table and a withdrawal table

Or have one table called transactions, that stores both, so it will have a fourth field called type(deposit or withdrawal)

What do I have to consider with going for one or the other?

Re: How should I design my database?

Posted: Mon Mar 24, 2008 10:32 pm
by Weirdan
I would have a single transaction table. Withdrawal records would have a negative amount, deposit - positive. This way it's easy to summarize actions taken on behalf of particular account, using sum() + group by.

Re: How should I design my database?

Posted: Tue Mar 25, 2008 2:24 pm
by Sequalit
k thanks.

Also this will allow me more flexibility such as if i wanted to add a type called bill :)