You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a user signs up with my app he can create either a personal or a business profile.
Three types of models exist in the code:
User (general sign-up information)
Person (personal information, only applies to personal accounts)
Business (business information, only applies to business accounts)
So the User model can have a HasOne relationship to a Person model, OR a Business model, but not both.
Having trouble to implement this. Maybe there is a flaw in my database schema design.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When a user signs up with my app he can create either a personal or a business profile.
Three types of models exist in the code:
So the User model can have a HasOne relationship to a Person model, OR a Business model, but not both.
Having trouble to implement this. Maybe there is a flaw in my database schema design.
Schema of persons table has:
Schema of businesses table has the same:
Both models have:
I would like to avoid introducing an extra pivot table for this. What is the correct way of implementing this?
EDIT
I have come across the
inherits
feature of Lucid https://lucid.adonisjs.com/docs/table-builder#inherits... but it's lacking a bit of documentation, and I'm unsure of the implications of using it.
Beta Was this translation helpful? Give feedback.
All reactions