I want to store the details of college courses in a (MySql) database but I\'m not sure how to maintain the relationship between modules and selections.
Basically, a cour
You can create a recursive table structure here, wherein Options reference their parent options.
The "main" options can then be identified by querying this table for all options with "null" parents.
The "and-or" relationships can be implemented by a separate "option-set" table, where the primary key is to an "option". The option-set table's with null self-references are the "root" point for defining a course's options. From that point, you will select option-set records with parent = root. This will be the first "level" of options. Some will be mandatory, some won't. To express that, you will have to have a boolean attribute on the option-set table as a flag. Thus each option-set is defined in terms of smaller option-sets. Of course, ultimately, once you get to the bottom, your option-set's will define an actual class at some point.
I would suggest that this can much more effectively be modelled in JSON or XML, since those data structures support hierarchies in a much more expressive manner.