Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Student projects/SQLite.

Student projects/SQLite

From MoodleDocs
Revision as of 06:29, 12 May 2008 by Andrei Băutu (talk | contribs) (About SQLite support)

Note: This page outlines ideas for the XMLDB/SQLite project. It's a specification under construction! If you have any comments or suggestions, please add them to the page comments.

Summary

This project is part of the 2008 edition of Google Summer of Code (GSoC). Mentor: Penny Leach. Student: Andrei Bautu.

The objective of this project is to extend Moodle's database support and features. The main working directions established in the proposal are:

  • implement SQLite in Moodle database abstraction layer;
  • implement a tool which will allow administrators to copy a live Moodle database and switch into 'testing mode' using a SQLite copy of the live database.

SQLite support

Adding support for SQLite in Moodle requires a careful analysis of compatibility between Moodle's database requirements and SQLite's features (e.g. https://docs.moodle.org/en/Development:XMLDB_problems).

SQLite supports almost all of the features of SQL92. However, we can't ignore the features it does not support as some of them are used by Moodle (http://www.sqlite.org/omitted.html):

  • proper settings for Unicode support, long field names, numeric/associative fetches, metadata support -> solution: use pragma commands;
  • incompatible SQL commands (e.g. SQLite does not support MySQL's TRUNCATE because it is not part of standard SQL) - > solutions: rewrite the SQL command (recommended) or alter the query in the database layer;
  • unsupported SQL commands (SQLite does not support GRANT/REVOKE) -> solution: ignore these commands in database layer;
  • unsupported SQL keywords (SQLite does not support right and full join) -> solution: rewrite the SQL command (e.g. use left join instead of right), or alter the query in the database layer (althought, in some cases it can be very difficult).

A serious limitation of SQLite is the limited ALTER TABLE command. In this case, the general solution for the missing clauses problem consists in replacing the query with a series of queries that will create a second table to replace the original one. This will be done by the database layer.

See also