Tuesday, April 1, 2014

CELKO vs. TOTH in SS T-SQL Table Design

The subject makes me think of an old bootleg entitled "Frank Zappa vs. the Tooth Fairy".


It is difficult to comment on your database design, as it seems to be for a local US system and this is not a business domain I am familiar with.


In our system, persons - natural and juridical alike - are (to some extent) identified by a three columns: country code, centry number and national registration number.


The country code is required, because some of our customers have business in more than one country, typically the Nordic countries, Denmark, Finland, Norway and Sweden. All four countries uses a national registration number which for a natural person is based on the birth date, but while the Swedish number is organised from YYMMDD, the other countries uses DDMMYY. As you see, the numbers uses two-digit years, and that is why the century number is needed. If the century number is 8, 9 or 0 you have a natural person. Other century numbers are for differnt classes of juridical persons. The leading digits of a juridical person is never a legal date.


It is very difficult to model persons accurately on a general level in a database, because there is no universal system. As Himanshu mentioned not all countries have registration numbers, or they may have it for natural/juridical persons only. And even if there a system in force, it may not be good enough to serve as a key. We don't use (country code, century number, national registration number) as a true key in any table. Even in a well-organised country it is not reliable. Occasionally, the authorities issues the same number to multiple persons. (As far as know, this happens with US SSNs as well.) And our clients have foreign customer our counterparts of which any national-registration number is not of interest.


So I declare the game to be a draw, 0-0.


On the question of singular vs. plural, I say that is a matter of habit and preference. My own preference is for plural.





Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

No comments:

Post a Comment