If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Primary key in muliple tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-20-08, 11:43
mkhasan mkhasan is offline
Registered User
 
Join Date: Jun 2008
Posts: 5
Red face 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,
date,message)

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.
Reply With Quote
  #2 (permalink)  
Old 06-20-08, 23:57
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 06-21-08, 05:40
mkhasan mkhasan is offline
Registered User
 
Join Date: Jun 2008
Posts: 5
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On