![]() To reflect this in the database, a foreign key column is added to the ORDER table (e.g., CUSTOMERID), which references the primary key of CUSTOMER (e.g. Suppose the business requires that each order must refer to a single customer. įor example, consider a database with two tables: a CUSTOMER table that includes all customer data and an ORDER table that includes all customer orders. īecause violations of these constraints can be the source of many database problems, most database management systems provide mechanisms to ensure that every non-null foreign key corresponds to a row of the referenced table. 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.
0 Comments
Leave a Reply. |