Re: Newbie question about db normalization theory: redundant keys OK?

From: Tony Rogerson <tonyrogerson_at_torver.net>
Date: Fri, 14 Dec 2007 08:01:28 -0000
Message-ID: <fjtdb3$h58$1$8302bc10_at_news.demon.co.uk>


> CREATE TABLE Schedule
> (teacher VARCHAR(15) NOT NULL,
> class CHAR(15) NOT NULL,
> room INTEGER NOT NULL,
> period INTEGER NOT NULL,
> PRIMARY KEY (teacher, class, room, period));
>
> That choice of a primary key is the most obvious one -- use all the
> columns. Typical rows would look like this:
>
> ('Mr. Celko', 'Database 101', 222, 6)

And half way through term the teacher changed their name to 'Mrs Bunting' and now everybody is confused!

Great example of why you should use an artificial key, I'll remember your example for a blog entry I'm writing.

-- 
Tony Rogerson, SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson
[Ramblings from the field from a SQL consultant]
http://sqlserverfaq.com
[UK SQL User Community] 
Received on Fri Dec 14 2007 - 09:01:28 CET

Original text of this message