Re: DDL issue

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: DDL issue
Date: 2024-09-12 23:46:51
Message-ID: a15a61f9-eb6d-47b0-ad15-ab6ff39a0dd7@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9/12/24 16:01, Rich Shepard wrote:
> I have one name in the people table who owns 5 different dairies with three
> different phone numbers, but all 5 have the the same email address.
>
> The five dairies each has its own name and location while the people table
> has five rows with the same last and first names and email address.
>
> Is there a way to have only one entry for the owner in the people table
> while related to five different company names? In some industries, such as
> dairy farms, this is not an unusual situation.

Quick and dirty:

people_table
person_id PK
name_last
name_first
email_address
ph_number
...

location_table
loc_id PK
person_id_fk FK <--> people_table(person_id)
loc_name
loc_st_addr
loc_st_city
loc_st_st_prov
...

contact_table
contact_id PK
loc_id_fk FK <--> location_table(loc_id)
contact_ph_number
contact_email --Can be null

It can get more involved then this, depends on how flexible you want to get.

>
> TIA,
>
> Rich
>
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

  • DDL issue at 2024-09-12 23:01:30 from Rich Shepard

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thiemo Kellner 2024-09-13 00:55:48 Re: Better way to process records in bash?
Previous Message David G. Johnston 2024-09-12 23:32:25 Re: DDL issue