[eluser]Unknown[/eluser]
Hi guys,
I'm converting to CodeIgnitor, and I can't wait to use DataMapper ORM. Woo who!
I'm learning how to build relationships, but I can't figure out how to use super- and sub-type tables with DM. I've looked around DM's documentation, searched the forum, and googled for answers, but I can't find any ideas.
I'm building a health and wellness website where users have goals. There are several types of goals: exercise goals, nutrient goals, and marker goals. They have attributes in common like "user_id" and "created" columns, but they also have individual data. Here are my tables...
Code:
goals
id
type
client_id
created
amount
frequency
rank
exercise_goals
id
goal_id
exercise_id
unit_id
nutrient_goals
id
goal_id
nutrient_id
marker_goals
id
goal_id
marker_id
unit_id
direction
How do I model those relationships? I'd prefer to keep the super- and sub-type tables because I think it's a more efficient database design. However, I guess the simplest fix would be to repeat the super-type columns in each sub-type table. I can see some of the sub-type tables are simple join/pivot tables (e.g., nutrient_goals). But other tables like marker_goals have extra data (i.e., "direction" column).
Any ideas?
Thanks for your help!