Search Postgresql Archives

Re: use null or 0 in foreign key column, to mean "no value"?

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

 



On Friday, June 26, 2015, Robert Nikander <rob.nikander@xxxxxxxxx> wrote:
So… is this bad DB design to use null to mean that an item has no color? Should I instead put a special row in `colors`, maybe with id = 0, to represent the “no color” value?  Or is there some way to make an index work with nulls and `is not distinct from`?

Not sure about getting is distinct to work with indexes but in this particular case I would add a "colorless" color to the table and make the column constraint not null.

I would also likely just make the text value the unique key and forget the surrogate integer key.

David J.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux