Welcome Guest, Not a member yet? Register   Sign In
Datamapper ORM Multi-tabel Relationship Halp!
#3

[eluser]Genki1[/eluser]
Hi WanWizard,

This is a good post for illustrating relationships. I have a slight variation and wonder, do I need a custom join table?

Example scenario: a User can purchase many website Templates. Each Template can be used by many Users. Each User specifies many configuration Options for each of their Templates.

Quote:User -> has many -> Templates
Templates -> has many -> Users
Templates -> has many -> Options
Options -> has one -> User
Options -> has one -> Template

Desired usage: Show me all of the Options for this User's Template.

In order to connect all three tables, do I need to use a multi-relationship join table like this:

join table: "users_templates_options" (per DM guidelines, the names would be in alphabetical order)

Code:
[id] [user_id] [template_id] [option_id] [value_for_this_template_option]
  1       1         1             1        Some data
  2       1         1             3        more stuff
  3       1         2             1        Maybe my name here
  4       1         2             5        contact info
  5       2         1             1        Yet more user data


Messages In This Thread
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 07-27-2011, 12:34 PM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 07-28-2011, 02:04 AM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-04-2011, 07:18 PM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-05-2011, 04:49 AM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-05-2011, 08:54 AM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-05-2011, 11:37 AM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-06-2011, 03:44 AM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-06-2011, 04:01 AM
Datamapper ORM Multi-tabel Relationship Halp! - by El Forum - 08-06-2011, 01:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB