- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
What I understood most people to be saying is that once they need to go international, the table would no longer be a US States, but instead be changed to a States/Province/whateverYourCountryCallsThoseThingsThatAreBiggerThanCitiesButSmallerThanTheCountryItself table.
Admin
Probably Java hence the case of String and int, also C# UCASE method naming convention sucks(as does the language [:D]
Admin
I just received my copy of the book you mentioned. However, after a cursory skimming, I'm unable to find anything that mentions that meaningless primary keys are contrary to the Relational Model and/or should be avoided. While I fully intend to read the book in its entirety, as it obviously contains a wealth of useful information that I should know, I was wondering if you could point me to a specific section or chapter of the book that supports your point, in the interest of expediency.
Admin
It is interesting to me to read this conversation, and see a guy who's self-taught in DB desing (Chris) arguing with a guy who I am guessing has had formal DB education (Jeff), and then finding myself disagreeing with the the guy who has the formal education...
I say that because I've been what I would call "classically trained' in DB architecture, BCNF, Relational Calculus, Relational Algebra, etc... And it's interesting to me to see people forget that there are different levels of DB modeling at work when we're designing a DB, namely: Conceptual, Logical, and Physical.
At the Conceptual and Logical levels, Jeff is right. The primary key has to be meaningful, well-defined. There is no way to normalize a database without a meaningful Primary key. But Physical DB modeling does not have to adhere to that standard, and indeed it shouldn't.
History has taught us (at least those of us who work on real systems) that using real Business entitites as primary keys isn't practical. Meaningful data is not static, and it does change, whether it's a primary key or not.
Hence surrogate keys used in conjunction with unique contraints.
I don't know why people would argue against the use of a Surrogate key. It's a perfectly legitimate way to model a database in a physical environment, abstracting from the logical model. Experience has shown a lot of us that it's actually a very effective way to maintain a database and handle FK dependancies. Nothing sucks more than having a meaningful primary key as a FK in many related tables, and then having that key change... The surrogate key gives us the flexibility in design, development, and maintenance, to avoid the hairy problems of implementing a strict logical model.
I think the thing a lot of folks misinterpret is saying an ID is a PK. It's not a PK. It's a surrogate key. The real PK is next door, in the next column, with a unique constraint on it. And to the business user, that unique value really is the PK - that is what makes that row unique - be it a special customer ID, or a state abbreviation, or whatever.
Auto-incremented Surrogate keys are a tool for Physically representing a logical model, and shouldn't be perceived as PK's. I think if Jeff were to see them that way, he might understand the key element in all of this: when using a Surrogate key in a Physical modeling of a DB, the logical modeling hasn't really changed...
Admin
I assume this is exactly the kind of programming WTF that prompted Java inventor to enforce strong typing :)
Apart from jokes, I like this code a lot. It reminds me of my first year in CS when, programming in C, all variables were "int", all pointers where "char*" and all loops were "while".
Admin
You know the ID of the record because the ID was stored somewhere else, say in another record.