Code Table

A CodeTable is a table that contains codes of one or more letter with their corresponding meaning. The most common example of this sort of table is the list of states of the United States, where each state has a two-letter code. Code tables are usually an AntiPattern because it becomes hard for programmers to keep track of all the codes for various things all over the place, and because they are not generally portable. The issue is that they are InformationOriented, and in order to make a code table work effectively and not have the various downsides that they usually have you have to write a lot of InformationOriented overhead code and structure to manage them. Their ultimate form is the EndemeSet, which does have enough InformationOriented overhead to manage them properly, and is an atomic unit of information used in InformationOrientedSoftwareDevelopment?.

If it's an AntiPattern, what's the alternative? If the long name is subject to change, then we risk having to update gajillion copies if the name changes. An abbreviated or self-meaning-free (aka "dumb") code is less subject to this. Plus codes are less subject to typographical errors in my experience. It's hard to visually differentiate between "programmer" and "programer" for most humans.

The advantage of int or GUID based tables over code based tables is that the PK becomes a GUID or an int with no semantic meaning. Decoupling the semantic meaning from the PK means that you can manage the code separately in another column if you still want a code for an item. You can manage it without having to change data in many tables if you want to change a code for a particular item.

In my experience it is usually and AntiPattern but not a particularly bad one.

{Isn't that essentially the eternal AutoKeysVersusDomainKeys debate in a slightly different guise?}

This particular debate seems quite similar to the AutoKeysVersusDomainKeys debate. However I am trying to assemble a stable of pages for types of tables that are a step or two in the direction of InformationOrientatedSoftwareDevelopment?. I would be happy to move the debate, and leave a general page here describing this particular type of table. -- JonGrover

GUID's are tricky to manage because you have to consider "global". That's a large scope to have to keep an eye on.


Not to be confused with a ControlTable, which may have programming code in it.


CategoryInformation


EditText of this page (last edited September 24, 2014) or FindPage with title or text search