August 13, 2009 at 9:59 pm
I am a web developer trying to become a better database designer. I have been reading about keeping away from lookup tables. I need some help to figure out to do that considering my current DB has alot of them.
I have two tables a user table and a group table. All groups must have at least one user, but a user does not have to belong to a group. These are sample tables and both tables have more columns.
Users
--------
uID(INT) Primary Key
userName(VARCHAR(50))
Group
---------
gID(INT) Primary Key
groupName(VARCHAR(50))
UserGroupLookup
--------------------
uID(INT)
gID(INT)
I need to be able to scale to have thousands of groups and a million + users. I have the lookup table to allow for quick sorting so when gID = 2 is viewed then all the users can be quickly found and user data joined.
Thanks for your help!
-Josh
August 14, 2009 at 12:44 am
josh.d.kelly (8/13/2009)
I am a web developer trying to become a better database designer. I have been reading about keeping away from lookup tables.
Do you have a URL where you've been reading that misinformation? I'd like to get kick the slats out of someone's fence for giving that bad advice. The tables you've show are pretty much properly normalized. Any changes would make your tables much less proper and much more difficult to manage in the future.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 14, 2009 at 3:49 am
josh.d.kelly (8/13/2009)
I am a web developer trying to become a better database designer. I have been reading about keeping away from lookup tables. I need some help to figure out to do that considering my current DB has alot of them.
I suspect this is just a terminology problem. The term "lookup table" rarely seems to be precisely defined and certainly means different things to different people. Most often it is used to mean a table that is referenced by a foreign key. For the record, there is nothing inherently wrong with having tables referenced by a foreign key!
In the Microsoft Access world "lookup table" can imply something else: lookup fields. The use of that feature in Access is indeed widely discouraged and that may be what you have been reading about.
My advice is to base your database on good design principles like normalization and try to avoid vague terms like "lookup table".
August 14, 2009 at 7:43 am
To summarize what I think that we all agree on: What you have is fine and there is no apparent reason to change it.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
August 14, 2009 at 8:09 am
I'd agree with Mr. Moden and Mr Young on using lookup tables. And I'd encourage one of them to write something up on this.
Josh, If you have a URL, we'd like to see it and try to write something against it.
August 14, 2009 at 8:24 am
Add another vote of confidence supporting you for doing well on your initial design. Now don't mess with it. There's nothing wrong with using lookup tables. As a matter of fact, everything is right about using lookup tables. Stick with them. You get better data integrity and less programming headaches.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
August 14, 2009 at 9:49 am
Thank you for your replies. I was getting confused about the terminology and couldn't find the answer. So thank you very much. I will continue to create tables like this. As soon as I have the site live I will reply back so you can see the pieces come together and then let me know how I did.
Thanks!
Josh
August 14, 2009 at 10:39 am
In this table
UserGroupLookup
--------------------
uID(INT)
gID(INT)
Do the columns need to be foreign keys?
Thanks
August 14, 2009 at 10:46 am
They don't NEED to, but they probably should be. That will help keep away from "orphans".
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
August 14, 2009 at 10:49 am
I agree with Matt. Need is a big word. I'd say they should be and are probably also the primary key & clustered.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 10 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply