3 ms·
It's not super unreasonable for a multi-element primary key, is it? For example, at work we have a MySQL table that stores advertising stats with a (Publisher I
by MaxGabriel 12y ago
It's not super unreasonable for a multi-element primary key, is it? For example, at work we have a MySQL table that stores advertising stats with a (Publisher ID, Country, Day) primary key[1]. All those fields are non-nullable, but I can imagine someone using NULL for the country[2] if we couldn't determine it (it's based on IP).
[1] It's slightly more complicated, but it's basically similar.
[2] "zz" might be appropriate to represent an unknown country, but other domains might not have a good default value
Edit: double asterisks messing up my formatting
- zzzeek 12y agoit's unreasonable. NULL isn't a value, it means, "the value can't be known". If a primary key of a table has part of it that is unknown, you've designed your schema completely incorrectly, and you should brush up on normal form: http://en.wikipedia.org/wiki/Database_normalization#Normal_forms http://en.wikipedia.org/wiki/Database_normalization#Normal_f...