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 |
|
echo88
Starting Member
4 Posts |
Posted - 2009-07-31 : 15:49:49
|
| Some one is telling that is "better design" to have one query the keys of relationship table and have another query that queries on those instead of one single query using INNER JOIN?? SO lets say Table A has QID,ANSID - both are keys and B has ANSID, comment, date. I wanted all the records from B where QID=... I wanted to do SELECT * FROM B INNER JOIN A ON B.ANSID=a.ANSID , but he says that is bad database design is it would be more efficient or better to do something like SELECT ANID FROM A - then iterate through all of those values returned. I thought doing one query would be preferrable instead of 1+N queries. |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-07-31 : 16:16:05
|
| Unless there is something you are not mentioning, that is exactly the way a database should be designed and using INNER JOIN is way more preferable to N-number of queries. |
 |
|
|
echo88
Starting Member
4 Posts |
Posted - 2009-07-31 : 16:21:40
|
| Actually - he said I return the keys back to the web server and then N separate calls - I had a hard time accepting that and gave him the benefit of the doubt. He also said that view are bad as well. Is this guy a complete idiot or is there something I am missing... |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-07-31 : 16:36:24
|
| That sounds strange, but I have seen it done that way because it's "easier" for for an object to populate itself making a call for each object created (each key) rather then getting all the data and populated the objects that way.. It doesn't sound like he knows what he's talking about to me, but I also don't know what you are doing or how your system is designed. |
 |
|
|
|
|
|