The diagram was generated by using the reverse engineering feature of the MySQL Workbench tool using a file containing the SQL code used to install Moodle.
The SQL statements were extracted from the install.xml files from each Moodle module. This was converted from XML to SQL using a utility I wrote as a local Moodle plugin which can be found at
https://github.com/marcusgreen/moodle_local-sqlgenerator. This utility is fairly simple and makes use of the Moodle XMLDB API.
This utility should not be used on a live Moodle site as it has had no checking for security or robustness. Note that some of the table relationships in Moodle are not strictly relational, i.e. some tables may have multiple value fields and there may be missing primary/foreign key relationships. This will result in a diagram where a table has no link to any other table. However this process may still result in a diagram that is useful to understand the database design.
This was done on a Windows 8 /Xampp machine. The reverse engineering
was done with MySQL Workbench 6.2 though I suspect it would work
on other platforms.
Marcus Green 2015