If you don't use the builder, it is quite exhaustive work
If you goal is to discover / learn ORM, then you don't need to build all these pages (forms / layouts), just populate your database, and debug the datas.
This can help you for debug :
Place this in the model you want to debug SQL
$this->setState('debug.query', true);
But this will NOT show you the relations.
The relations are created into "loadRelations()" and "loadRelation()"
There you can dump your SQL for understanding ORM and helping you to debug your problem.
So... For helping you better, please first use the builder for designing these relations (forms / layouts), and then populate some datas in the pivot tables (in the sandbox)
Once you've done that, I can have further look.
Normaly you don't need to write a line of code (100% handled by the builder)