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

Database Sharding
A horizontal scaling strategy that distributes data across multiple database servers based on a partition key.
Partitioning
A technique of dividing large database tables into smaller, more manageable segments while maintaining a single logical table.
Replication
The process of copying and maintaining database data across multiple servers for redundancy, failover, and read scaling.
Deadlock
A situation where two or more transactions permanently block each other by each holding locks that the other needs.
Trigger
A database object that automatically executes a specified function when certain events (INSERT, UPDATE, DELETE) occur on a table.
ORM (Object-Relational Mapping)
A technique that lets you interact with a database using object-oriented code instead of writing raw SQL queries.
View All Databases Terms โ†’