🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Databases Beginner

What is Foreign Key?

A column that creates a link between two tables by referencing the primary key of another table.

Foreign keys enforce referential integrity — ensuring relationships between tables remain consistent. For example, an orders table might have a customer_id foreign key referencing the customers table.

Foreign key constraints can specify behavior on delete/update: CASCADE (propagate changes), SET NULL, SET DEFAULT, or RESTRICT (prevent action). They are fundamental to relational database design.

Related Terms

Database Constraint
Rules enforced by the database to maintain data integrity, including NOT NULL, UNIQUE, CHECK, PRIMARY KEY, and FOREIGN KEY.
Index
A data structure that improves the speed of data retrieval operations on database tables at the cost of additional storage.
Write-Ahead Log (WAL)
A technique where changes are first written to a log before being applied to the database, ensuring crash recovery and data integrity.
Window Function
An SQL function that performs calculations across a set of rows related to the current row without collapsing the result set.
Migration
A version-controlled change to a database schema that can be applied and reversed systematically.
Time-Series Database
A database optimized for storing and querying timestamped data points like metrics, sensor readings, and event logs.
View All Databases Terms →