Re: DDL issue

2024-09-13 Thread Rich Shepard
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_

Re: DDL issue

2024-09-13 Thread Rich Shepard
On Fri, 13 Sep 2024, Tony Shelver wrote: Or if you want to get even more flexible, where a dairy could have more than one owner as well as one owner having more than one dairy, you could create an intersection / relationship table. Something like -- Create people table (one entry per person) C

Re: DDL issue

2024-09-13 Thread Rich Shepard
On Fri, 13 Sep 2024, Muhammad Usman Khan wrote: To handle this situation in PostgreSQL, you can model the data in a way that maintains a single entry for each owner in the people table while linking the owner to multiple dairies through a separate dairies table. This is a typical one-to-many rel

Re: DDL issue

2024-09-13 Thread Rich Shepard
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_

Re: DDL issue

2024-09-13 Thread Rich Shepard
On Thu, 12 Sep 2024, David G. Johnston wrote: Read up on “many-to-many” data models. In SQL they involve a linking table, one row per bidirectional edge, in addition to the two node tables. David, Thanks very much. I knew about those a long time ago but haven't needed them in a long time so I

Re: DDL issue

2024-09-12 Thread Adrian Klaver
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 fi