View Full Version : Simple Banking database

12-31-2011, 07:23 PM
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 ?

01-01-2012, 08:31 AM
show us what you've tried.

01-01-2012, 02:08 PM
I created those tables, but i think i should relate table Client with another table , what would u suggest .

create table Branch (
BranchID int,
BranchCity varchar(30),
Primary key (BranchID)

create table Account (
AccountID int,
BranchID int,
AccountNr varchar(20),
Accounttype varchar(15),
Balance int,

Primary key(AccountID),
Foreign key(BranchID) references Branch(BranchID)

create table Client(
ClientID int,
ClientName varchar(30),
ClientSurname varchar(30),
ClientTown varchar(20),
primary key (ClientID)

create table transaction(
TransID int,
TransType varchar(2),
TransAmount int,
AccountID int,
primary key (TransID),
foreign key (AccountID) references account (AccountID)

Old Pedant
01-02-2012, 01:06 AM
You could relate client to branch, as most banks assign a client to a single branch, but from a database standpoint that's not needed.

If you do it, just add

Branch ID INT REFERENECES Branch(BranchID)
to the clients table.