
Foreign Key Constraint
A foreign key constraint is a rule in a database that links data between two tables to ensure consistency. It ensures that the value in a specific column of one table matches an existing value in a related column of another table, acting like a reference or "link." This prevents having records that point to non-existent data, maintaining data integrity. For example, in an orders database, an order must reference a valid customer ID; the foreign key ensures this relationship is always valid and consistent.