users and another one for lessons. The users table can contain a type
column, with possible values teacher or student. Here is how it could look:
Lessons are assigned by teachers and completed by students. The
lessons table
has both teacher_id and student_id, which are actually references to the
user id. The lessons table can look like this:
The best way to design such a data model is by using what we call Polymorphic
Cubes. It relies on the
extends feature and
prevents you from duplicating code, while preserving the correct domain logic.
Learn more about using extends here.
The first step is to create a user cube, which will act as a base cube for our
teachers and students cubes and will contain all common measures and
dimensions:
teachers and students cubes from users:
lessons cube: