Moodle supports a variety of SQL databases to store program information. To do that, Moodle provides powerful code libraries to let you write database-agnostic code. Moodle also enforces strict database layout design, allowing you to understand table structures easily. We will examine Moodle's database structures, policies, and libraries in order to better understand how to build our code.
This chapter covers the following topics:
Overall structure of the Moodle database
Coding methods and APIs for accessing databases
Tools and programming tricks to help with your development projects
Every data table in Moodle has one common element: the first field is an integer field called id
. This field is a unique field that serves as the Primary Key for every table. It also serves as the Foreign Key to any other data table that contains a reference to that table.
Although this may seem excessive to some database programmers, as there are...