[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ProgSoc] NULL values in primary keys in MySQL



jedd wrote:
I've bodgied around it by setting suffix to have a DEFAULT 0, which makes tests for its presence easier .. but to mind, that's
actually less elegant than having NULLs in that column.

That's one perverted mind you have there dude.

Think about what your foreign keys would look like. Apart from the fact they'd need to be two columns side, they'd have to be nullable too, and if the value was legitimately 'unknown' you'd match it with the wrong account. Very, very far from elegant.

If I were you I'd use a surrogate key as the primary key.

Then put a unique constraint on 'number' and 'suffix'.

Natural keys are a nightmare.












- You are subscribed to the progsoc mailing list. To unsubscribe, send a message containing "unsubscribe" to progsoc-request@xxxxxxxxxxxxxxxxxxx If you are having trouble, ask owner-progsoc@xxxxxxxxxxxxxxxxxx for help.