I am modelling a chauffeur-like system, where for each driver that registers in the platform, he/she can either be a "solo" driver or belong to an already associated company.
Independently of the type of driver, the following information is registered:
- Driver ID (Primary Key - I considered using this parameter in order to have the system more "ordered")
- Email (UNIQUE)
- Phone Number (UNIQUE)
- Registration Date (Time Stamp)
Now, if it's a "solo" driver, the following additional information will also be asked:
- Vehicle type (for example: 'car', 'motorbike', etc.)
- Plate number (UNIQUE)
- Fiscal number (UNIQUE)
If he/she belongs to an associated company, only the name of the company will be asked (since all the vehicles will be associated to the car company).
The company table will have the following attributes:
- Company ID (Primary Key - I considered using this parameter in order to have the system more "ordered")
- Contact (UNIQUE)
- Email (UNIQUE)
- IBAN (UNIQUE)
- Fiscal Number (UNIQUE)
Lastly, the vehicle table will have the following attributes:
- Vehicle ID (Primary Key - I considered using this parameter in order to have the system more "ordered")
- Company ID (Foreign Key)
- Vehicle Type
- Plate Number (UNIQUE)
A vehicle cannot exist as a standalone entity, i.e., it must be associated to a driver or to an existing company.
I would like to model this scenario using a relational DB since this info will be coupled with a routing algorithm. I'm having a difficult time finding a "clean" solution for this problem (specially considering that we are storing related-entity information, vehicle, in two different tables)... so, what's the best way to model this situation?
Responses to clarification requests
- In your business domain, is it possible for a solo driver to eventually work for a car company?
- Is it possible for a driver that works for a car company to become a solo driver only?
- Can a driver be working for a car company and, at the same time, be working as well as a solo dirver?
Regarding questions 1 and 2, those are cases I haven't quite considered, but they seem plausible possibilities, so we can consider that those are possible scenarios.
Regarding question 3, for the moment, let's consider that a person can only be a solo driver or a company driver.