Our website is made possible by displaying online advertisements to our visitors.
Please consider supporting us by disabling your ad blocker.

Responsive image


Foreign key

A foreign key is a set of attributes in a table that refers to the primary key of another table, linking these two tables. In the context of relational databases, a foreign key is subject to an inclusion dependency constraint that the tuples consisting of the foreign key attributes in one relation, R, must also exist in some other (not necessarily distinct) relation, S; furthermore that those attributes must also be a candidate key in S.[1][2][3]

In other words, a foreign key is a set of attributes that references a candidate key. For example, a table called TEAM may have an attribute, MEMBER_NAME, which is a foreign key referencing a candidate key, PERSON_NAME, in the PERSON table. Since MEMBER_NAME is a foreign key, any value existing as the name of a member in TEAM must also exist as a person's name in the PERSON table; in other words, every member of a TEAM is also a PERSON.

Important points to note:-

  • The reference relation should already be created.
  • The referenced attribute must be a part of primary key of the referenced relation.
  • Data type and size of referenced and referencing attribute must be same.
  1. ^ Coronel, Carlos (2010). Database Systems: Design, Implementation, and Management. Independence KY: South-Western/Cengage Learning. p. 65. ISBN 978-0-538-74884-1.
  2. ^ Elmasri, Ramez (2011). Fundamentals of Database Systems. Addison-Wesley. pp. 73–74. ISBN 978-0-13-608620-8.
  3. ^ Date, C. J. (1996). A guide to the SQL standard. Addison-Wesley. p. 206. ISBN 978-0201964264.

Previous Page Next Page