Moodle has many tables, and plugins can add many more. There are a few tables that factor in to almost every task that you do. We will look at these, and their relationships to the other tables, in order to understand the data relationships in Moodle.
Let's take a look at course modules, and the tables that impact each one.
The following screenshot is a data relationship diagram showing the key relationships defined for the course_modules
table. As you can see, this one table has links to five other Moodle tables. Every one of those links refers directly to an id
field in another table.
The instance
field links to the specific module table that the course_modules
record is an instance of. In this case, it is a forum module, but it could be any valid Moodle module. In the following screenshot, the id
field of the forum
table is referenced by the instance
field. The table to be referenced (for example, forum
) is determined from...