Foreign Key in DBMS (original) (raw)

Last Updated : 6 Jan, 2026

Foreign keys are a set of constraints in DBMS that establish relationships between tables and also ensure consistency and integrity of data.

Syntax For Creating and Deleting Foreign Key

Let’s see the Foreign Key syntax used for creating a table.

**Syntax for Creating Foreign Key:

**CREATE TABLE Child_table_name (

Child_Column1 data_type,

Child_Column2 data_type, ...,

**FOREIGN KEY (Child_foreign_key_column)

**REFERENCES referenced_table_name (referenced_primary_key_column) );

Below syntax is used to delete the foreign key in DBMS.

**Syntax for Dropping Foreign Key:

**ALTER TABLE Child_table_name

**DROP FOREIGN KEY Child_foreign_key_name;

Example

foreign_key

Foreign Key Example

It means that dept_id field of employee_info table can have only those value which are present in dept_id field of department_info table.

Need of Foreign Keys in DBMS

Foreign keys plays a major role in database management systems (DBMS) for the following reasons:

To Read more about SQL FOREIGN KEY Constraint Refer, Here.