<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.developerdotstar.com/community" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>developer.* Blogs - Ideal Design/Structure for Lookup Tables - Comments</title>
 <link>http://www.developerdotstar.com/community/lookup_table</link>
 <description>Comments for &quot;Ideal Design/Structure for Lookup Tables&quot;</description>
 <language>en</language>
<item>
 <title>Localization Strings</title>
 <link>http://www.developerdotstar.com/community/lookup_table#comment-7346</link>
 <description>&lt;p&gt;Support for multiple languages is an excellent suggestion, and one I will have to work into the main post at some point.&lt;/p&gt;
&lt;p&gt;My first reaction is that is depends on what kind of localization scheme you are using (assuming that is the context you have in mind). For example, I have seen many schemes where there is a localization token associated with a &quot;resource,&quot; which might be something that needs to appear in a label, or a descriptive field, or a dropdown list or listbox (all which could apply to lookup tables). So instead of, or in addition to, the Name and Description columns in the lookup table, you could have NameToken and DescriptionToken, and the middle or presentation tier in your system would translate that token to the appropriate language at runtime. Something like this:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;CustomerType&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CustomerTypeID&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CustomerTypeName&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DefaultName&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;NameToken&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DefaultDescription&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DescriptionToken&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Active&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DisplayOrder&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...etc...&lt;/p&gt;
&lt;p&gt;If instead you need your language support to be at the database level, you might create a Language lookup table with a row for each language you need; then you would have child table to the lookup table that had the lookup table&#039;s primary key as a foreign key. Then you could have an entry in the child table for translated value corresponding to the parent lookup table row, with of course a foreign key from the Language lookup table. Something like this:&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Language&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LanguageID&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LanguageName&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CharacterSet&lt;/p&gt;
&lt;p&gt;&lt;b&gt;CustomerType&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CustomerTypeID&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CustomerTypeName&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DefaultName&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DefaultDescription&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Active&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DisplayOrder&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...etc...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;CustomerTypeLanguage&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CustomerTypeLanguageID&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CustomerTypeID&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LanguageID&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TranslatedName&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;TranslatedDescription&lt;/p&gt;
&lt;p&gt;I introduced the &quot;Default&quot; idea because I encountered a high traffic web site once that served 98% of its pages in English, yet every single page view did a full localization lookup on every resource.&lt;/p&gt;
&lt;p&gt;Anyone else have thoughts on this one?&lt;/p&gt;
&lt;p&gt;Dan&lt;/p&gt;
</description>
 <pubDate>Wed, 21 Mar 2007 19:11:34 -0700</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">comment 7346 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Multiple Language Requirements</title>
 <link>http://www.developerdotstar.com/community/lookup_table#comment-7344</link>
 <description>&lt;p&gt;Useful article.  Any insight into best approach for handling multiple language requirements?&lt;/p&gt;
</description>
 <pubDate>Wed, 21 Mar 2007 15:38:45 -0700</pubDate>
 <dc:creator>Willy</dc:creator>
 <guid isPermaLink="false">comment 7344 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Display Logic</title>
 <link>http://www.developerdotstar.com/community/lookup_table#comment-7341</link>
 <description>&lt;p&gt;What happens when your client wants to support multiple languages? I generally do not like having display logic fields (name, sort order) in the database. These are view attributes and should probably be evaluated in the view layer.&lt;/p&gt;
</description>
 <pubDate>Wed, 21 Mar 2007 14:14:13 -0700</pubDate>
 <dc:creator>rgreathouse</dc:creator>
 <guid isPermaLink="false">comment 7341 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Table of Tables</title>
 <link>http://www.developerdotstar.com/community/lookup_table#comment-7340</link>
 <description>&lt;p&gt;I also found the term Table of Tables commonly used for what you describe as a MUCK table.&lt;/p&gt;
&lt;p&gt;-Rich&lt;/p&gt;
</description>
 <pubDate>Wed, 21 Mar 2007 13:26:08 -0700</pubDate>
 <dc:creator>Rich LaMarche</dc:creator>
 <guid isPermaLink="false">comment 7340 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>GUID PKs</title>
 <link>http://www.developerdotstar.com/community/lookup_table#comment-7321</link>
 <description>&lt;p&gt;Coincidentally, the very next day after I wrote about using GUIDs as primary keys, Jeff Atwood added a (per usual) &lt;a href=&quot;http://www.codinghorror.com/blog/archives/000817.html&quot;&gt;good article on the topic to the Coding Horror blog&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Dan&lt;/p&gt;
</description>
 <pubDate>Tue, 20 Mar 2007 16:25:42 -0700</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">comment 7321 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>MUCK Tables</title>
 <link>http://www.developerdotstar.com/community/lookup_table#comment-7318</link>
 <description>&lt;p&gt;Thank you, Ron, for that summary! I have encountered MUCK tables before in applications I have been tasked to maintain or rewrite (I&#039;ve also heard them called &quot;code tables&quot;). In fact, I&#039;ve seen some *huge* MUCK tables. The worst part of the evil is that (in the cases I&#039;ve seen anyway) you have no referential integrity at all.&lt;/p&gt;
&lt;p&gt;I&#039;m glad to know that I would probably agree with Don Peterson&#039;s article, though the term &quot;lookup table&quot; has always seemed a fine one to me.&lt;/p&gt;
&lt;p&gt;Dan&lt;/p&gt;
</description>
 <pubDate>Tue, 20 Mar 2007 11:27:30 -0700</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">comment 7318 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Lookup Table Madness</title>
 <link>http://www.developerdotstar.com/community/lookup_table#comment-7314</link>
 <description>&lt;p&gt;Thanks for the good article, Dan. About the only difference between your structure and the one I&#039;ve evolved is that you have a field called Active, whereas I have one called Obsolete. It feels good to have somebody agree with my decision!&lt;/p&gt;
&lt;p&gt;As it happens, I already had an account at the site with article on Lookup Table Madness, so I&#039;ve taken the liberty of summarizing it here. The only direct quote is indicated as such and the summary and examples are my own.&lt;/p&gt;
&lt;p&gt;The author, Don Peterson, refers to something called &quot;Massively Unified Code-Key tables, or MUCK tables.&quot; A MUCK table is basically a structure that allows for the inclusion of multiple &#039;lookup types&#039; in one table. Thus, instead of separate tables for DocumentStatus and DocumentType, you end up with a table called LookupType with 2 entries (DocStatus and DocType) and a second table with the actual lookup values, keyed by LookupType.&lt;/p&gt;
&lt;p&gt;I&#039;m sure that we&#039;ve all been down that road before! At least I hope I&#039;m not alone in that particular folly. While a MUCK table certainly makes it easy to add new lookups, the reality is that the application needs to be recoded anyway if the new data is to be utilized. In practice, I&#039;ve seen first hand how quickly this concept leads to attempts to use the RDBMS to create a program that very poorly simulates an RDBMS.&lt;/p&gt;
&lt;p&gt;Peterson also dislikes the term &#039;lookup table&#039; because there is nothing particularly special about the table in the first place. It contains data, it&#039;s related to other tables, it&#039;s used for reference and validation, etc., in the same way that things like Customer and InventoryItem are used.&lt;/p&gt;
</description>
 <pubDate>Tue, 20 Mar 2007 07:32:10 -0700</pubDate>
 <dc:creator>Ron Porter</dc:creator>
 <guid isPermaLink="false">comment 7314 at http://www.developerdotstar.com/community</guid>
</item>
<item>
 <title>Ideal Design/Structure for Lookup Tables</title>
 <link>http://www.developerdotstar.com/community/lookup_table</link>
 <description>&lt;p&gt;In my work over the years that I have continually strived for the ideal structure of a lookup table. I must have designed hundreds of them by now in at least four different RDBMS engines. I may have finally arrived at a structure I really like, so I thought I would share it, with the hope that other people may benefit from adopting it, or even better, suggest improvements to the design.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.developerdotstar.com/community/lookup_table&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.developerdotstar.com/community/lookup_table#comment</comments>
 <category domain="http://www.developerdotstar.com/community/taxonomy/term/28">Database Design</category>
 <category domain="http://www.developerdotstar.com/community/taxonomy/term/152">Design Patterns</category>
 <pubDate>Mon, 19 Mar 2007 14:36:30 -0700</pubDate>
 <dc:creator>Daniel Read</dc:creator>
 <guid isPermaLink="false">720 at http://www.developerdotstar.com/community</guid>
</item>
</channel>
</rss>
