For example, let's say I have a User model. Users have things like logins, passwords, email addresses, avatars, etc. But there are two types of users who will use this site, let parents and enterprises say. I need to store some other information for parents (for example, names of children, internal partner, salaries, etc.), than for enterprises (for example, industry, number of employees, etc.), but also some of them are the same. like logins and passwords.
How to properly structure this in a SQL database? Thank!
- UPDATE -
After digging a little more, I think polymorphic association may make sense. But I don’t know much about them, is there a reason why I would not want to use them, or that an STI is better? They seem to be exactly the same, except that fields specific to parents or enterprises are stored in separate tables, and I think this is what I would like. Is not it?
source
share