×

Notice

The forum is in read only mode.

How does a foreign key help?

More
3 months 2 days ago #3302 by Elias Katsaniotis,MSc
How does a foreign key help?
More
3 months 2 days ago - 3 months 2 days ago #3303 by Elias Katsaniotis,MSc
The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables. A FOREIGN KEY is a field (or collection of fields) in one table, that refers to the PRIMARY KEY in another table (google).

If you have the header Orders Table, then at the Detail Orders Table must exist the Primary Key of an order as foreign key in order to be a relation for the two tables. So we know what are the products of this order, the detal table includes one record per product ( if this producy has 3 products we may have quantity 3, but one row).We can not delete the Header order if there are record(s) in the Detail Order, and we know this from Foreign Key ( of course we may use DELETE CASCADE).I hope to help
Last edit: 3 months 2 days ago by Elias Katsaniotis,MSc.
Time to create page: 0.077 seconds

Site Info

V. Katsanioti,

Russia,

Kaliningrad Oblast.

matizegr@yahoo.com

Visit counter

United States of America (the) 80.6% United States of America (the)
Russian Federation (the) 11.1% Russian Federation (the)
China 4.9% China

Total:

33

Countries
00001847
Today: 17
Yesterday: 55
This Week: 72
Last Week: 565
This Month: 1,767
Last Month: 81

Who's Online

We have 365 guests and no members online