In a food delivery app I have a USERS
table that holds info about user data like firstname, lastname, email, password etc.
A small subset of users (~1% of all users) will have a delivery person role assigned. This means that there will be some delivery person-specific data like driver license id, average_rating and some more.
What I'm unsure of is what's better: have one USERS
table that holds all the data (which means that for the majority of users the delivery-person specific columns will be null) or have a subtype table (DELIVERY_PERSON
) that will hold those columns and a foreign key to USERS
table?
Option #1
USERS:
- id(PK)
- password
- name ...
- driver_license_id (null for all regular users)
- avg_rating (null for all regular users)
- more delivery person specific columns
Option #2
USERS:
- id(PK)
- password
- name
DELIVERY_PERSON:
- id (PK, FK to USERS.id)
- driver_license_id
- avg_rating
- more delivery person specific columns
I've seen several similar questions on SO, but in all of them there are multiple subtypes like Vehicle -> Car/Airplane/Boat etc.
In my scenario there is one base type (user) and only one possible extending subtype (delivery person). I'm wondering if having only one possible subtype somehow affects what option to choose.