Current location: Hot Scripts Forums » Other Discussions » Database » Primary Key/Foreign Key relationships using phpMyAdmin

Primary Key/Foreign Key relationships using phpMyAdmin

Reply
  #1 (permalink)  
Old
Wannabe Coder
 
Join Date: Jan 2009
Location: Beverley, England
Posts: 132
Thanks: 5
Thanked 2 Times in 1 Post
Primary Key/Foreign Key relationships using phpMyAdmin

Hi,

Could someone who is familiar with the phpMyAdmin interface (or MySQL in general), tell me whether or not primary keys also need to be indicated as foreign keys within the relevant table.

For example:

Table A

client_id (primary key)
name
email
password

Table B

upload_id (primary key)
client_id (foreign key)
description
file_size

In the above scenario, client_id in Table B is a of course a foreign key, as it lies in a child table that belongs to the parent table: Table A.
However, does 'client_id' in Table A, therefore also need to be indicated as a foreign key (in effect becoming both a primary and a foreign key) ?

I'm just curious, because I don't want to build the database, if afterwards it turns out I've made an error with this.

This is a bit of a silly question I guess...but it is one of those 'should be simple to answer' ones that has been bugging me.

thanks
Reply With Quote

Featured Marketplace Scripts (view more)

  #2 (permalink)  
Old
Wannabe Coder
 
Join Date: Jan 2009
Location: Beverley, England
Posts: 132
Thanks: 5
Thanked 2 Times in 1 Post
I guess this was a stupid question.....I am assuming the answer is that client_id doesn't need to be set as a 'reverse' foreign key in table A....
Reply With Quote
  #3 (permalink)  
Old
Newbie Coder
 
Join Date: Dec 2008
Location: United States
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Your assumption is correct and the setup looks correct with the one to many link.
Reply With Quote
  #4 (permalink)  
Old
Wannabe Coder
 
Join Date: Jan 2009
Location: Beverley, England
Posts: 132
Thanks: 5
Thanked 2 Times in 1 Post
Thanks

thanks Hopper
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2-3 Tree implementation ShrpSight Everything Java 3 04-30-12 05:37 AM
Hello all, can you help me? K4ot1K Other Languages 2 01-23-09 05:23 AM
Iterating Associative arrays with foreach divya PHP 13 11-21-07 01:12 PM
Reset the primary key in access zoliky Database 2 02-13-07 05:37 PM
About Primary Key silvercover Database 1 08-30-06 02:28 PM


All times are GMT -5. The time now is 01:11 PM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.