ddomoney
07-16-02, 17:04
| I am currently creating a datamodel for a large web based application and have a problem that I would like to bounce off some others..... BTW I am using postgresql 7.2.1 I have some tables ie: address that I am trying to create generically but am probably trying to do too much with. For example I am trying to have the address table relate to people or organizations or potentially appointments. Table structure (now): address_id serial primary key address_type_id int foreign key person_id int foreign key *only tagging locations to people* address1 text address2 text address3 text postcode varchar city_id int foreign key province_id int foreign key country_id int foreign key Potential solutions: 1) add foreign keys for organization_id & appointment_id - how do I create an integrity constraint that says one of the foreign keys must be non-null? 2) create three inherited tables ie: person_address, organization_address, appointment address with the distinctive trait being the foreign key. How much complexity is this going to add to my database queries that are being dynamically created using PHP??? 3) Others??? Note: I am a little unsure if I really want to use an address - organization linkage as I stating in my business rules that an organization is represented by a person.... but I definately need to be able to handle appointment addresses. |