How to create foreign key in MySQL?
A foreign key in MySQL is basically a column or group of columns in a table that does the work of linking to a column or group of columns in another table. This key generally places constraints on the data in the related table that usually allows MySQL to maintain referential integrity. The relationship that exists between the customer's table and the Orders table is basically one-to-many. And this is the relationship that has been established by the foreign key in the orders table that has been specified by the customer number column. The customer's table is also known as the parent table or referenced table, and the orders table is generally called as the child table or referencing table. How to create Foreign Key? In order to create this, the user has to use the basic syntax of defining a foreign key constraint in the CREATE TABLE or ALTER TABLE statement that is as depicted below: [CONSTRAINT constraint_name] FOREIGN KEY [foreig