I'm using react-admin
with hasura
as an API for Postgres.
I have a need for different entities that are all basically a person but with different purposes. Eg. a student and a teacher. I am thinking, given the similar attributes, it would be good to have a person table that will share common features and then have a separate tables for specific attributes. For example, tables like this:
persons {
id,
first_name,
last_name,
birthday
...
}
students {
id,
person_id,
date_enrolled
...
}
teachers {
id,
person_id,
sallary
...
}
The problem I encounter with that schema is that in order to create a student, the person for it has to be created first. So in react-admin I will have to present a user with a form for creating a person first and then another form to create a student based on that person.
I guess it's not ideal and maybe it would be better to have separate tables for students
and teachers
although some fields (first_name, last_name, birthday...) would be repeated in both tables.
This question is not really specific for react-admin
but more of a general advice on similiar db model design so any tips are more than welcome :).