Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2008

    Red face Unanswered: Primary key in muliple tables

    Hello everbody i am new in this forum and new to in database also.

    I am now designing a database where i have 6 tables like

    1.Cashdeposit (accountno,customerId,amount,date,message)

    2.Cashwithdraw (accountno,customerId,amount,date,message)

    3.Loanrequest (accountno,customerId,amout,duration,date,message)

    4.Loanpayment (accountno,customerId,amout,duration,date,message)

    5.Transferamount(accountno,customerId,amout,destin ationaccountno,

    6.Payment (accountno,customerId,amout,duration,date,message) .

    The thing is that i am facing problem with fixing the primary key and foreign key. Because in all the tables i have the same fields. Now if i think
    "accoutno" is the primary key then for every table it will be the primary key. So, it is possible to take the same key as a primary key for those tables. Please anwer me because i am facing with the problem.
    Or how should i solve that problem.

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    yes, accountno can be the PK in each of those tables

    however, if it is, then there can be only one cashdeposit per account, only one cashwithdraw per account, and so on

    why are these separate tables? it seems to me like you should have only 1 table, not 6 | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2008
    Basically, I have six php pages for six tables where pages are taking inputs and inserting those in mentioned fields in the six tables. That's why i am planning to include 6 different tables against six php pages. If i make one table then how should i take inputs from 6 different pages only in one table. Still i am not clear about that one. Please if possible help me.

Posting Permissions

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