2.4k questions

2.4k answers

99.9k users

3 Online Users
0 Member 3 Guest
Today Visits : 1884
Yesterday Visits : 3909
Total Visits : 2580427

Categories

Notice

Dear All, These are my answers from Quora and primarily Google; please check the answer and from others sites; the answers are free and without any liability.To make a decision, write down all of the positives and negatives on a piece of paper.Thank you,

Elias Katsaniotis, MSc

Information

Viktoria Katsanioti,

Kaliningrad,

Russia,

matizegr@yahoo.com

0 votes
88 views

How does a foreign key help?
in General by

1 Answer

0 votes

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

by
...