public inbox for [email protected]
help / color / mirror / Atom feedDDL issue
4+ messages / 2 participants
[nested] [flat]
* DDL issue
@ 2024-09-12 23:01 Rich Shepard <[email protected]>
2024-09-12 23:46 ` Re: DDL issue Adrian Klaver <[email protected]>
0 siblings, 1 reply; 4+ messages in thread
From: Rich Shepard @ 2024-09-12 23:01 UTC (permalink / raw)
To: pgsql-general
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.
TIA,
Rich
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: DDL issue
2024-09-12 23:01 DDL issue Rich Shepard <[email protected]>
@ 2024-09-12 23:46 ` Adrian Klaver <[email protected]>
2024-09-13 12:38 ` Re: DDL issue Rich Shepard <[email protected]>
2024-09-13 16:27 ` Re: DDL issue Rich Shepard <[email protected]>
0 siblings, 2 replies; 4+ messages in thread
From: Adrian Klaver @ 2024-09-12 23:46 UTC (permalink / raw)
To: Rich Shepard <[email protected]>; 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
[email protected]
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: DDL issue
2024-09-12 23:01 DDL issue Rich Shepard <[email protected]>
2024-09-12 23:46 ` Re: DDL issue Adrian Klaver <[email protected]>
@ 2024-09-13 12:38 ` Rich Shepard <[email protected]>
1 sibling, 0 replies; 4+ messages in thread
From: Rich Shepard @ 2024-09-13 12:38 UTC (permalink / raw)
To: pgsql-general
On Thu, 12 Sep 2024, Adrian Klaver wrote:
> 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.
Adrian,
There are many companies with multiple locations, but few owners with
multiple companies, each with a different location. David's reminder about
many-to-many tables will do the job.
Thanks,
Rich
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: DDL issue
2024-09-12 23:01 DDL issue Rich Shepard <[email protected]>
2024-09-12 23:46 ` Re: DDL issue Adrian Klaver <[email protected]>
@ 2024-09-13 16:27 ` Rich Shepard <[email protected]>
1 sibling, 0 replies; 4+ messages in thread
From: Rich Shepard @ 2024-09-13 16:27 UTC (permalink / raw)
To: pgsql-general
On Thu, 12 Sep 2024, Adrian Klaver wrote:
> 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.
Adrian,
This comes close; I need to think about this.
Thanks,
Rich
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2024-09-13 16:27 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-09-12 23:01 DDL issue Rich Shepard <[email protected]>
2024-09-12 23:46 ` Adrian Klaver <[email protected]>
2024-09-13 12:38 ` Rich Shepard <[email protected]>
2024-09-13 16:27 ` Rich Shepard <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox