0

what is the difference between foreign key and joins?
when to use foreign key?
How foreign key works?
and
Is it better to use join rather than foreign key?..

can someone explain me this?...

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by uselessninja
0

Foreign keys are used at the database level and forces a link. Joins are used at your application level. You should have foreign keys when you setup your database to ensure every join will be valid.

0

A join is used in a query to retrieve data from more than one table based on a common element in the two tables. For example you might keep shipping addresses in one table and orders in another with a field in the order table holding the id of the address record it was shipped to. To print an order you could use a join to get the address data.

A foreign key is used to create a permanent link between two tables to prevent removal of important data. In the above example you might create a foreign key from the orders table to the shipping addresses specifying (constraining) that the address cannot be deleted if there are orders using the address.

0

...uhh looks blur a little bit but thank you for the explaination ..

Edited by uselessninja: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.