English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Please explain in simple terms.

Thanks

2006-07-17 12:42:34 · 2 answers · asked by Truth 2 in Computers & Internet Programming & Design

2 answers

Pick me Pick me...I know the answer.
Ok here we go...
Primany Key are basically "Unique" and "Not Null" in a table
Foreign Keys are just Primany Key in another table and basically used to create relationships.

Meaning....
In a databse, in a table, a primany key is required to uniquely identify each record or each row.
Consider example....
Table1: Teacher (Teacher ID will be primany)
Table2: Student (Here Student ID is primany for the table, but if a relationship has to be created, then Teacher ID in a Student table is a Foreign Key.
Teacher Table:
Teacher ID:
1
2
3
4
Student Table:
St. ID----Teacher ID
a----------1
b----------2
c----------1
d----------1 and so on.

Meaning there are unique teachers, but One unique student can have multiple teachers (a, c, d all have teacher 1)

Trust me I passed school with this answer... :)
Ohh and "Not Null" i mentioned above means... Primany Key in a table cannot be left empty. Its like Indexing. It should have a value.

2006-07-17 12:55:56 · answer #1 · answered by rpkeskar 2 · 0 0

lets say your are a shop who has customers stored in a customer table ( id,name,address) you would probably make the primary key for that table the ID ( could be their telephone number ). Then you have another table which is the history of sales.( who bought what) , a secondary key in that table could be th eID of the customer). the two tables could be joined by the primary key (ID) in the customer table , and the forewign key in the sales history table.

2006-07-17 12:56:32 · answer #2 · answered by howlingengines 4 · 0 0

fedest.com, questions and answers