XMLDBイントロダクション

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


作成中です - Mitsuhiro Yoshida (トーク)

Moodle 1.7における新しい主要な機能は MySQL および PostgreSQL ですべてが正常に動作するよう管理されてきたのに対して、 さらにいつくかの RDBMS (MSSQL および Oracle) でも動作するようになったことです。Moodleコアは内部的にADOdbを使用していたため、この機能は当初より存在していました。現在のプロジェクトの成熟度 (5歳です!) を考えて、すべてを整理する良い機会だと思います。

I当初、私たちのすべてのテストおよび事前作業は内部的にはADOdbがどのように動作するのか、そして、SQLに方言を持つ4種類のRDBMSをどのように統合できるか、そして残りのMoodle内でどのように使用されるか調査するためのものでした。SQLはすべて極めて類似していますが、私たちの現在のデータベースコード (以前は「datalib.php」) を変更せざるを得ない異なる部分および独自性がありました。

実施されるすべての変更の第一の目的はMoodleがさらなるRDBMSで動作可能にすることにあります。その変更は以下の非機能的要求を満たす必要があります:

  • 1DB作成/アップグレードあたり1レイヤを提供する (DDL): これにより、開発者は各RDBMSで使用される厳密な実装から独立した中立的な形で自分の構造を作成できます。
  • DBハンドリングに1レイヤ (既存) を提供する (DML): これにより、開発者は中立的および独立した形で使用されるRDBMSの情報をリクエスト/保存できます。
  • 前のバージョンからの簡単な移行手順: 現在のインストレーション/アップグレードシステムは少なくともサードパーティの開発者が新しいシステムに移行可能なMoodle 2.0までは動作します。
  • 単純、便利、効果的: 最初からMoodleのアップグレード方法は極めて洗練されて素晴らしく動作していました。しかし、これは開発者にモジュールおよびプラグインに関して2つのインストールおよびアップグレードスクリプトのメンテナンスを強制するものでした。新しい代替手段ではインストールおよびアップグレードに1つずつファイルを持つため (モジュール/プラグインに関しても)、ミスの発生する可能性を劇的に減らせました。
  • 条件付きコードの使用は最小限にすべき: データベースライブラリは潜在的なSQL文を99%受け入れるため、RDBMSで適切に動作するよう必要に応じてSQL文を構築および変換してください。データベースごとのカスタムコードを使用する場所は最小限にしてください。
  • 十分なドキュメント: すべての定義済み関数はDMLおよびDDLレベルで十分にドキュメントを作成してください。ドキュメントにより開発者が様々な場面で正しい関数を探して使用できるようにします。

スタック The Stack

次のスタックはMoodle 1.7のコードがどのように実装されているRDBMSと相互作用するのか表示します。これは私たちが試そうとしていることに対する理解を少しだけ手助けします。また、ロードマップ (以下のページ) の一部を説明します。

MoodleDBStack.png

Moodleコードはデータベース操作を実行するため2つの「言語」を使用します:

  • XMLDB中間説明ファイル: データベースオブジェクトを作成、修正および削除するため (DDL: テーブル、フィールド、インデックス、制約等の作成/変更/ドロップ)。これは有効な標準XMLファイルで構成されます。また、すべてのデータベースオブジェクトの定義に使用されます。Moodle 1.7の新機能です。
  • Moodle SQL中間説明ファイル: データベース情報を追加、修正削除および選択するため (DML: レコードの追加/更新/削除/選択)。Moodle 1.7で更新されます。

上で使用されているキーワード「中間」に留意してください。基本的なデータベース使用の独立性に関して両「言語」は100%同じ意味です。そして、特にXMLDPの部分に関して明確に同じ意味です。

明らかにSQLの部分において私たちは何らかの「例外」を強制するための特別なクエリ (複雑なJOIN、正規表現等) を見つけることができます。確かに特別クエリは存在できますが (実際に存在しますが)、私たちは常に中間説明および標準ライブラリを使用して特別クエリを最小化する代替パスを提供すべきです。

上の各「言語」は動作するため独自ライブラリを使用します:

  • Moodle DDL Library (ddllib.php): Where all the functions needed to handle DB objects will exist. This library is new for 1.7 and will provide developers with a 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 DDLライブラリ (ddllib.php): DBオブジェクトの処理に必要な関数すべてを含みます。このライブラリはMoodle 1.7の新しい機能であり、開発者に高いレベルの抽象化が提供されます。入力として正しく定義されたオブジェクトおよび操作を受け入れます。また、RDBMSで使用される適切なコマンドを実行します。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 is still 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 these 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 of these libraries (plus the small Exceptions bar) will perform all their actions using the ADOdb Database Abstraction Library for PHP that will receive all the requests from them, communicate with the DB (MySQL, PostgreSQL, Oracle or SQL*Server), retrieve results and forward them back to originator library.

プロセス The process

This section points to the main areas of information about the process of design and implementation of the new XMLDB layer:

  • Roadmap: Where the whole process is defined. It has been split into small chunks to be performed and tested easily. Also, such documents should be used to track what's done and what's pending, while using easy nomenclature.
  • Problems: A comprehensive list of issues that need to be determined/solved prior to incorporating them into the roadmap.

ドキュメンテーション The documentation

This section points to the main documentation index about the implemented XMLDB:

  • Documentation: Where you'll find quick links to different parts of the XMLDB documentation.

関連情報

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.

データベース関連

  • 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.