I have to create a simple bank database using MySQL, so i have to create tables and relationships between them (normalization).
I have created those tables :
Branch (BranchID, BranchPlace)
Account (AccountID, AccountNumber, AccountType, Balance)
Client (ClientID, ClientName, ClientSurname, ClientCity)
Transaction (TransactionID, TransactionType, Amount)
So i need defining primary keys and foreign keys, can anyone help me with this ?
Thanks
You will first need to better understand the business case to determine what relationships need to exist, but my basic suggestions would be:
- Add ClientID to the ‘Account’ table with the foreign key constraint: Account.ClientID => Client.ClientID
- Add AccountID and BranchID to the ‘Transaction’ table with the foreign key constraints: Transaction.AccountID => Account.AccountID, Transaction.BranchID => Branch.BranchID
With those changes you will know the applicable information for each transaction (account number, client, and branch).
Hope that helps!
Scott