Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

banking database design issue

I'm trying to build a database for banking I created a table for every account loan, deposit , checking account and also for payment methods checks, debit cards and cash.

My question is that how should I handle transactions between the tables knowing that the transactions are possible between all the tables?

For example customer can withdraw money using debit card, transfer money from checking account to loan or deposit money to checking using a check.

My first solution is to create one transaction table for all the transactions and the Cardinality (0...1 n ) so that only one type of payment and one account, so should I go with it or just create a transaction table for every relationship between two tables?

like image 701
user2231157 Avatar asked Oct 21 '22 13:10

user2231157


1 Answers

If "I created a table for every account, loan, deposit , checking account" means that you have more than four tables then you are doing something very very wrong. You should have one table for customers and one table for transactions. A transaction is money moving from one account to another account, so a simple transaction table would have the fields id, transaction date, credit account, debit account, amount. In accountancy, there are frequently transactions which involve several credit and debit accounts so these can't be maintained in the simple transaction scheme outlined above.

If you want to represent loans, then you'll probably need two more tables: one table contains the atomic details of all the loans (date given, account of the loanee, total amount, nominal interest rate, etc) and the other table contains the projected repayments of each loan.

There is no need for further tables representing deposits or checking accounts: these can be represented as accounts, with a type field designating which kind they are.

like image 133
No'am Newman Avatar answered Oct 29 '22 23:10

No'am Newman