How to represent a many-to-many-to-many relationship

Posted 3 years ago by alex_hill

I am trying to create what I am calling a many-to-many-to-many relationship for lack of a better phrase to use, and would like to know how to create the third link.

I have a User model and a Book model. When a User borrows a Book from the library a book_user table is updated.

Now I want the User to be able to write some Notes (Note model) on that book (which only the user sees when they are logged in).

The problem I am seeing is that the book_user table is not represented by a model, so I can't do a one-to-many relationship on that.

While the Note is one to many with the Book, it is also one to many with the User, and the combined relationship must be true (ie users cant see each other's notes).

Any tips on representing this would be greatly appreciated.


Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.