C
chris.nebinger
Okay, here's my question.
Taking the Northwind database, it is obvious that there are 3 types of
people. Customers, Employees, and Supplier contacts. Taking a OO
methodology, and considering inheritance, I would model that as a
Person class, with a Customer Class, Employee Class, and Supplier class
all inheriting from the Person class, possibly overloading some
methods/properites.
My question is: What is the best way to model that in a DB?
I see three possibilities.
A People table with all the fields that apply to each Person type.
Then, I could use a Employee table, with a PersonID and the remaining
employee types. And, if I need to map to different companies
(subsidiaries, etc.), I could use the Employee table as the many-many
relationship. This works, but then I have a Customer table, Employee
table, and Supplier table.
Another method that I've seen in models is to use 1 intermediary table
with:
PersonID
CustomerID
EmployeeID
SupplierID
The PersonID would be required, then either one of the remaining three
types of People.
Any thoughts?
Chris Nebinger
Taking the Northwind database, it is obvious that there are 3 types of
people. Customers, Employees, and Supplier contacts. Taking a OO
methodology, and considering inheritance, I would model that as a
Person class, with a Customer Class, Employee Class, and Supplier class
all inheriting from the Person class, possibly overloading some
methods/properites.
My question is: What is the best way to model that in a DB?
I see three possibilities.
A People table with all the fields that apply to each Person type.
Then, I could use a Employee table, with a PersonID and the remaining
employee types. And, if I need to map to different companies
(subsidiaries, etc.), I could use the Employee table as the many-many
relationship. This works, but then I have a Customer table, Employee
table, and Supplier table.
Another method that I've seen in models is to use 1 intermediary table
with:
PersonID
CustomerID
EmployeeID
SupplierID
The PersonID would be required, then either one of the remaining three
types of People.
Any thoughts?
Chris Nebinger