0

I am trying to model a sales situation where you can sell to a person or to a business with a contact person. I cannot figure out the proper way to do this.

It seems like 2 tables would be incorrect. But how do I model a Customer table that can be a business or a person? Would I just have a boolean for "business" and an additional "business_name" field that would default to Null. But then I have to do an if/then on the columns and that seems like poor design.

Any advice, direction, or links is appreciated.

dewyze
  • 979
  • 1
  • 7
  • 21

2 Answers2

1

This SO answer deals specifically with individuals and organizations. This one uses the same technique in a slightly different application.

Community
  • 1
  • 1
Mike Sherrill 'Cat Recall'
  • 91,602
  • 17
  • 122
  • 185
0

For some detailed explanation of two design alternatives and a related technique, google articles on "Single Table Inheritance", "Class Table Inheritance" and "Shared Primary Key".

There are tags for all three of these here in SO as well.

Walter Mitty
  • 18,205
  • 2
  • 28
  • 58