{"id":132,"date":"2026-05-27T18:28:50","date_gmt":"2026-05-27T18:28:50","guid":{"rendered":"https:\/\/www.flossed.uk\/blog\/?p=132"},"modified":"2026-05-27T18:31:45","modified_gmt":"2026-05-27T18:31:45","slug":"documenting-the-moodle-database","status":"publish","type":"post","link":"https:\/\/www.flossed.uk\/blog\/index.php\/2026\/05\/27\/documenting-the-moodle-database\/","title":{"rendered":"Documenting the Moodle database"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">AI and the Moodle database documentation<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For over 21 years I have been working on maintaining some documentation of the Moodle database structure.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I have just released an update for the recent release of Moodle 5.2, which you can see here<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.examulator.com\/er\/output\/index.html\" target=\"_blank\" rel=\"noopener\">https:\/\/www.examulator.com\/er\/output\/index.html<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I am interested in learning analytics and tools for querying Moodle data and the first step is to understand how the data is structured.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You might think that documenting the database would be a trivial activity, but due to mainly historical reasons it is fairly complex. A fresh install with no plugins creates around 500 tables. The relationships between tables are discarded during the installation process. There is no database level referential integrity, it is all done at the application level.&nbsp;&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This means you cannot use a standard database tool to use those relationships when creating queries. My process restores those relationships in the documentation which is helpful for query building..<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In addition to processing the data in the Moodle installation files I add approximatly 70 additional implied table relationships and links to sources for database queries in the Moodle documentation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can see the implied relationships I add here<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/marcusgreen\/moodle_local-sqlgenerator\/blob\/master\/morekeys.xml\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/marcusgreen\/moodle_local-sqlgenerator\/blob\/master\/morekeys.xml<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can see the ER diagrams by scrolling to the end of any of the table pages, This is part of the diagram for the core quiz module.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"704\" src=\"https:\/\/www.flossed.uk\/blog\/wp-content\/uploads\/2026\/05\/image-6-1024x704.png\" alt=\"\" class=\"wp-image-137\" srcset=\"https:\/\/www.flossed.uk\/blog\/wp-content\/uploads\/2026\/05\/image-6-1024x704.png 1024w, https:\/\/www.flossed.uk\/blog\/wp-content\/uploads\/2026\/05\/image-6-300x206.png 300w, https:\/\/www.flossed.uk\/blog\/wp-content\/uploads\/2026\/05\/image-6-768x528.png 768w, https:\/\/www.flossed.uk\/blog\/wp-content\/uploads\/2026\/05\/image-6.png 1352w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The tools and techniques I have used over that time have changed and evolved and since 2014 I have maintained a custom plugin to help with the task. I have had various ideas for improving on this plugin over the years but have done little to it due to time constraints.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The arrival of LLM\/AI assisted development has allowed me to make improvements in the latest version. The changes have taken a small number of days to complete and without AI it would have taken a small number of weeks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It now includes the ability to extract the default data from a fresh install and create a file describing that data. For each table that includes this type of data there is now a link to it. The whole file set can be downloaded for local use and there is a link to the current and archive file here<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.examulator.com\/er\/archive.html\" target=\"_blank\" rel=\"noopener\">https:\/\/www.examulator.com\/er\/archive.html<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This version includes a link at the top called Changelog which describes what has changed since the last Moodle release.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I am currently investigating how to use the database structure information and an external AI\/LLM system to make it easier to create queries and Moodle reports.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AI and the Moodle database documentation For over 21 years I have been working on maintaining some documentation of the Moodle database structure.&nbsp; I have just released an update for the recent release of Moodle 5.2, which you can see here https:\/\/www.examulator.com\/er\/output\/index.html I am interested in learning analytics and tools for querying Moodle data and &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.flossed.uk\/blog\/index.php\/2026\/05\/27\/documenting-the-moodle-database\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Documenting the Moodle database&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-132","post","type-post","status-publish","format-standard","hentry","category-uncategorized","entry"],"_links":{"self":[{"href":"https:\/\/www.flossed.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.flossed.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.flossed.uk\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.flossed.uk\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.flossed.uk\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=132"}],"version-history":[{"count":4,"href":"https:\/\/www.flossed.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/132\/revisions"}],"predecessor-version":[{"id":138,"href":"https:\/\/www.flossed.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/132\/revisions\/138"}],"wp:attachment":[{"href":"https:\/\/www.flossed.uk\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.flossed.uk\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.flossed.uk\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}