FOREIGN KEY

A foreign key is an attribute that is assigned to a column to ensure data integrity and implies a link between this column and a primary key or unique column of another table.
A table can contain several foreign keys.


The foreign key in a table is a column in a table that links records of one type with those of another type
Foreign keys create relationships between tables and help to ensure referential integrity.
Referential integrity ensures that every record in a database is correctly matched to any associated records.
Foreign keys help to promote referential integrity by ensuring that every foreign key within the database corresponds to a primary key.
Every time you create a foreign key, a primary key with the same name must already exist in another table.




CREATE TABLE MyProducts 
(
CONSTRAINT constraint_name FOREIGN KEY (ProductID) REFERENCES Products (ProductID)
ON UPDATE CASCADE
ON DELETE CASCADE
)

Relationshups are implemented in relationship databases to using foreign key/primary key relationships






© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext