I am working on a system that allows users to track their musical practice. The system allows users to create 'exercises' that store a few pieces of information like name, description and external links. These exercises are created by the user and will belong to the user: the user ID is a property of the exercise (one-to-many). When a user searches for exercises, the system only shows him the exercises that have a matching user ID.
I have now introduced the concept of student and teacher users. I would like teachers to be able to share some of their exercises with their students as they see fit.
The way I have implemented this at the moment is:
- create a class that represents a student/teacher membership (typical many-to-many)
- subscribe a student to a teacher
- edit the service that gets the exercises for a user to also include all exercises from any teacher the student is subscribed
This works fine, but it doesn't allow teachers to decide which exercises the student can see, as the student will see all the exercises from the teacher.
I was thinking of creating another 'membership' class that I can use to register a user to an exercise, which would achieve the goal. However, I don't like this idea as things would get a bit messy:
- if memberships are used to get the relevant exercises, then it would make more sense to use memberships for exercises that the user itself created, instead of saving the user ID on the exercise itself
Essentially, I now need a many-to-many relationship between user and exercise and I cannot think of another way to achieve it other than what I mentioned before (remove the user ID from the exercise object and create a membership class to assign exercises to users, so that now exercises can have multiple users that can access them)
Here is a diagram showing the objects and how they relate to each other (ignore the other objects, I included them to give more context):
This is an example of a possible scenario with different students and teachers:
Does the above sound like a sensible approach?
I'm afraid I might be missing some basic key social media concept that would make this problem easy to solve, as I think this is a very similar problem to 'how to share a post with only some other users' on a social media platform.