Junior — Middle
Explain what a foreign key means in the context of databases.
sobes.tech AI
Answer from AI
A foreign key is a field or a set of fields in one database table that references the primary key of another table. It is used to establish and enforce a referential integrity between related tables. For example, if there is an Orders table with a customer_id field that is a foreign key referencing the id field in the Customers table, it ensures that each order is associated with an existing customer.