MySQL Forums
Forum List  »  Newbie

Re: Why use JOINS when have FK
Posted by: Chad Bourque
Date: March 23, 2010 07:57AM

Andy,

A foreign key constraint is just that, a constraint. It prevents data from being added to the child table if it doesn't have a correlated row in the parent table. It also allows things to happen automatically. Like it can automatically update or delete data in the child table when parent table data is updated or deleted. It really doesn't have anything to do with querying the tables. Although, since indexes are required for the foreign key constraints, you do get the benefit of faster joins. The foreign key constraint can't possibly know how you want to join your tables in your query since in one query you may want an inner join and in the next query a left outer join or even a right outer join.

The foreign key constraint is for data integrity, not query magic. :)

HTH,
Chad

Options: ReplyQuote


Subject
Written By
Posted
March 23, 2010 05:11AM
Re: Why use JOINS when have FK
March 23, 2010 07:57AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.