Tuesday, May 3, 2011

Company & Contacts Object Design Help

I am hoping that someone (or some people) could help us with a problem that we have wrangled with for a few days. How to organize our business objects given the attached diagram?

We are looking for any assistance (ideas about where to or how to search for the design pattern(s)/object model(s) we could use in order to solve this problem. Our situation is slightly more complex, but we have tried to simplify it best we could for the purposes of asking this question.

Some Details: Some companies have product lines and some don't.
Each company has a list of contacts. If a company has at least one product line, some of those company contacts are ALSO associated with at least one product line.
A few of the contacts are references (business/personal) for other contacts.
Each company and each contact can have zero or more addresses.

Thank you for any assistance finding a more appropriate solution (My assumption is that we will need to use multiple models/patterns).

Entity Diagram

Larger view of diagram (flickr.com)

** (from the diagram) Our company has employees/internal application users who are included with contacts because they can also be references, etc.

From stackoverflow
  • If you are trying to desing a database, I'd do it that way :

    Companies = [id, name]
    Contacts = [id, name]
    Products = [id, name]
    Adresses = [id, details]
    
    CompaniesContacts = [contact_id, company_id]
    CompaniesProducts = [product_id, company_id]
    AdressesContacts = [contact_id, address_id]
    
    References = [contact_id, referenced] // referenced is also a contact_id
    

    Also, I'd recommend using UML. It's just a quick answer, try to update your question and I'll update it a bit.

    Steve Bargelt : The database is legacy and cannot be changed at this point. We are attempting to create business objects We were hoping to find someone who may have come across a proven design pattern or two (or tried and true object models) for this. The flow diagram was simpler in design - we don't want to propose solutions just the problem/question
  • We have a similar structure in our application and it works well for us. We have two extra tables

    We have the concept of Sites between the company and addresses people can be attached one or more sites in our schema and that saves storing thousands of duplicate addresses. You could reference the client address direct in an addressbook too.

    Where are you storing contact details ?

    Steve Bargelt : u07ch, thank you. The tables appear to be in good shape (properly normalized). Our concern is primarily with the business object area of our project.
  • You can use the following object model:

    Organization
    -id
    -name
    -description
    -productLines ( collection object consisting of products)
    -orgcontacts ( collection object consisting of contacts)
    -addresses (of type Address, can be a collection depends on business rule)
    
    Contact
    -id
    -name
    -type (Business, personal, etc)
    -parentID (null if no reference)
    -adresses (Address or collection)
    
    ProductLine
    -id
    -name
    -prLineContacts ( collection object consisting of contacts)
    

    You can build on this basic model that I can think of. Do you have a data schema? if so, you should decide where to start. Some people like 1-1 mapping between their object and data model and some want to design their data schema based on performance and then have another abstraction mapping between objects and database.

0 comments:

Post a Comment