Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tfewr-0044IB-KX for pgsql-general@arkaria.postgresql.org; Wed, 05 Feb 2025 12:56:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tfewq-00EQIJ-N7 for pgsql-general@arkaria.postgresql.org; Wed, 05 Feb 2025 12:56:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tfewq-00EQIB-Al for pgsql-general@lists.postgresql.org; Wed, 05 Feb 2025 12:56:08 +0000 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tfewm-003JTp-2Y for pgsql-general@lists.postgresql.org; Wed, 05 Feb 2025 12:56:07 +0000 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-ab2b29dfc65so1110484266b.1 for ; Wed, 05 Feb 2025 04:56:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kleczek.org; s=google; t=1738760163; x=1739364963; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=E6dsYgpHyXMy9VBBA2r6tT5G/HDXXq4/RdCRWdtNRuE=; b=Hz7CUeYJXL3O8/HjJNNrd4pnRLl1Z906Kt1LNotM5qE7hpkwVYzKG5SodciV5FXZmK hPZ+ycjyRh2JHj9JkUwvKlpHMwY3tQdqVO8hgtZ6gIDn9zUxswhuJ/KFRZNMU09fm508 kcHkagYZggnMCdjwi4DxpPR16TqHZS4awYhyE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738760163; x=1739364963; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E6dsYgpHyXMy9VBBA2r6tT5G/HDXXq4/RdCRWdtNRuE=; b=kwt1/VXQY0MnveY76tHCD8x2/ZujHRquQAId9CBVJdcGYaDLPUFMHRG9uSSyiaPtHR YZqW/1uepGgXWWwOjqIW3/c1Bb2BVv/UWEZII9JXn0U1pRYhEXUCmsCjPpMMlpYUyi1k sa5kEduOwsmo5JPstkMM/IELXqYOIWZPChCodjFqZ0tW872T4465V9NSLnZDHzxmDTV+ PtV584/mJDGEqAHEE6vAF4PZF1cGYQRFx/uOoKtr0zjXs6RBOjTxl8VJj/xfDo03Ztcg vwZMrleYLodhs+wI4AWAxruqIv+MxqCrJVtYP6MdUCg0FqSzKJmeil2O19n3l1nBvIP8 E5aw== X-Gm-Message-State: AOJu0Yyt9qYMsjq1qjbCWDoJM3oSvfRcKgznmHUuuDDnd7Y1BgOyiU+B YjStRrwVdeyf1Oq4jFUbf3fpMv711+qz5dMwWOendBPetTQg1UapRLcqXBsLLGFeaDobLvG1kNL M3pI= X-Gm-Gg: ASbGncv+K0nDmxNGtTNzT7jZRlHkZwxvON6T6XQXX0RzeXnzyOkwHXfPDL6PYKJUza4 kg+3MbfJDHTEuddJc8wiWxACXTeAMm882pH/aBae+SA87g1BIX1ExafUWaGBz+Izeo/zrVCIZ9A iQlxF0ba7XvlIupnqLb8SYallqTeX/yLNouIqri5/tu+PWIFrgayR08dYxuHsOX6c9V+WFOOj+2 IIvh0aeH35TnR/AajovxTIRSrfDL0x4iwuj81ajOiAoKiezw+RMNt3c8YH0fzoR0V993pz+Ct2D 5Yxq8hybCNsuUSSSl9nXh8vUG5v10KNeD5eyIeCmX2E= X-Google-Smtp-Source: AGHT+IE62ELvkLPGW2hQ5POvdjyfVakixw/MrXwV9onE7eXFYwNZbssiMz/e5Uvja8mSlBqc0W4wrg== X-Received: by 2002:a17:907:2ce3:b0:ab2:da92:d0bc with SMTP id a640c23a62f3a-ab75e234984mr283649466b.3.1738760162904; Wed, 05 Feb 2025 04:56:02 -0800 (PST) Received: from smtpclient.apple (b15.kleczek.org. [185.20.172.182]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dcda03eaecsm1653987a12.49.2025.02.05.04.56.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Feb 2025 04:56:02 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.300.87.4.3\)) Subject: Re: Lookup tables From: =?utf-8?Q?Micha=C5=82_K=C5=82eczek?= In-Reply-To: <64603f36-b6d5-469b-8d6d-30376842241b@gelassene-pferde.biz> Date: Wed, 5 Feb 2025 13:55:51 +0100 Cc: pgsql-general Content-Transfer-Encoding: quoted-printable Message-Id: <3A08C6E4-8B03-4D24-BAA7-53860A66C1AF@kleczek.org> References: <628D4022-5365-4D00-810B-10349A90874A@kleczek.org> <64603f36-b6d5-469b-8d6d-30376842241b@gelassene-pferde.biz> To: Thiemo Kellner X-Mailer: Apple Mail (2.3826.300.87.4.3) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 4 Feb 2025, at 22:41, Thiemo Kellner = wrote: >=20 > 04.02.2025 18:31:09 Micha=C5=82 K=C5=82eczek : >=20 >>=20 >>> On 4 Feb 2025, at 18:27, Thiemo Kellner = wrote: >>>=20 >>> =EF=BB=BF Unless the lookup table is actually a check constraint one = can use to populate dropdown boxes in an interface. >>=20 >> That is even worse because it ceases being transactional and users = might select something different than what they see on the screen. >=20 > 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. >=20 > A) Your release changed the sementics of the record 3. It's meaning = changed. I cannot recommend doing that. That=E2=80=99s what using natural keys and FK=E2=80=99s 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=E2=80=99s 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. >=20 > 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? =E2=80=94 Michal=