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 1tfMMw-001mb4-0N for pgsql-general@arkaria.postgresql.org; Tue, 04 Feb 2025 17:05:50 +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 1tfMMu-005pgG-Sl for pgsql-general@arkaria.postgresql.org; Tue, 04 Feb 2025 17:05:48 +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 1tfMMu-005pg7-Hh for pgsql-general@lists.postgresql.org; Tue, 04 Feb 2025 17:05:48 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tfMMr-003Gix-1T for pgsql-general@lists.postgresql.org; Tue, 04 Feb 2025 17:05:48 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-218c8aca5f1so21274595ad.0 for ; Tue, 04 Feb 2025 09:05:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738688744; x=1739293544; darn=lists.postgresql.org; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=KTwVbrYgZ4/BQ2oQroXPddKbT6U8rNJcqb0BSYddH1I=; b=hj4dyNbIJPi8+tlPmjRYrvVADrZwvSIlZLMCQnGLKqRZMUT3sIxPi0j038E9TDoPAm y2Wjjcp2YlusF6tCzmAuwBURIMvtr7wW1V0yRo3ICEO2r5dp9urQJ6YLTREpIRrWb174 TE5WSatcbZ/ZYLM80UimdPluAzEg9V4Fj3dfo/e+SrUIDjeCkPGt8I6iusWcnjIWpFgY uYXiLxuSM70WI2P6Y3QEnLeigtTSfIpTajec/xmSPI7uBGc9H8wNdi7dmxV46brodwvZ e3kkD1TeiPhOG76Y9Emlb6YHVTDR6yw/uwtw717fovayHlBqpESwWHG53LF1pHA+N/Z7 nZow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738688744; x=1739293544; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=KTwVbrYgZ4/BQ2oQroXPddKbT6U8rNJcqb0BSYddH1I=; b=Yb9O6GKIjNluEr6IcA1LEGHngL/V6QQufm5xZ8O26ITFKzOVkIk4I5DIJcgs7S+xsI WczCBZNkaYxftlrzkBBluxVi4PRVOwcENjQPKLk6nF+WOi7Pq7LUc8vaOVNw+pdOHVWF 5mMHDWiI46M69pFjoE+axFy3jVq9veWIcz5/NmJmsEgvqmDMnGka/Ar4XptrKHMJBNLH dsWsTeP86vR8Kt8b2sGK4bg74dMS/Q2bPL39lAo9/2Np7Nug9azYViPS7h9xMihojtav 87CELXmwo6ltzWdlCRh0w0ouw55u9o1JTBL22CkXz+xOD53iP1XweoOeffP9CIX3Jryl Qq8w== X-Gm-Message-State: AOJu0YwTLGyU7uj7nA21z2ghV+QdCUUWChmpMs3oWmQYCRjMxY4C2LjO nb2JlT4y3OSHH4N6yeHmSa+RYyLL62Jnk4GUJcS/T+SvHLArW+2usJBjVw== X-Gm-Gg: ASbGncv50Mi+e8dL/jGvBdzbNcvbp7uHfb3oTH1QDemrsIdjqMKKG7BMqueB/on9wVW 36ReovMNbtVWVheNOIbzoX0eRohVchCBl3d7MQJgKoNgNwFM81iNUn13N93fwDiMxNtPrQNLIST Txk0WF3NPfoKUDslLNl0OEKpCSg6lkKBpu9nxicA9HjIUPbMxaoO6CDp4SSiHHbGgOCXGfutUn8 vF2niB0qbJY8FqiET65yNOgT83Sf6gfmJunsLszJIDuh70GLlMWXRmfcsOD8JltU4mRvi3kFTuE eW7XdhXsBWuAsLuKokefGyimLD/NdA3kPdqFg7wT7E+odczjEZjQ5BmhKTRBXZsaAA== X-Google-Smtp-Source: AGHT+IHUMS+EU45r1wd8hKuO93MSwx+br6T5gk2tkQnTyz3izJHoE5BicwLqE2p8HLhyR6wxmZwv3w== X-Received: by 2002:a17:903:903:b0:21f:1c9:ce4e with SMTP id d9443c01a7336-21f01c9d3c0mr64802925ad.34.1738688743672; Tue, 04 Feb 2025 09:05:43 -0800 (PST) Received: from ?IPV6:2601:681:4c01:7310:fdae:6140:a46c:4610? ([2601:681:4c01:7310:fdae:6140:a46c:4610]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21edc84fcb7sm85161475ad.205.2025.02.04.09.05.43 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Feb 2025 09:05:43 -0800 (PST) Content-Type: multipart/alternative; boundary="------------Q0qTzORZBG0f20J0ExJ0Ugs9" Message-ID: <868eea77-7a0c-4fca-b9a3-7a38ffe5087f@gmail.com> Date: Tue, 4 Feb 2025 10:05:42 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Lookup tables To: pgsql-general@lists.postgresql.org References: <4e7a338-c7d3-e944-20bd-a6e346e175c7@appl-ecosys.com> Content-Language: en-CA From: Rob Sargent In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------Q0qTzORZBG0f20J0ExJ0Ugs9 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2/4/25 10:03, Ron Johnson wrote: > On Tue, Feb 4, 2025 at 11:31 AM Michał Kłeczek wrote: > [snip] > > > The query to register a visit is: > insert into restaurant_visit > select $user, current_date, restaurant_id, $rating > from restaurant where name = $restaurant_name > > > It is now completely unclear what it means to change the name of > the restaurant for already registered visits. > Is it still the same restaurant with a different name or a > different restaurant? > > Or let say someone swaps names of two restaurants. > That means a user that goes to the same restaurant every day would > register visits to two different restaurants! > > > Valid concerns, which means that you add a new restaurant record when > the name changes. > And there goes your unique index on phone number :) --------------Q0qTzORZBG0f20J0ExJ0Ugs9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 2/4/25 10:03, Ron Johnson wrote:
On Tue, Feb 4, 2025 at 11:31 AM Michał Kłeczek <michal@kleczek.org> wrote:
[snip] 

The query to register a visit is:
insert into restaurant_visit
select $user, current_date, restaurant_id, $rating
from restaurant where name = $restaurant_name


It is now completely unclear what it means to change the name of the restaurant for already registered visits.
Is it still the same restaurant with a different name or a different restaurant?

Or let say someone swaps names of two restaurants.
That means a user that goes to the same restaurant every day would register visits to two different restaurants!

Valid concerns, which means that you add a new restaurant record when the name changes.


And there goes your unique index on phone number :)

--------------Q0qTzORZBG0f20J0ExJ0Ugs9--