Database Interview Questions and Answers
<< Previous Question Next Question >>
 Question: 689 Page Views: 

How are Primary Key and Foreign key inter-related?



Posted By: Avi Date: 1 October 2010 11:07:06 AM
 Answer:

Primary Key is a column or combination of columns to have unique records in the table. There can only be one Primary Key in a table. A foreign key is a column or combination of columns to enforce a relation between the two tables. The Primary Key of table becomes the forign key in the second table. Such as if take an example there are two tables "Stud" and "result". Table 1 i.e. "stud" is having roll_number , name,class, as its fields. In this table the roll_number field is a Primary Key. Hence no two rows will have the same roll_number. Now in the second table i.e. "result" the fields are roll_number,sub1,sub2,sub3 and total. Here this table is related to "stud" table by making "roll_number " the foreign key.


Posted By: avibtech


Date: 1 October 2010 11:07:06 AM
Post a better Answer if you have
 
(Will show your Gravatar icon)  
  Country flag

Loading
Enter the text as shown in the image CVY0W4
Related Questions
Database : What do you mean by normalization?

What do you mean by normalization?

Basically normalization is a process in realational databse design to organise the data and avoid da....
Category: Database Date: 10/1/2010 10:56:06 AM
Database : I have 1-year gap between my 10th & 12th. So what should I answer regarding this?
Database : Explain Data Integrity?

Explain Data Integrity?

Data integrity means the correctness and consistency of data. Enforcing data integrity ensures the q....
Category: Database Date: 10/7/2009 4:43:37 AM
Database : How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?

How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?

One-to-One relationship can be implemented as a single table and rarely as two tables with primary a....
Category: Database Date: 10/7/2009 2:51:09 AM
Database : What is Database Denormalization?

What is Database Denormalization?

Database denormalization is the reverse process of database normalization. Denormalization is the pr....
Category: Database Date: 10/7/2009 2:29:21 AM