๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout 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

SQL
Structured Query Language โ€” the standard language for managing and querying data in relational databases.
ACID
A set of four properties (Atomicity, Consistency, Isolation, Durability) that guarantee reliable database transactions.
MVCC (Multi-Version Concurrency Control)
A technique where the database maintains multiple versions of data to allow concurrent reads and writes without locking.
PostgreSQL
An advanced open-source relational database known for its reliability, feature richness, and standards compliance.
Upsert
A database operation that inserts a new row if it does not exist, or updates the existing row if it does.
JSONB
PostgreSQL's binary JSON data type that stores JSON documents with indexing, querying, and manipulation capabilities.
View All Databases Terms โ†’