I am developing a library system that includes both employees and users, each sharing 5 identical attributes. I'm considering creating a 'person' entity to hold these attributes and establishing a one-to-one relationship with the 'employee' and 'user' entities, allowing them to have a person-type identifier. Would this be the correct approach, or is it better to maintain the two separate entities?
I have already searched how to create a form to save data in two different tables. However, I acknowledge that this solution is applicable to traditional applications
Hello Bruno,
This is a very interesting question.
Both data models would work, I believe the decision just depends on the pros and cons of having one or another. Meaning which one is going to facilitate your queries to the database and your logic overall.
Let's say you have a screen where you'll list all the employees and another screen where you'll list all the users... Then there's no point of having a single table to store both of these concepts. Queries and screen rendering will take longer because you have more records in one single table. In this case, you should separate them.
However let's say that both of these concepts are strongly connected and you have a screen where you show both employees and users in the same listing. Or you have a timer that processes both employees and users personal data. It would be better for you to have a single table instead.
Assuming it's just to maintain 5 common attributes, if your app is quite simple and both concepts are not somehow connected, I'd keep them separated. But it all depends on your app and what you're trying to achieve.
Kind regards,
Rui Barradas
I understood your explanation, thank you!
Hi Burno,
It depends on the business context. What are the differences between employees and users? would employees also be the users?
Best regards,
Sam
Users are the people who borrow books. However, the relationship isn't between employees and users. Instead, it's a one-to-one between people and employees, as well as people and users. The only use of the 'person' table would be to maintain these common attributes.
I'm not very proficient in English.
If so, I would keep it simple and have 2 separate entities of employee and user.
I understand, thank you very much.
Hello
This is totally depends on the requirement. for example -
I hope this helpsThanksTousif Khan
Please keep the comments in English so every community member can understand and participate in the thread :)
Thanks!