November 6, 2005

One table to contain all lookup data

Between the world of CRUDs and maintaining lookup data, programming for multiple tables can be painful, and in many causes does assist with performance at all.

So in some scenarios is maybe a good idea to contain all reference data within one single table, ie tblReference.

refID refMneumonic refDescription refType
1 AMS Surgery Service
2 ENDO Endoscopy Service
3 J Ambulatory PatientType
4 E Emergency PatientType
5 ET EmergencyTemporary PatientClass

This design technique has a couple of advantages:

  1. First, it is very extensible when we come to the conclusion that we need to add a new type of reference data. Let’s say we just wanted to add the doctor numbers to this application.
  2. It is easier to maintain from a coding perspective. Imagine only one business model to handle all reference data with a gateway, bean, and DAO.

Posted by Elyse at November 6, 2005 9:20 AM
Comments

i fail to see exactly how extensible or easy-to-use this is, besides the fact that you 'might' have less code... even though I doubt the difference shd be anything significant

it also appears you are structuring your data to fit your code; imho, it shd be other way around... what this means is that, when minor things in your code change, you don't have to make changes to your data to make that fit too... as an example what happens when "Service" becomes "SVC"... hyphotetical, but possible :) ... before long, you'll start maintaining a reference table for reference types ... :P

there's value in keeping your code/data model as separate and as simple as possible :)

Posted by: eokyere at November 6, 2005 12:11 PM

I'm beginning to think that this approach is more popular than I would have thought. It seems like it would go against everything I know to mix all the different types of data, but I see it more and more in larger applications. I see you are using medical terms and the last place I saw this was in the Cerner Millennium system. Do you think there are performance gains as well to storing reference data in a single table?

Posted by: Steve House at November 7, 2005 7:43 AM

Hi Elyse,

I don't mean to be negative, but I think this style of DB design has flaws. It only works as long as the different types of "reference data" have the same taxonomy - in this case, a Mneumonic and a description.

1. What happens when I want to store State and Country data in the catch-all lookup table? Or ZIP codes, with lat and long info?

2. It sort of defeats the purpose of normalization to some degree - you wind up with a ton of duplicate strings in the "type" column. To fix this, you can add another table refLookupType, but then...when not just use real, entity-dedicated tables to begin with at that point?

I've been down the road with a very large application that did just what you're describing - the table became a mess, had tons of columns to hold entity-specific stuff, sometimes the columns held something nothing like what they were named because "we can just use this column for that," etc.

Posted by: Joe Rinehart at November 7, 2005 9:56 AM

I did the same thing 4 years ago to combat massive proliferation of lookups. I now have a 2,500 row lookuptable and this table contains the list of lookups as well (set refType='Valids' and refMnumonic='age_class' and refDecsription='Age Classes'. Then refType for the actual age classes is set to 'age_class' - So the code also maintains the list of lists. Also added a definition column and a flag to show or hide a row. My code can also handle addng the next sequence to a valids list - the refMneumonic may be numeric and not alpha-coded. Only have to be careful about deletes and refMnumonic changes

Posted by: Dave Watts at November 7, 2005 6:12 PM
Post a comment









Remember personal info?