Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Foreign key
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Concept in database systems}} A '''foreign key''' is a set of [[Attribute (database)|attributes]] in a [[table (database)|table]] that refers to the [[primary key]] of another table, linking these two tables. In the context of [[relational database]]s, a foreign key is subject to an [[inclusion dependency]] constraint that the [[tuple]]s consisting of the foreign key attributes in one [[Relation (database)|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.<ref>{{cite book|last=Coronel|first=Carlos|title=Database Systems: Design, Implementation, and Management|year=2010|publisher=South-Western/Cengage Learning|location=Independence KY|isbn=978-0-538-74884-1|page=65}}</ref><ref name=elmasri>{{cite book|last=Elmasri|first=Ramez|title=Fundamentals of Database Systems|url=https://archive.org/details/fundamentalsdata00elma|url-access=limited|year=2011|publisher=Addison-Wesley|isbn=978-0-13-608620-8|pages=[https://archive.org/details/fundamentalsdata00elma/page/n101 73]β74}}</ref><ref>{{cite book|last=Date|first=C. J.|title=A guide to the SQL standard|year=1996|publisher=Addison-Wesley|isbn=978-0201964264|page=206}}</ref> In other words, a foreign key is a set of attributes that {{em|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.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)