SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Lookup Table Madness


Lookup Table Madness

Author
Message
DCPeterson
DCPeterson
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3521 Visits: 432
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/dpeterson/l

/*****************

If most people are not willing to see the difficulty, this is mainly because, consciously or unconsciously, they assume that it will be they who will settle these questions for the others, and because they are convinced of their own capacity to do this. -Friedrich August von Hayek



*****************/
Gary Perkins
Gary Perkins
SSC-Enthusiastic
SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)

Group: General Forum Members
Points: 100 Visits: 1

In my opinion, you got a bit wordy which meant your proof for your ideas was less clear.

Other than that, I agree with what you said. I believe most of the problems I have come across relate to the original code using a technique that is possible and works (just), but is not necessarily the best way of doing it. Database design can suffer in the same way and you highlighted a good example.


Dave Poole
Dave Poole
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16950 Visits: 3403

CREATE TABLE Code (
CodeID int IDENTITY(1,1)
, CodeType int
, Description varchar(255))

ALTER TABLE Code ADD CONSTRAINT PK_Code PRIMARY KEY (CodeID, CodeType)

I would put CodeID as the PRIMARY KEY and separate index on the CodeType field.

The reasons being that I may want a drop down box of all entries for a particular code type.

As CodeId is unique I don't have to worry about what type I am referencing in a PK->FK relationship.

If I have a database with a large number of "Lookup" tables but these table only hold a handful of records each then I will consider the "MUCK" approach.

If those lookup table contain a vast number of records then I keep them as individual tables because a MUCK table will slow the system down.

It really depends on who is going to be using the database and for what.



LinkedIn Profile
www.simple-talk.com
Jonr
Jonr
Mr or Mrs. 500
Mr or Mrs. 500 (552 reputation)Mr or Mrs. 500 (552 reputation)Mr or Mrs. 500 (552 reputation)Mr or Mrs. 500 (552 reputation)Mr or Mrs. 500 (552 reputation)Mr or Mrs. 500 (552 reputation)Mr or Mrs. 500 (552 reputation)Mr or Mrs. 500 (552 reputation)

Group: General Forum Members
Points: 552 Visits: 65
Completely agree, it's what's best suited to the app. being created.
I'd use Access (spit!) for certain things, but not for a serious app/site/amount of data.
I wouldn't expect to see the MUCK approach in a serious project, certainly not in a commercial project (though I have, and it did cause hideous problems).
For personal usage or a small group who understand the implications of what's being done it's fine.
But the problem is, these things often creep into production, or worse still, get taken as an acceptable example by people who don't know any better.
I think the main argument for always doing it the right way is that if the DBA can't be bothered to do it right on EVERY occasion, some developers will see it as an excuse for them to go down the same route, even though they may not understand the implications of doing so.
All comes down to education - the old saying 'A little knowledge is a dangerous thing' is probably most apt here...


Jon
RonKyle
RonKyle
SSCertifiable
SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)

Group: General Forum Members
Points: 7088 Visits: 3622
This is a superb explanation of the subject. I completely agree, and I like the logic used that makes it more than just an opinion. In the rarest of occassions, like an import database that is more a staging area for information rather than a proper OLTP database, I can see the use for a MUCK, but otherwise no.



SteveB-74825
SteveB-74825
Right there with Babe
Right there with Babe (750 reputation)Right there with Babe (750 reputation)Right there with Babe (750 reputation)Right there with Babe (750 reputation)Right there with Babe (750 reputation)Right there with Babe (750 reputation)Right there with Babe (750 reputation)Right there with Babe (750 reputation)

Group: General Forum Members
Points: 750 Visits: 1
I agree also, there have been many arguments that i've had with programmers about the design of the database being more important and this article gets it spot on.

cheers

dbgeezer
dm
dm
SSC Veteran
SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)

Group: General Forum Members
Points: 293 Visits: 1
A good article but your points got lost in the wordiness. A little brevity please.



YSLGuru
YSLGuru
SSCarpal Tunnel
SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)SSCarpal Tunnel (4.5K reputation)

Group: General Forum Members
Points: 4526 Visits: 1667

I believe the 'wordiness' of the article has left me confused as to exactly what the articles author's opinion is about lookup tables. Is he making the case that no lookup tables should be used or that no lookup tables that combine multiple objects be used? At the beginning of the article he listed 3 independent lookup tables and then further down he made the case that these 3 tables could be combined into a single lookup table since they shared the same structure. Is the author stating that the use of lookup tables as defined at the beginning with the 3 individual tables that contain 1 specific type of lookup value only not be used, that a table that is a combination of these 3 should not be used or that neither of these approaches should be used?

If someone could help clarify this for me I would be most appreciative.

Thanks

Ed



Kindest Regards,

Just say No to Facebook!
Adam Machanic
Adam Machanic
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3019 Visits: 714
I totally agree with your message, but please slow down when you write. Maybe make an outline first, and have a few people edit it for you. You clearly have some good points to get across. I'd like to see you express them effectively.

One problem in particular is that you present your 'MUCK' table (thing) later in the article than you do the properly normalized tables (EmployeeStatusCode, CustomerStatusCode, etc). This is confusing; think about the flow of the article: Introduce problem (MUCK); show example of problem (MUCK tables); introduce solution (normalization); show examples of normalization (normalized tables)...

Again, good effort; execution just needs a bit of work.

--
Adam Machanic
SQL Server MVP
SQLblog.com: THE SQL Server Blog Spot on the Web
tsg_jfigueroa
tsg_jfigueroa
Grasshopper
Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)

Group: General Forum Members
Points: 19 Visits: 2

"Wordiness" is no the only thing that makes this article confusing. The authors zealotry <g> makes it even harder to wade thru...

Instead of giving a "holier than thou" talk, try pointing out some of the reasons why this particular design was used and is used today, and how it can be abused, and not abused...

Code tables (MUCK tables...ahhh give it a rest) can be (and have been) an elegant solution to specific design issues...

Hierarchical data has always and will always be around, the author of the piece painted a very narrow minded "take" on it...

Next time, add some facts to your diatribe...

Cheers





Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search