Records creates double entry, should only be one Need an assist on a database design.

I'm creating a system to track students in a course.

Currently, I have courses.  Courses are made up of modules. A given module can be in multiple courses (eg 2 courses have the same module, so students from both course A and course B are in module Z.  

Students are enrolled in modules.  So student john gets enrolled into all the modules that makeup course A.

However, when I put john into module Z, he shows up in course A and course B, even though he should only show in course A.

Currently, I have a student table, a module table, and a course table, linked together with a studentinmodule and moduleincourse table (both many to many).  

Any insight into how to redesign so a module can be in multiple courses, but a student enrolled in a module only shows up in one course?
If you link Student-->Course-->Module, you would avoiding having Module Z causing both Course A &amp; B to show up for that student.

Alternatively, you could slightly modify the current to have Student-->(Module &amp; Course). If your Enrollment table includes all three identifiers, it would be trivial to determine if the student is enrolled in Module Z because they are also enrolled in a specific class, or because they are enrolled in the module directly, rather than via a class.