Home > Ask the Oracle Experts > SQL Questions & Answers > Using a lookup table for a form select list
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Using a lookup table for a form select list

Rudy Limeback EXPERT RESPONSE FROM: Rudy Limeback

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 03 July 2003

In the world of my database application, a person has an ethnicity. The input for ethnicity comes from a fixed pick-list, with values like:

  • Black/African American
  • Native American
  • White/Caucasian
  • Southeast Asian
  • other Asian/South Pacific Islands
  • etc.

I can see a few ways of handling this:

  1. An "ethnicity" column of type TEXT in the People table, storing the exact values above. What worries me about this is the possibility of the UI developers making a seemingly innocent change to the values sent from the form, e.g. changing 'other' to 'Other' or adding a hyphen between Southeast and Asian, and thereby muddying the data.

  2. Similar to 1, but passing every value through a standardizing text formatter first, that might change all characters to lower case, and replace all consecutive non-letter characters with a single underscore. So the last example would become: 'other_asian_south_pacific_islands'. Problems: it's still not immune to spelling changes (e.g. 'Islands' to 'Islander'), and it's difficult to format the values back to their original format when queried for reports.

  3. Have the form send back numeric codes rather than text, and have the back-end software translate that to text before submitting it to the database. Possible disadvantage: the textual representation is now coded both into the UI's display and in the software.

  4. Create a separate Ethnicity table, with a unique numeric identifier column, and a TEXT column for the descriptive text. The form would send identifiers, which the back-end would store directly to the People table's ethnicity column (a foreign key to the new table's identifier column). Possible disadvantage: the textual representation is now coded both into the UI's display and the database. Queries also become somewhat more complicated.

Which would you favor?


>
EXPERT RESPONSE

Presumably there's a legitimate purpose for collecting and storing this information, most likely for some HR policy. Without controls of some kind on the valid options, the "garbage in, garbage out" rule will prevail. HR will therefore probably oppose any scenario where you cannot demonstrate that there is adequate control. On that basis, options 1 and 2 should be discarded.

Option 3 is on the right track, but success depends on the whims of both the UI developers and backend developers, and how well they communicate and coordinate their efforts when changes are required, not to mention the time and effort involved in making those changes. HR's not going to like this option either.

That leaves option 4. In this scenario, the Ethnicity table is an example of a lookup table. Not only does it make the People table smaller, but it affords total control, through relational integrity, over the valid options that can be selected. If a spelling change is required, or a new ethnicity option needs to be added, you make one change, in the lookup table, and you're done. Furthermore, you would give this administrative function to HR. The UI and backend developers are no longer involved, because the UI's display would be populated directly from the lookup table.

Are the queries somewhat more complicated? Well, yes, but only somewhat. A simple join. Hardly complicated at all.

For More Information


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
SQL
IN list or series of OR conditions?
Connecting tables in a database
SQL query for co-authored books
Querying complex derived tables
SQL string functions
Changing a NULL column to NOT NULL
SQL for hourly totals for the last 48 hours
LEFT OUTER JOIN to a MIN/MAX row
Normalizing a crosstab table
Querying metadata and data at the same time

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts