Explore the question in detail with explanation, related questions, and community discussions.
In a database, a foreign key is a field or a set of fields in one table that refers to the primary key in another table. Unlike primary keys, a foreign key does not have to be unique. In fact, it often contains duplicate values because multiple records in one table can refer to the same record in another table.
For example, in an Orders table, the CustomerID field may be a foreign key that refers to the ID in the Customers table. Many orders can be placed by the same customer, so the CustomerID (foreign key) can appear multiple times in the Orders table.
Discussion
Leave a Comment