Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple Banking database

    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

  • #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,634
    Thanks
    4
    Thanked 148 Times in 139 Posts
    show us what you've tried.

  • #3
    New to the CF scene
    Join Date
    Aug 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    any suggestion

    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)
    )
    Last edited by xp_vista007; 01-01-2012 at 02:21 PM.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,733
    Thanks
    80
    Thanked 4,516 Times in 4,480 Posts
    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
    Code:
         Branch ID INT REFERENECES Branch(BranchID)
    to the clients table.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •