XMLデータベーススキーマ

提供:MoodleDocs
移動先:案内検索


作成中です - Mitsuhiro Yoshida 2006年10月27日 (金) 19:09 (CDT)

Moodle 1.7の新しい機能は、MySQLおよびPostgreSQLを正常に動作させながら、さらにいくつかのRDBMS (MSSQL and Oracle)でも動作することができるようになることです。Moodleコアでは、内部でADOdbを使用するため、最初からこの可能性が存在し、現在の成熟したプロジェクト ( 5 years old baby! ) でも同じです。これは、すべてを整理する良いタイミングであり得ます。

はじめに、すべての私たちのテストおよび準備作業は、ADOdbがどのように動作するか、そして4つのRDBMSをどのように混在させMoodleの他の部分でどのように使用するか調査することでした。4つのRDMBSのSQLは、非常に類似していますが、いくつかの違いおよび特異性のため、現在のデータベースコード ( 以前の datalib.php ) を変更する必要があります。

All the changes to be performed, which primary objective is to enable Moodle to work with more RDBMS must be be filled following the next non-functional requirements:

  • Provide one layer (new) for DB creation/upgrade (DDL): With this, developers will create their structures in one neutral form, independent of the exact implementation to be used by each RDBMS.
  • Provide one layer (existing) for DB handling (DML): With this, developers will request/store information also in one nuetral form, independent of the RDBMS being used.
  • Easy migration path from previous versions: The current installation/upgrade system will work until, at least, Moodle 2.0, allowing 3rd part developers to migrate along the time to the new system.
  • Simple, usable and effective: Until now, the way to upgrade Moodle has been really cool and it has worked pretty fine since the beginning, but it has forced developers to maintain at least two installation and two upgrade scripts for each module/plugin. The new alternative will have only one file to install and one file to upgrade (per modude/plugin too), reducing the possibility of mistakes in an high degree.
  • Conditional code usage must be minimised: Database libraries must accept 99% of potential SQL sentences, building/transforming them as necessary to work properly under any RDBMS. The number of places using custom (per DB) code should be minimum.
  • Well documented: All the functions defined, both at DML and DDL level must be well documented, helping the developer to find and use the correct one in each situation.

スタック

The next stack shows how Moodle 1.7 code will interact with underlying RDBMS. It will help us to understand a bit more what we are trying to do and will explain some of the points related in the Roadmap (below in this page).

https://docs.moodle.org/en/images_en/a/ad/MoodleDBStack.png

Moodle code will use two languages to perform its DB actions:

  • XMLDB neutral description files: To create, modify and delete database objects (DDL: create/alter/drop tables, fields, indexes, constraints...). It consists in a collection of validated, standard, XML files. They will be used to define all the DB objects. New for 1.7.
  • Moodle SQL neutral statements: To add, modify, delete and select database information (DML: insert/update/delete/select records). To modify for 1.7.

Please note the neutral keyword used in the expressions above. It means that both languages will be 100% the same, independently of the underlying RDBMS being used. And this must be particularly true for the XMLDB part. Point.

Obviously it's possible that in the SQL part we found some specialised queries (using complex joins, regular expressions...) that will force us to do some Exceptions. Well, they can exist (in fact, they exist), but we always must try to provide an alternate path to minimise them using neutral statements and standard libraries.

Each one of the languages above will use its own library to do the work:

  • Moodle DDL Library (ddllib.php): Where all the functions needed to handle DB objects will exist. This library in new for 1.7 and will provide developers with an high level of abstraction. As input it will accept some well defined objects and actions and it will execute the proper commands for the RDBMS being used.
  • Moodle DML Library (dmllib.php): Where all the functions needed to handle DB contents will exist. This library is new for 1.7, although its contents are, basically, functions currently present in datalib.php (moved from there). All those DML functions will offer cross-db support for insert/update/delete/select statements using a common behaviour.

Also note that datalib.php continues present in the schema above. It will contain all the functions that haven't been moved to the new ddllib.php and dmllib.php libraries. Only some common functions will remain there, and this situation will disappear (it's considered a legacy library) in upcoming Moodle releases (after 1.7) by moving all those functions to their proper library (course/lib.php, user/lib.php....).

Both this libraries (plus the small Exceptions bar) will perform all their actions using the ADOdb Database Abstraction Library for PHP that will receive all the request from them, communicate with the DB (MySQL, PostgreSQL, Oracle or SQL*Server), retrieve results and forward them back to originator library.

プロセス

  • Roadmap: Where the whole process is defined. It has been splitted in small chuncks to be performed and tested easily. Also, such documents should be used to track what's done and what's pending following some easy nomenclature.
  • Problems: A comprensive list of issues that need to be determined/solved prior to incorporate them to the roadmap.

関連情報

XMLDB関連

  • XMLDB preliminary links - A collection of links about general info, searched and analysed at the initial stages of the project
  • XMLDB preliminary notes - A collection of notes collected in the early stages of this project, pointing both to some changes required and some problems to solve.
  • XMLDB column types - Some links about column types inside every RDBMS and their characteristics
  • XMLDB key and index naming - Some info about automatic naming of keys/indexes and other objects.
  • XMLDB reserved words - A collection of reserver words inside each RDBMS

データベース関連

  • DDL functions - Documentation for all the Data Definition Language (DDL) functions available inside Moodle.
  • DML functions - Documentation for all the Data Manipulation Language (DML) functions available inside Moodle.