Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqlclarify
Yak Posting Veteran
56 Posts |
Posted - 2008-09-17 : 17:20:41
|
| I have 5 tables. A,B,C,D,EI have joined them in the following way..A->BB->CC->DD->EIf I join them as A->BA->CA->DA->Ewill that change the meaning of the query? |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-09-17 : 18:27:13
|
it depends on what columns you are joining on. elsasoft.org |
 |
|
|
sqlclarify
Yak Posting Veteran
56 Posts |
Posted - 2008-09-19 : 13:29:52
|
| A contains the foreign keys of B,C,D,E |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-09-19 : 13:34:57
|
how about you post the DDL for the tables, and the DML for query? elsasoft.org |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-20 : 02:07:18
|
quote: Originally posted by sqlclarify A contains the foreign keys of B,C,D,E
then you should be using the latter one |
 |
|
|
sqlclarify
Yak Posting Veteran
56 Posts |
Posted - 2008-09-20 : 21:47:25
|
| Why should we use the latter one? What difference does it make?Could you please explain the reasoning?I am new to databases so I would like to know why this makes a difference.Thank you! |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-09-20 : 23:13:22
|
Assuming they are all INNER JOINs (on the same columns with either method) then I don't believe the results will be different. Depending on the indexes, the optimizer may come up with a better plan one way or the other. You can always compare the results from both methods to see for yourself. Be One with the OptimizerTG |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-21 : 01:31:03
|
quote: Originally posted by sqlclarify Why should we use the latter one? What difference does it make?Could you please explain the reasoning?I am new to databases so I would like to know why this makes a difference.Thank you!
i told use latter one since you've specified A contains foreign keys of B,C,D & E. So the relationship will be A->B,A->C,A->D & A->E |
 |
|
|
|
|
|
|
|