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

Transaction
A sequence of database operations that are treated as a single unit โ€” either all succeed or all are rolled back.
Database Backup
The process of creating copies of database data to protect against data loss from failures, corruption, or human error.
SQL
Structured Query Language โ€” the standard language for managing and querying data in relational databases.
ORM (Object-Relational Mapping)
A technique that lets you interact with a database using object-oriented code instead of writing raw SQL queries.
Prepared Statement
A pre-compiled SQL template that uses parameters instead of literal values, preventing SQL injection and improving performance.
Database Connection Pooling
A technique that maintains a cache of database connections for reuse, reducing the overhead of creating new connections.
View All Databases Terms โ†’