Skip to main content

Incorrect setup for Model associations

Databases • Asked by Masud Hossain

I feel these associations are incorrectly set up. It's a bit similar to Trello, except I'm adding in a 'client' model too. The main part that's confusing to me is the fact user.rb, it's just bugging me.

https://docs.google.com/spreadsheets/d/17HLjRnIrs-lf_nNwJKj3ijkC2HnfEmti2wVFdx6kG9Y/edit?usp=sharing

What it's suppose to do:

  1. A user can create a business and belong to it as an employee.
  2. A business can have multiple employees (and a user belongs to that specific employee).
  3. A business can have multiple clients (and a user belongs to that specific client).

Is there a more efficient way to set this up?



@Tabish Iqbal,

do you mind showing me how the models would be set up? I don't seem to understand how the self joins would work in this case.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 22,346+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.