Refactoring to have multiple classes

Moved inner classes our of EntityRelation to have make the example more
student-friendly.