Im sort of scratching my head on this one. Here’s the scenario. Im using Doctrine and YAML schema files:
I have a table User and a table Event
User looks like this:
User:
columns:
id:
type: integer(7)
email:
type: string(100)
display_name:
type: string(255)
fb_id:
type: string(100)
relations:
Event:
type: many
refClass: UserEvent
Event looks like this:
Event:
columns:
id:
type: integer(7)
initiator_id:
type: integer(7)
loc_latitude:
type: decimal(11)
loc_longitude:
type: decimal(11)
4sq_id:
type: integer(11)
relations:
User:
type: one
local: initiator_id
foreign: id
User:
type: many
refClass: UserEvent
As you can see the problem is this: A User (or ‘initiator’) can start many events, and an event can belong to one User (‘initiator’). However, an event can also have many Users who join it, and a User can Join many events.
So Event and User end up being related in two different fashions. How does this work? Is it possible to do it this way or am i missing something?
I think you just need one many-to-many relationship between the two tables. UserEvent will tell you what users have what events (and vice versa)… and joining through UserEvent and adding WHERE user.id = event.initiator_id will give you access to a user’s initiated events, assuming they also belong to those events.