๐ŸŽ 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

CTE (Common Table Expression)
A temporary named result set defined within a SQL statement using the WITH clause, improving query readability and enabling recursion.
Soft Delete
A pattern where records are marked as deleted with a flag or timestamp rather than being physically removed from the database.
Prepared Statement
A pre-compiled SQL template that uses parameters instead of literal values, preventing SQL injection and improving performance.
EXPLAIN ANALYZE
A PostgreSQL command that shows the execution plan of a query along with actual runtime statistics for performance tuning.
ETL (Extract, Transform, Load)
A data pipeline process that extracts data from sources, transforms it into a suitable format, and loads it into a destination system.
PostgreSQL
An advanced open-source relational database known for its reliability, feature richness, and standards compliance.
View All Databases Terms โ†’