How are Moodle tables constructed?

moodleOne of the most important components of Moodle is its database.  This article aims to describe the tables of the database.  I will investigate each table, and comment on the contents.

There are over 280 tables in a default installation of Moodle (I'm using Moodle 2.2.1 for this article), and I will endeavour to give a summary description of each one.


Important Note

To make this article a little easier to read, I have removed the mdl_ prefix.

assignment

Each record in the mdl_assignment table, represents an instance of an Assignment that a course creator has included in a course.

assignment_submissions

Here are records of submissions for each assignment.

backup_*

Moodle has a sophisticated backup environment that makes use of various tables, for logging purposes and other reasons.  Once I understand this area better, I will make more notes!

block

Here there is a record for each Moodle block that includes its name and version number.

block_community

This looks like a table that is used by the Community block

block_instances

This table contains a record for each occurance of a block, including default regions and default weights.

block_positions

This table seems to show a record for each block that is actually deployed on the front-end, including its actual region and weight.

block_rss_client

Don't know, will let you know when I find out!

blog_association

A simple record that links blogs with contexts.

blog_external

Here there are descrete records for a blog entry that has been collected from outside of Moodle.

cache_***

There are a number of tables that presumably support caching in some way.

capabilities

This is a list of over 300 different Moodle capabilities (eg. Backing up an activity, restoring a course etc...).

chat

When you create a new Chat activity at site level, or inside a course, a new record is enterred in this table.

chat_messages

Each individual message is stored in this table.

chat_messages_current

For each chat activity, the most current message is kept in this table.

chat_users

Each member of a chat activity, has a record here.

choice

Each instance of the Choice activity is recorded here.

choice_answers/options

Here are the configuration settings for each Choice activity.

cohort/cohort_members

If you are using the cohort feature, these two tables will store your data.

comments

Each comment is stored in this table.

config

There are nearly 400 different configuration settings stored in this table.

config_log

Each time a configuration for Moodle is modified, the change is logged, showing who, when, old setting and new setting.

config_plugins

Each configuration for a plugin is stored in this table.  These configurations don't seem to be logged in the previous table.

context

Context levels, depth and related instances are kept in this table.

context_temp

Don't know I'm afraid.

course

There is an entry in this table for every course that has been created in your Moodle site.  There are 33 fields for each entry, including creation date and language.

course_allowed_modules

I think this is used to restrict modules that can be used with a particular course.

course_catgories

Here is a list of all course categories.

course_completions

When a student finishes a course, a record is enterred here.

course_completion_*

The completion process is managed using 4 separate tables.

course_display

Not sure what this table is for.  It has 4 fields: id, course, userid, display.

course_modules

Each time a resource, or activity module is instantiated, an entry is maintained in this table.

course_modules_*

For each course_module entry, there can be further configurations in 2 more tables.

course_published

This table seems to be related to Moodle Hubs.  Presumably used if you want to publish a course to a hub?

course_request

Each time a visitor requests a new course be considered, the request is logged here.

course_section

Courses are made up of multiple topics or sections.  Each section has an entry in this table.

data_*

Don't know what these tables are used for?

enrole

Every time a student enroles on a course, an entry is made in this table.

enrole_***

The enrolement process involves several steps, including payment, refund and change of enrolment status.  These processes are stored in 4 separate tables.

event

Calendar events are stored in this table.

events_***

There are 3 more tables that are used to configure/manage calendar events.

external_*

When you use external web services, these tables are used to store your configuration settings.

feedback_*

The Feedback activity uses 9 separate tables.

files

Every time a file is used in Moodle, it is referenced in this table.

filter_active

Entries in this table are used to describe the current status of Moodle filters.

filter_config

This is a table with a number of fields, filter, context, name and value.  I therefore think that this table is used for storing filter configurations.

folder

Each time a resource folder is created, a new entry will appear here.

forum

Every time a forum is created (note that there is a default one for every course), a record is added in this table.

forum_*

There are several other tables, that are used in conjunction with forums.

glossary

Every time you add a new Glossary activity to a course, a new entry is made in this table.

glossary_*

There are 5 more tables, including the glossary_entries themselves that are used to support the Glossary activity.

grade_*, gradingform_rubric_*, grading_*

There are 20 different tables dedicated to the grading process.

groupings, groupings_groups, groups, groups_members

There are 4 different tables that handle the grouping function that can be used in Moodle courses.

imscp

When you create a new IMS Content Package resource, a new entry will appear here.

label

When you add a label resource to a course, it is added to this table.

lesson

For each Lesson activity that you create for any course, a record is enterred into this table.

lesson_*

There are an additional 7 tables, that go to make up the Lesson activity.

license

The license plugin uses various licences that are stored in this table.

log

Almost all visitor interactions are logged in this table.  This table can get large!

log_display

This table configures what should be displayed when looking at logs.

log_queries

I think this table stores log queries, so that you don't have to keep typing the same query many times?

lti_*

There are 4 tables that together hold configurations for accessing remote Learning Tools Interoperability (LTI) resources.

message

Each time a user sends a message to another user, the message is stored here.

message_*

There are 5 additional tables that allow further configuration of the Message function.

mnetservice_enrol_*, mnet_*

The MNet configurations are stored in thirteen different tables.

modules

Here is a list of all resource and activity modules.

my_pages

When a student changes their home page, an entry will appear in this table.

page

Don't know yet what this table is for!

portfolio_*

There are 6 tables that support the Portfolio plugin.

post

Blogging posts are stored here.

profiling

This table stores performance profiling results.

qtype_essay_options

This table stores additional options for essay questions.

question_*

There are 25 tables that support all the different types of questions.

quiz_*

There are 11 tables for the quiz activity.

ratings

Ratings are used throughout Moodle.  When you make a rating, it is stored in this table.

registration_hubs

This table is used in conjunction with Community Hubs.

repository_*

The repository feature of Moodle, uses 3 separate tables.

resource

Each record is a resource with its configuration.

resource_old

Backup of old resources from Moodle 1.9.

role_*

There are 7 tables that come together to manage the Moodle role system.

scale

One entry for each configured Moodle scale.

scale_history

Logged configurations for the scale feature.

scorm_*

There are 11 SCORM tables.

sessions

Details of your visitors session of interaction, are logged here.

stats_*

There are 6 tables that populate your stats data, if you've enabled statistics for your Moodle site.

survey_*

The survey activity uses 4 tables.

tag

All tags are stored in this table.

tag_*

Tags are further configured with 2 more tables.

timezone

Over 2,000 timezones are stored in this table.

tool_custom_lang

Not sure about this one.  Clearly it's something to do with language, presumably related to Moodle tools?

upgrade_log

This table logs the upgrade process.

url

For each URL resource, there is a record in this table.

user

Each Moodle user has an entry in this table.  Even users who are authenticated externally.

user_enrolments

When a user enrols on a course, an entry is made in this table.

user_info_*

Additional information about users is configured with 3 tables.

user_lastaccess

This table keeps a running list of the last time a user logged on to this Moodle site.

user_preferences

This table stores user preferences.

user_private_key

Access keys that can be used instead of cookies.

webdav_locks

Locks for the webdav resource.

wiki_

There are 7 tables for managing wiki content.

workshop_*

There are 21 tables for managing the Workshop activity.

 

Thanks for visiting.