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?...
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?...
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.
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.
...uhh looks blur a little bit but thank you for the explaination ..
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.