I am a bit confused in choosing an approach to model the following relationships.
Scenario:
The system has a User.
The User can perform 2 functions :
How can i model the user who can do both the functions of a seller as well as place delivery requests.
User
|
|
_________________________________________________
| |
Seller (ONLY) Delivery (ONLY)
**SELLER AND DELIVERY**
You have two options how to implement the class hierarchy formed by Seller
and DeliverySubscriber
being subtypes of User
. If your subclasses/subtables do not have many additional properties/columns, one would normally use the Single Table Inheritance approach with just one table User
and a type
(or category
) column for discriminating between users who are sellers and users who are delivery subscribers. Otherwise, if there are many additional properties/columns, it's better to use the Joined Table Inheritance approach, where subtables (representing subclasses) are joined to their supertable via their primary key being also a foreign key referencing the supertable. You can read more about these two forms of implementing class hierarchies with tables in my book chapter Subtyping and Inheritance.