From: | Ron St-Pierre <rstpierre(at)syscor(dot)com> |
---|---|
To: | John Browne <jkbrowne(at)gmail(dot)com>, pgsql-novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Conditional Relationships? |
Date: | 2004-10-07 18:10:29 |
Message-ID: | 41658695.3000109@syscor.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-novice |
John Browne wrote:
>Yes, there will be different address types. Sorry, I didn't represent
>the address type in the example. Sorry about that. The address to
>office relationship will need to be a many to many relationship,
>because of the different address types and the need to possibly share
>a ship-to address between multiple offices. A manager may use his
>home address for a ship-to address, and share that between three
>different offices.
>
>tb_address_types
>address_type_id
>description (ie, Office Location, Ship-to, Mail-to, etc)
>
>tb_address_data_us
>address_id
>addr1
>addr2
>city
>state
>zip_code
>
>tb_address_data_ca
>address_id
>addr1
>addr2
>city
>province
>postal_code
>
>tb_offices
>office_id
>manager_name
>date_opened
>
>tb_addresses_2_offices
>office_id
>country_id
>address_type_id
>address_data_id
>
>
>
One solution would be to create a tb_managers and change
tb_addresses_2_offices to something like tb_mgr_addr_off where it would
need
mgr_addr_off_id PRIMARY KEY
manager_id FOREIGN KEY REFERENCES tb_managers
address_id FOREIGN KEY REFERENCES tb_address
office_id FOREIGN KEY REFERENCES tb_office
address_type_id FOREIGN KEY REFERENCES tb_address_types
then an entry in tb_managers can have 0+ entries in tb_mgr_addr_off. If
you did it this way you could create a manager without either an address
or an office. You could also make the address table more generic by
using either the cdn or us version of state/province and zip/postalcode,
and introducing a country field. I don't know if this is the best
solution for your situation or not, but hopefully it will give you a
different perspective for finding a solution.
Ron
From | Date | Subject | |
---|---|---|---|
Next Message | Mike Benoit | 2004-10-07 18:47:50 | PSQL undesired transaction behavior when connection is lost. |
Previous Message | Francisco Reyes | 2004-10-07 17:38:05 | Re: Date variables in psql |
From | Date | Subject | |
---|---|---|---|
Next Message | Ron St-Pierre | 2004-10-07 18:47:57 | Re: Conditional Relationships? |
Previous Message | Ron St-Pierre | 2004-10-07 17:10:55 | Re: [NOVICE] Conditional Relationships? |