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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Optimal number of tables

Author  Topic 

tomcatuk
Starting Member

6 Posts

Posted - 2009-10-29 : 13:46:37
I want to build a query to return a lowest value from a range of values. My data is in two tables (same Db), the first table only has one record per item, but the second table may have multiple records for the same item, each with a different value.

If need be, I can break that second table up into multiple tables in which each item has just one record.

My question is, is it "better" to break up that second table, or is there no difference. I know it sounds like a dumb question. I'm right at the start here, and would like to get it right before jumping into building the query.

Andy Fletcher - just another blog.

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-10-29 : 14:35:52
Hard to say without knowing what the data/entites are.. but, it is probably correct to keep the second table as one.
Go to Top of Page

tomcatuk
Starting Member

6 Posts

Posted - 2009-10-29 : 14:47:32
Sorry, I probably didn't phrase the question as well as I should have. I'm primarily concerned with the efficiency of what I'm doing.

If I put it another way, is it more efficent the fewer the number of tables a query has to run through, regardless of whether it looks up multiple records (and retrieve values from them) from some of those tables. I thing you said "yes".

Andy Fletcher - just another blog.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-10-29 : 16:23:27
Hehe, well it all depends..

I'd say in, general, you want to normalize as much as possible and then unwind (denormalize) if needed. There are lots of variables, but try not to let the number of joins determine your schema.
Go to Top of Page
   

- Advertisement -