Topic: how to design models and what will be correct associations

I have the following design problem:

A "complaint" model is used to track complaints.

Complaints can be originated in two ways:
  1. By an automated web based system that generate so called "incidents". Each incident has a unique id. (This cater to outside company complaints)
  2. People can call / email and register complaints. (Caters to inside company complaints from various departments)


Goal is to track the complaint using either "incident id" or complainant (person).

How should I design my models / associations. If there were a single source of complaints this would have been easy:

Complaint belongs_to Complainant
Complainant has_many Complaints

OR in case of origin being incidents

Complaint belongs_to Incident
Incident has_one Complaint

Also a side effect would be the design problem with phone numbers.

Phone belongs_to Complainant
Complainant has_many Phones

OR in case of origin being incidents

Phones has_many_and_belongs_to Incidents
Incidents has_many_and_belongs_to Phones

Note that in the case of complaint being originated by people we do have names and associated phone numbers. However, in case of complaint origin being an incident, we do not necessarily have people information and the phone numbers are effectively tied to incident itself.


Any help will be appreciated and thank you for reading.

Last edited by imtiaz (2011-05-01 02:25:01)