Here is the model used for this demo. There is differents relations type:
- Books -> Serie: OneToMany -
a book can be in a serie, a serie may have many books
- Books -> Reviews: OneToMany -
one book can have many reviews, a review is for only one book
- Books -> Authors: ManyToMany through ProjectBookCreation join table that contains extra fields (so it's OneToMany between Book and ProjectBookCreation, and OneToMany between Editors and ProjectBookCreation -
a book can have many authors, an author can write/draw/colorize many books
- Books -> Editors: same as Authors but with ProjectBookEdition -
a book can be published by many editors, an editor can publish many books
- Books -> Tags: ManyToMany auto managed with Doctrine -
a book can have many tags, a tag can be applied to many books
- Readers -> Books: ManyToMany -
a reader can own many books, a book can be owned by only one reader
- Readers -> Loan: OneToMany -
a reader can loan/borrow many books a to/from many readers
You may find it strange that Readers and Books is a ManyToMany relatinship. This is just to simplify the sample. In fact in a real library, a book can be owned by only one reader. To do that, i should link Readers to a ProjectBookEdition, and not a simple Book. This is because a Reader may owned a Book in different Edition. So we should also add extra properties like a date_entry and a price per example. So the relation between Readers and Books is more complex than it appears first.
I will certainly improve this in future, but i wanted the sample to be as simple as possible, but not too much to be able to see some complex relations.