What is the best way to setup my tables and relationships for this use case?

Posted by Dustin Brewer on Stack Overflow See other posts from Stack Overflow or by Dustin Brewer
Published on 2010-04-30T16:28:22Z Indexed on 2010/04/30 16:47 UTC
Read the original article Hit count: 235

Filed under:
|
|
|

1)A user can have many causes and a cause can belong to many users.

2)A user can have many campaigns and campaigns can belong to many users. Campaigns belong to one cause.

I want to be able to assign causes or campaigns to a given user, individually. So a user can be assigned a specific campaign. OR a user could be assigned a cause and all of the campaigns of that cause should then be associated with a user.

Is that possible? And could I set it up so that the relationships could be simplified like so:

User.causes = all causes that belong to a user

User.campaigns = all campaigns that belong to user whether through a cause association or campaign association

© Stack Overflow or respective owner

Related posts about ruby

Related posts about rails