From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Robert Nikander <rob(dot)nikander(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: use null or 0 in foreign key column, to mean "no value"? |
Date: | 2015-06-27 04:41:11 |
Message-ID: | CAKFQuwbKVZC1z9X4xWPkLM5G-=g5KZGY9JdF7vk9Em3+cBz16w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Friday, June 26, 2015, Robert Nikander <rob(dot)nikander(at)gmail(dot)com> 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.
From | Date | Subject | |
---|---|---|---|
Next Message | John McKown | 2015-06-27 04:50:08 | Re: use null or 0 in foreign key column, to mean "no value"? |
Previous Message | Jan de Visser | 2015-06-27 04:31:27 | Re: use null or 0 in foreign key column, to mean "no value"? |