E
E
Evgeny Abaev2022-03-31 22:23:18
Database design
Evgeny Abaev, 2022-03-31 22:23:18

Implementing student and teacher tables?

I'm writing a program in Spring MVC using JDBCTemplate, which will be added with more functionality in the future. It has two types of active users (Admin does not count now): Student and Teacher. Each has its own set of fields, there are only a few identical ones (such as a full name, for example). And the question arose of how to proceed further: either cut separate models, implement endpoints for authorization for each, etc., or file one large one, with the ability to leave the fields empty (at the front, give the teacher the opportunity to fill in only his fields, and the student his own) and scatter the functionality by Roles. But the second option entails an incredible number of crutches. Tell me how to do it right?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Slava Rozhnev, 2022-04-01
@rozhnev

1 - General table Users
2 - Teachers
3 - Students
https://sqlize.online/sql/psql11/4cb83c0ff81975c35...

O
Orkhan Hasanli, 2022-04-01
@azerphoenix

Good afternoon!
So
you need 3 models:
1) User (contains common fields) - @MappedSuperclass
2) Student - @Entity
3) Teacher - @Entity
More details - https://www.baeldung.com/hibernate-inheritance

A
Anton Shamanov, 2022-04-01
@SilenceOfWinter

EAV model
Entity - entities/roles: Admin, Student and Teacher
Attributes - special attributes/properties: Classes, Credits (common fields (full name, password) are added to the user table)
EntityAttributes - M:M relationship of attributes and entities
Values ​​- unique attribute values
AttributeValues ​​- association of M:M values ​​and attributes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question