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 1qwYsr-00ChIk-Vf for pgsql-docs@arkaria.postgresql.org; Sat, 28 Oct 2023 02:17:05 +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 1qwYso-002hRd-Lr for pgsql-docs@arkaria.postgresql.org; Sat, 28 Oct 2023 02:17:02 +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 1qwYso-002hRI-Eb for pgsql-docs@lists.postgresql.org; Sat, 28 Oct 2023 02:17:02 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qwYsi-002f7j-8P for pgsql-docs@lists.postgresql.org; Sat, 28 Oct 2023 02:17:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 39S2Gstj1688334; Fri, 27 Oct 2023 22:16:55 -0400 From: Tom Lane To: Daniel Gustafsson cc: Maxim Yablokov , pgsql-docs@lists.postgresql.org Subject: Re: Example 43.6. A PL/pgSQL Trigger Function for Maintaining a Summary Table In-reply-to: <455CCA8F-4D66-48A1-A6B8-07371D97B4D5@yesql.se> References: <70f74895-8512-4b2f-8617-2ac0ebcd2e87@postgrespro.ru> <99AC5F34-FDB6-42A8-867A-CF97F0707F9B@yesql.se> <455CCA8F-4D66-48A1-A6B8-07371D97B4D5@yesql.se> Comments: In-reply-to Daniel Gustafsson message dated "Fri, 27 Oct 2023 15:15:12 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1688332.1698459414.1@sss.pgh.pa.us> Date: Fri, 27 Oct 2023 22:16:54 -0400 Message-ID: <1688333.1698459414@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Daniel Gustafsson writes: > Thanks, I'll await pushing and backpatching if Tom who committed it has > insights into whether it was missed or if it indeed serves a purpose. Hey, I just pushed that for somebody else, I don't claim authorship ;-) It seems clear that the example intends to show a star-schema database where the fact table refers to various dimension tables. But it's incomplete --- there's no foreign-key constraint on time_key, and even less infrastructure for product_key or store_key. I don't have the cited book either, so I don't know how complete the original example was. Perhaps the bit in the trigger function about forbidding updates to time_key has something to do with that model. Anyway, I don't see any reason to object to this patch. The extra table isn't adding much. My only thought is would it make sense to change time_key to be a timestamp or timestamptz value? regards, tom lane