farrest.blogg.se

Mysql foreign key
Mysql foreign key






mysql foreign key mysql foreign key mysql foreign key

This rule is called a referential integrity constraint between the two tables. Since the purpose of the foreign key is to identify a particular row of referenced table, it is generally required that the foreign key is equal to the candidate key in some row of the primary table, or else have no value (the NULL value. The value or combination of values of candidate key attributes for any tuple cannot be duplicated for any other tuple in that relation. In database relational modeling and implementation, a candidate key is a set of zero or more attributes, the values of which are guaranteed to be unique for each tuple (row) in a relation. The table containing the foreign key is called the child table, and the table containing the candidate key is called the referenced or parent 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. 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. In simpler words, a foreign key is a set of attributes that references a candidate key. Another way to put it: In the context of relational databases, a foreign key is a set of attributes subject to a certain kind of inclusion dependency constraints, specifically a 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, and furthermore that those attributes must also be a candidate key in S. A foreign key is a set of attributes in a table that refers to the primary key of another table.








Mysql foreign key