From: | "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Lookup tables |
Date: | 2025-02-07 18:42:08 |
Message-ID: | 20250207184208.y6htcxbhlravtrte@hjp.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgadmin-support pgsql-general |
On 2025-02-07 09:22:13 +0100, Michał Kłeczek wrote:
>
>
> On 6 Feb 2025, at 22:03, Peter J. Holzer <hjp-pgsql(at)hjp(dot)at> wrote:
>
> On 2025-02-04 22:41:38 +0100, Thiemo Kellner wrote:
>
>
> 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.
>
>
> I fail to see why use of a surrogate key is the problem here.
>
> Either changing the color from GREE to YELLOW makes sense or it doesn't.
>
>
> If it doesn't make sense, then it's release which is faulty, not the
> model.
>
> if it does make sense (I'm a bit at a loss when that might be the case,
> maybe the "color" is just a code word, or maybe they are colors in a
> design which are arbitrary but must be consistent), then the experience
> that the user has is exactly the same as if the maintenance release was
> applied just after they selected the color. Which might be a bit
> confusing but is almost certainly what is wanted.
>
>
>
> This is simply saying “what is implemented is certainly wanted,
Not at all. It may or may not be what is wanted but we can't tell unless
we know what is wanted. We have a single table without any context. What
does this table represent? What is the identity here? If it's the color
itself, changing green to yellow doesn't make any sense ("it's the same
color, but now it's yellow instead of green" is self-contradictory). If
the identity has some application-defined semantics, it may make sense.
> so what’s the point”.
Indeed. Without knowing the semantics discussing the data model or the
advisability of certain updates is indeed rather pointless.
Disagreements will be more likely to be due to unstated assumptions
about the application than because of general principles.
> A) Your release changed the sementics of the record 3. It's meaning
> changed. I cannot recommend doing that.
>
>
> If the release changed the semantics of an existing record the release
> was almost certainly wrong.
>
>
> Is it possible to minimize the risk of “wrong releases” using mechanisms that
> DBMS provides?
Maybe. But the person who thought that
update colors set name = 'YELLOW' where id = 3; -- YELLOW is the new GREE
was a good idea might also think that
update doodads set color = 'YELLOW' where color = 'GREE';
is a good idea.
Is it? I don't know. Maybe it is. Maybe it isn't. There is no way to
know unless we know the requirements.
> 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.
>
>
> Yeah, that's a good example where changing the color from GREE to YELLOW
> doesn't make sense. Presumably that ID 3 is used as a foreign key in
> lots of places, e,g. in an inventory table. Your bikes in stock won't
> just magically change color just because you changed some text in the
> database. So that change simply doesn't make sense and shouldn't be done
> as part of a maintenance release. Confusing a few people who just happen
> to open the dropdown in the wrong second is the least of your problems.
>
>
> We are in agreement here. What I am also saying is:
> having color name as PK and all FKs referencing it *prevents* these unwanted
> updates.
I'm not convinced.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp(at)hjp(dot)at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"
From | Date | Subject | |
---|---|---|---|
Next Message | Igor Korot | 2025-02-07 19:02:19 | Re: How to get a notification |
Previous Message | Robert Leach | 2025-02-07 18:20:16 | Re: How to perform a long running dry run transaction without blocking |
From | Date | Subject | |
---|---|---|---|
Previous Message | Thiemo Kellner | 2025-02-07 11:07:56 | Re: Lookup tables |