jeudi 3 septembre 2015

Role based model for entities with different fields

I would like to ask question about role-based database model for entities with different fields. I am designing a web-application with multiple different roles and each entity in given role is storing different information. E.g. entity in role customer has name, e-mail and phone number and entity in role manufacturer has address. My problem is to define database model for this situation. I have thought about creating table user with columns id, role, login, password then table customer with columns name, e-mail, phone number and table manufacturer with columns address. In addition there will be tables user_customer and user_manufacturer with one to one relation to corresponding tables. But in this case it would be possible to have row in table user with column role equal to manufacturer and relation to table customer. Is there any universal pattern to solve this problem? Thanks for answers and solutions.

Aucun commentaire:

Enregistrer un commentaire