From: | Michał Kłeczek <michal(at)kleczek(dot)org> |
---|---|
To: | Thiemo Kellner <thiemo(at)gelassene-pferde(dot)biz> |
Cc: | pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Lookup tables |
Date: | 2025-02-05 12:55:51 |
Message-ID: | 3A08C6E4-8B03-4D24-BAA7-53860A66C1AF@kleczek.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgadmin-support pgsql-general |
> On 4 Feb 2025, at 22:41, Thiemo Kellner <thiemo(at)gelassene-pferde(dot)biz> wrote:
>
> 04.02.2025 18:31:09 Michał Kłeczek <michal(at)kleczek(dot)org>:
>
>>
>>> On 4 Feb 2025, at 18:27, Thiemo Kellner <thiemo(at)gelassene-pferde(dot)biz> wrote:
>>>
>>> Unless the lookup table is actually a check constraint one can use to populate dropdown boxes in an interface.
>>
>> That is even worse because it ceases being transactional and users might select something different than what they see on the screen.
>
> I might see what you want to point out. E.g. the table is COLOURS. The rec with id 1 is RED, the one with id 2 is BLUE, 3 is GREE and so on. Now you load these values into the dropdown box that sports RED, BLUE, GREE and so on. While someone selects GREE, there is a maintenance release changing GREE to YELLOW. So when that someone sends the selection by id to the backend, not GREE is selected but YELLOW.
>
> A) Your release changed the sementics of the record 3. It's meaning changed. I cannot recommend doing that.
That’s what using natural keys and FK’s restricting their changes guarantee: no (accidental) changes to meaning of data.
Even with cascading updates you still have transactional semantics (ie. the user selects what’s on the screen or gets an error).
> B) If you absolutely must change the semantic, put your application into maintenance mode in which noone can select anything beforehand.
All this error prone hassle and downtime can be avoided with natural keys and guarantees that DBMS gives you.
>
> If the maintenance would just correct the typo from GREE to GREEN, nothing would happen. Yor customer still ordered the lavishly green E-Bike her hear ever desired.
The question is: how do you _ensure_ that?
—
Michal
From | Date | Subject | |
---|---|---|---|
Next Message | Serge De Maseneer | 2025-02-05 17:08:13 | Failed backup due to --no-password |
Previous Message | Yogesh Mahajan | 2025-02-05 09:25:32 | Re: Pgadmin |
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2025-02-05 12:57:42 | Re: Commit Latency |
Previous Message | Ramakrishna m | 2025-02-05 10:18:54 | Commit Latency |