Re: One parent record with 3 possible child records

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Cc: JORGE MALDONADO <jorgemal1960(at)gmail(dot)com>
Subject: Re: One parent record with 3 possible child records
Date: 2024-05-02 13:37:14
Message-ID: CCFD24A0-A331-4633-AC9A-714F7F18B5DF@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> On May 1, 2024, at 5:24 PM, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> On Wednesday, May 1, 2024, JORGE MALDONADO <jorgemal1960(at)gmail(dot)com <mailto:jorgemal1960(at)gmail(dot)com>> wrote:
>
> Let's say that tableMain has a string field called "type" with the following possible values: "residential", "industrial" and "energy".
>
> This, and have the same column in the other tables, but add a check constraint ensuring only the correct enum value can be specified. Then your foreign key from the child tables to main is both the ID and the type field.
>
> David J.
Presuming the id is unique in parent and child, what’s the value of the type field in the foreign key? Are you saying the PK on tableMain is (type,id), perhaps for clustering purposes?

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2024-05-02 14:02:37 Re: One parent record with 3 possible child records
Previous Message Sanjay Minni 2024-05-02 13:33:44 Re: One parent record with 3 possible child records