Forum Moderators: coopster

Message Too Old, No Replies

Primary keys and Linked tables

A query on relationship between tables

         

DontheCat

7:11 pm on Aug 27, 2005 (gmt 0)

10+ Year Member



To populate my Members table let's say I have FormX that has the follwing Input fields -Name, Age and Country.

The Country is a Menu Field and the values get populated from another table, which have two colums, Country_ID and Country.

Which would be right thing to do? Populate Memers table with the Country_ID or Country? Is a Unique/Foriegn Key required when the Countries itself would be not be repeated and unique?

Thanks for the Support

arran

7:45 pm on Aug 27, 2005 (gmt 0)

10+ Year Member



Hi DontheCat,

The standard way to do this would be as follow:

Members(Name, Age, Country)
Country(ID, Name)

Where Members.Country references Country.ID (this is the foreign key relationship).

Another solution would be to remove the 'Country' table and simply store the country name in the 'Members' table, however, from a design perspective, the first solution is better.

arran.

DontheCat

8:01 pm on Aug 27, 2005 (gmt 0)

10+ Year Member



Thanks Arran,

Another solution would be to remove the 'Country' table and simply store the country name in the 'Members' table

What you are suggesting is that I list the Countries as Options in my Form itself and store directly into the DB? I thought of that, but I was a bit lazy. :-)