🎁 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

Query Optimization
The process of improving database query performance through indexing, query rewriting, and schema design techniques.
ORM (Object-Relational Mapping)
A technique that lets you interact with a database using object-oriented code instead of writing raw SQL queries.
Row-Level Security (RLS)
A database feature that restricts which rows a user can access in a table based on security policies.
Elastic Search
A distributed search and analytics engine built on Apache Lucene, optimized for full-text search and log analysis.
JOIN
An SQL operation that combines rows from two or more tables based on a related column between them.
Database Constraint
Rules enforced by the database to maintain data integrity, including NOT NULL, UNIQUE, CHECK, PRIMARY KEY, and FOREIGN KEY.
View All Databases Terms →