MySQL Foreign Key

Profile picture for user arilio666

This one is also used to uniquely identify records or rows in another data table. It refers to the primary key in another table and acts as a link between two tables.

How to add Foreign Key in MySQL

emp_ID int ,
emp_fName varchar(255) NOT NULL,
emp_lName varchar(255) NOT NULL,
Age int
CHECK(Age <= 50)
FOREIGN KEY (emp_lName) References office_two(emp_lName)

This creates a foreign key constraint on emp_lName, referencing the office_two table.