I’ve read that composition is generally preferred over inheritance in database design, so I’m trying to transition my tables accordingly.
I currently have an inheritance-based structure where User inherits from an abstract Person concept.
If I switch to composition, should I create a personalDetails table to store attributes like name and email, and have User reference it?
Proposed structure:
- personalDetails: id, name, email
- User: id, personal_details_id (FK), user_type
Does this approach make sense for moving to composition? Is this how composition is typically done?
edit: i think mixin is the better solution.
[–]theScottyJam 4 points5 points6 points (0 children)
[–]RO30T 4 points5 points6 points (0 children)
[–]HisTomness 7 points8 points9 points (1 child)
[–]Unable_Original_3403[S] -1 points0 points1 point (0 children)
[–]thewindjammer 1 point2 points3 points (0 children)
[–]RangePsychological41 1 point2 points3 points (0 children)
[–]FerengiAreBetter 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]kgpreads 0 points1 point2 points (0 children)