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 1tfMQE-001n1K-7O for pgsql-general@arkaria.postgresql.org; Tue, 04 Feb 2025 17:09:14 +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 1tfMQD-005sra-AI for pgsql-general@arkaria.postgresql.org; Tue, 04 Feb 2025 17:09:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tfMQC-005srR-Va for pgsql-general@lists.postgresql.org; Tue, 04 Feb 2025 17:09:12 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tfMQA-003Gkn-0w for pgsql-general@postgresql.org; Tue, 04 Feb 2025 17:09:12 +0000 Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5dcd9158685so470619a12.3 for ; Tue, 04 Feb 2025 09:09:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kleczek.org; s=google; t=1738688949; x=1739293749; darn=postgresql.org; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=kfCxyjYpwa2t05IsbgspIKKbnRODCN81/iRJ4ptnxE0=; b=BbgyaA9uZCDP8dlsxklzVaArWyvOjU/0g6TPeKI8Eb+8g0h4jaDhu9SjP5U5nXLz9V BjXqsRjdzM/Wljk0fphp+yYoxFOy1wUY1ugtWkWFqKSdS1uZ2z0kcY8A7attCeHaHZPH 4TNNiHBIyg6g3Ie9b2X6qIgEIY9F7xXSyvP4k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738688949; x=1739293749; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kfCxyjYpwa2t05IsbgspIKKbnRODCN81/iRJ4ptnxE0=; b=SfSGqPJ8JGvRtWGWlDzkZ6J4bNOEpbf/P3rOVmaIIe6y76+z09kjr6qdfQZFU8WSyz +ZPXVWYTyjcvRvIYns0JGLlvzoHjzUtLKVeX4YYdWoc1W1AZT83eWh3vRTjn3J2bfoyH DaqGGB5DJtpa6JQsWvFniU/auS/b+BR3PxecKcA8VXz9yU66+KAWb55v71LMqqbvaV6m bLhyZ57fEwD38gT+UEe6MBNcTPewK7MjA9uNXLs6YX1FlvtFAstB6R9/dph9ZI14G+Ao YiJtSnchzAn7TV9gGSxRHK4jDaFf3l5Gp3h3/GdBOzDV/PUCia+wg/6B8ux+oAyAhqIX Z3nQ== X-Forwarded-Encrypted: i=1; AJvYcCU+ETvHotgwRfjuGQTAF61JSdty7hnp8tEz6mLvvZTe2mcEBxF/fHMKP4Z6WNXDtlKc256MfJ8G/mhXHHA3@postgresql.org X-Gm-Message-State: AOJu0YxIL72gWmq8yy5lTJwTOCfqBxFDdQTL2x1NRbgN3bS5sV/hBtJF fDkChHFeop1swH8Y/ql4q2uXj3I2yM4QPnxSMZQdoLCQCFdju2fJRJ5PB8dfu8E= X-Gm-Gg: ASbGncvzRNb0TxvBH7U1Jdc5wrqFb1e8jwjlHeMd1l7dcUPyj0qzcnaMKAnUeakVDR8 gj4XmsE1jaSKbTucO8u9ocJ0Bvj+j6jlBWmL9JFcLl9vfvXgefTbpxI49wa9Yp99VYptGn+03N9 yvoCu/HN+z1fzd5ana1Uv68VdkBOqOjJA7CXugea9byCgfsrbp2hUEly6aGskgpSKYayWdayLtn kS1o8/mKk9QexyreOAiKzfpzh+OAvM1fm+/XujSRWLprZzmDUeOfOzQbsYHPIDFm9onaFWhWbu3 IhLn8F+8jHVbbjIak2HfqccjNO0nM/Ym2mlG2w8gfmA= X-Google-Smtp-Source: AGHT+IHvpT1tvn/qiS7Rewu7/CdoQ2+HnPwpZ2+QzxRs1wokd/L6V1THE9x9VNee2/G9kvsn2NuIGQ== X-Received: by 2002:a05:6402:84d:b0:5d0:bdc1:75df with SMTP id 4fb4d7f45d1cf-5dc5efebbb2mr27277717a12.24.1738688948611; Tue, 04 Feb 2025 09:09:08 -0800 (PST) Received: from smtpclient.apple (b15.kleczek.org. [185.20.172.182]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5dc72404887sm9825794a12.38.2025.02.04.09.09.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Feb 2025 09:09:07 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: =?utf-8?Q?Micha=C5=82_K=C5=82eczek?= Mime-Version: 1.0 (1.0) Subject: Re: Lookup tables Date: Tue, 4 Feb 2025 18:08:56 +0100 Message-Id: <6DCD3899-51A8-4032-A189-F2B51AD7CC8F@kleczek.org> References: Cc: pgsql-general@lists.postgresql.org, PG-General Mailing List In-Reply-To: To: Karsten Hilbert X-Mailer: iPhone Mail (22C161) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 4 Feb 2025, at 17:51, Karsten Hilbert wrote: >=20 > =EF=BB=BFAm Tue, Feb 04, 2025 at 05:31:13PM +0100 schrieb Micha=C5=82 K=C5= =82eczek: >=20 >> It is now completely unclear what it means to change the name of the rest= aurant for already registered visits. >> Is it still the same restaurant with a different name or a different rest= aurant? >>=20 >> Or let say someone swaps names of two restaurants. >> That means a user that goes to the same restaurant every day would regist= er visits to two different restaurants! >>=20 >> Using the name of a restaurant as primary key gets rid of these logical a= nomalies because >> the database model now reflects facts from reality. >=20 > Reality tends to become so ambiguous as to not be > reflectable (two entirely different restaurants eventually, > within the flow of time, carry the very same name). >=20 > A primary key is very likely not the proper place to reflect > arbitrary business logic (is it the same restaurant or not ? > what if two restaurants have the same name at the same time These are of course problems ( and beyond the scope of my contrived example )= . The point is though, that having surrogate PK not only does not solve these i= ssues but makes them worse by kicking the can down the road and allowing for= inconsistencies. =E2=80=94 Micha=C5=82=20=