Author Topic: one question  (Read 3160 times)

ahmedghalep5

  • Newbie
  • *
  • Posts: 1
    • View Profile
one question
« on: October 21, 2009, 02:00:49 AM »
what is the primary key and the foriegn key
 


Mike

  • Administrator
  • Hero Member
  • *****
  • Posts: 2025
    • View Profile
Re: one question
« Reply #1 on: October 21, 2009, 06:36:28 AM »
what is the primary key and the foriegn key


http://psoug.org/reference/constraints.html

http://en.wikipedia.org/wiki/Foreign_key:

In the context of relational databases, a foreign key is a referential constraint between two tables.

The foreign key identifies a column or a set of columns in one(referencing) table that refers to a column or set of columns in another (referenced) table.

The columns in the referencing table must be the primary key or other candidate keyin the referenced table. The values in one row of the referencing columns must occur in a single row in the referenced table. Thus, a row in the referencing table cannot contain values that don't exist in the referenced table (except potentially NULL).

This way references can be made to link information together and it is an essential part of database normalization. Multiple rows in the referencing table may refer to the same row in the referenced table. Most of the time, it reflects the one (master table,or referenced table) to many (child table, or referencing table)relationship.