Database structure The Moodle database has around 200 tables, and can be quite daunting at first sight. The good news is that you don't have to understand it all at once. For example, there are eight tables called forum_something. If you are interested in the forum module, then obviously you need to understand these tables, and the places they link into core tables. But if you are not interested in the forum module, you can forget about them. The same is true of each activity module. Once you take out the tables for each activity module in this way, and similarly take out the tables belonging to the enrolment plugins, question types, etc. You are left with about 50 core tables. But the good news is that even here they break down into groups that mostly you can understand together, or ignore. This page lists the core database tables in these groups. Later, it would be good to add more detailed documentation explaining some of these groups. The database structure is defined, edited and upgraded using the XMLDB system. 1 Automatically generated documentation 2 Configuration 3 Users and their profiles 4 The roles and capabilities system 5 Courses and their organisation into categories 6 Activities and their arrangement within courses 7 Groups and groupings 8 The logging system 9 Blocks system 10 Events 11 Backup and restore 12 Statistics 13 Tags 14 Gradebook 15 Question bank and question engine 16 Messaging system 17 Moodle Network 18 Caching 19 Miscellaneous 20 Activity modules 21 Authentication plugins 22 Blocks 23 Enrolment plugins 24 Question types 25 See also Automatically generated documentation] The install.xml files that define Moodle's database structure (are supposed to) contain comments on each table and database field, to document their purpose. From Moodle 2.0 onwards, you can view this documentation in HTML format by going to Administration -> Development -> XMLDB editor and then clicking on the [Doc] links. Configuration] config config_plugins Users and their profiles] user user_info_category user_info_field user_info_data user_lastaccess this is separated from the user table for performance reasons user_preferences user_private_key ER Diagram of the Users and profiles tables The roles and capabilities system] role defines a role, its name, etc. Other parts of the role definition are stored in the role_capabilities and role_context_levels tables. capabilites the various permissions that can be granted. context a context is a scope in Moodle, for example the whole system, a course, a particular activity. The type is given by contextlevel, and depending on context level, instanceid points to one of a number of different tables. role_allow_assign which roles can assign which other roles role_allow_override which roles can override which other roles role_allow_switch which roles can switch to which other roles (Moodle 2.0 onwards.) role_assignments which users are assigned which roles in which contexts role_capabilities the permission for each capability in either a role definition (if contextid points to the system context) or a role override (if contextid points to some other context) role_context_levels the context levels at which each role can be assigned. (Moodle 2.0 onwards) role_names used to implement the feature where roles can be given different names in different courses (or, more gererally, contexts) role_sortorder is not actually used anywhere in the code! The following diagram shows the tables with their columns and the relationships between them, and other tables in Moodle. Courses and their organisation into categories] course course_categories course_display course_meta course_request Activities and their arrangement within courses] (Here is the Dia file, should you need to edit this image: File:Course modules database.dia.) modules course_allowed_modules course_modules course_sections See also the tables belonging to particular activity modules. For example forum_*, quiz_*, etc. Groups and groupings] groups groups_members groupings groupings_groups ER Diagram of the Groups system The logging system] log log_display Blocks system] block block_instance block_rss_client block_pinned block_search_documents Some particular blocks also have their own database tables. For example block_rss_client. See: ER Diagram of the Blocks system Development:Blocks#Database support Unit 7 - Part A - Block Basics of the Introduction to Moodle Programming course. Events] event events_handlers events_queue events_queue_handlers Backup and restore] backup_config backup_courses backup_files backup_ids backup_log ER Diagram of the Backup system Statistics] stats_daily stats_monthly stats_user_daily stats_user_monthly stats_user_weekly stats_weekly Tags] tag_* Gradebook] grade_* ER Diagram of the Gradebook system Question bank and question engine] Note that the tables for the core question bank, and also the tables for the individual question types, all have names starting with question_, however, it is easier to think of them separately. question question_answers question_attempts question_categories question_sessions question_states See below for a list of question type tables. Messaging system] message_* Moodle Network] mnet_application mnet_enrol_assignments mnet_enrol_course mnet_host mnet_host2service mnet_log mnet_rpc mnet_service mnet_service2rpc mnet_session mnet_sso_access_control ER Diagram of the MNet system Caching] cache_filters cache_flags cache_text Miscellaneous] scale scale_history sessions2 timezone post Activity modules] Assignment Chat Choice Data Feedback Forum Glossary Hotpot Label Lesson Quiz Resource SCORM Survey Wiki Workshop Authentication plugins] ... Blocks] block block_instance block_pinned block_rss_client block__search_documents Enrolment plugins] ... Question types] Calculated Matching Multiple choice Multi-answer (Cloze) Numerical Random short-answer matching Short answer True/false See also] ER Diagram of the installed system - a single big png image Development:Database_Schema - some automatically generated diagrams. Development:XMLDB_Documentation - the XMLDB system used to define, edit, and update the database structure. Database FAQ Source: docs.moodle.org/503/en/Database structure — MoodleDocs (GPL) · Imported 2026-11-10.