This gives instructions on how to create, set up and populate a database in Moodle.


This refers to Moodle 3.4 from December 2018 onward

How to: create a database activity

Stage 1: Set up the database

  1. Login to your module and click on the Turn editing on button (top right). 
  2. In the relevant section, click on the + Add an activity or resource hyperlink and choose Database 
  3. In General Settings, add the Name of the database (which will display on the main module page) and Description, e.g., to include specific directions on how students might contribute if they are expected to.
  4. Choose any Restrict access settings - Use the dates to restrict access by date if required
  5. Click on the Save and display button to see the database and start setting it up as below.
    (or Save and return to module to go to module front page or Cancel.)

Other settings

You can also add settings to:

Stage 2: Define the fields: 

You create a database by defining a set of fields that make up the database template. Each Field created will have a name and description. (Note that if you later edit the fields in a database template you must click on the Templates tab and use the Reset template button, or manually edit the template, to ensure the new fields are added to the display.)

For a new database, the Fields window will open automatically.

If not, click on the Fields tab.

Under Create a new field dropdown Choose to select the type of field

Field types include: 

Add names, descriptions and any other parameters to the fields and click Add

Continue adding fields.

You can choose which of the fields is used to sort the entries (by default they are listed by time created/added)

Stage 3: Define the templates

Click on the Templates tab. The List template and Single template define the way the database entries are displayed (there are other templates too, probably not needed for basic databases). Once you've defined the fields in step 2 you can often accept the default  templates without having to change anything. (More information on the Moodle site here)

Click Save template for each (normally  List, Single and Add are the only ones needed)

Stage 4: Add or import entries

It's usually a good idea at this stage to add your first entry or a test entry.

You can import multiple entries via a CSV file if you click the "Import entries" link in the Database activity administration block. The easiest way to determine the format of the text file is to manually add an entry to the database and then export it. The resulting export text file may then be edited and used for importing entries.

The expected file format is a plain text file with a list of field names as the first record. The data then follows, one record per line.



omeprazole,suppresses gastric acid secretion,proton pump inhibitor

Records should be delimited by new lines

Note: Certain field types may not be supported (e.g., files and images).

Do not put spaces after your commas or upload will fail!

Click Import entries (as below).  After upload if successful you'll read a message such as "10 entries saved".

See also