Development:XML database schema: Difference between revisions
From MoodleDocs
Helen Foster (talk | contribs) m category |
|||
| Line 1: | Line 1: | ||
{{Work in progress}} | {{Work in progress}} | ||
The goal of these pages is to document, explain and follow the evolution of the integration between Moodle and other RDBS, using the [http://phplens.com/lens/adodb/docs-datadict.htm#xmlschema ADOdb XML Schema] (AXMLS), built over the [http://phplens.com/lens/adodb/docs-datadict.htm ADOdb Data Dictionary], that comes with the [http://adodb.sourceforge.net/ ADOdb] library, used by Moodle to perform all DB operations since the beginning. | The goal of these pages is to document, explain and follow the evolution of the integration between Moodle and other RDBS, using the [http://phplens.com/lens/adodb/docs-datadict.htm#xmlschema ADOdb XML Schema] (AXMLS), built over the [http://phplens.com/lens/adodb/docs-datadict.htm ADOdb Data Dictionary], that comes with the [http://adodb.sourceforge.net/ ADOdb] library, used by Moodle to perform all DB operations since the beginning. | ||
__NOTOC__ | __NOTOC__ | ||
==Preliminary tests== | ==Preliminary tests== | ||
| Line 22: | Line 20: | ||
==The roadmap== | ==The roadmap== | ||
==Todo list== | ==Todo list== | ||
| Line 40: | Line 37: | ||
==See also== | ==See also== | ||
* [[XMLDB preliminary links]] - A collection of links about general info, searched and analysed at the initial stages of the project | |||
* [[XMLDB preliminary links]] - A collection of links about general info, searched and analysed at the initial stages of the project | * [[XMLDB column types]] - Some links about column types inside every RDBMS and their characteristics | ||
* [[XMLDB column types]] - Some links about column types inside every RDBMS and their characteristics | |||
* [[XMLDB reserved words]] - A collection of reserver words inside each RDBMS | * [[XMLDB reserved words]] - A collection of reserver words inside each RDBMS | ||
[[Category:Developer]] | [[Category:Developer]] | ||
[[Category:XMLDB]] | |||
Revision as of 07:40, 18 May 2006
Note: This article is a work in progress. Please use the page comments for any recommendations/suggestions for improvement.
The goal of these pages is to document, explain and follow the evolution of the integration between Moodle and other RDBS, using the ADOdb XML Schema (AXMLS), built over the ADOdb Data Dictionary, that comes with the ADOdb library, used by Moodle to perform all DB operations since the beginning.
Preliminary tests
This test involves the creation of one minimal DB structure (2-3 tables) testing all these features with the XML schema:
- Table creation.
- Field creation:
- names (don't forget reserved words!).
- types
- length considerations
- autonumeric (serial or sequence) fields.
- default values
- unsigned support
- null/not null decission!
- PK creation and naming
- INDEX and UNIQUE INDEX creation an naming
- FK creation and naming?
The roadmap
Todo list
- We need to change all the uses of the LIMIT offset, num clause to use the cross-db compatible SelectLimit() function. Two alternatives seem possible:
- Create a new set of get_records_limit() (and get_recordset_limit() ?) functions, allowing to specify the offset, num parameters.
- Modify the current get_records() (and get_recordset()) functions to allow two more optional parameters (offset, num)
- Analyse the impact of such SelectLimit() calls under SQL*Server, Oracle... because it's emulated by ADOdb on those DBs, because their lack of support for the LIMIT clause. As the offset parameter grows, ADOdb must iterate over more records to get the desired window and it could be a problem under long sets of records!
- What to do with all the previously created DB objects (indexes, unique indexes, sequences...) if their naming schema doesn't fit with the implemented by ADOdb. Drop/recreate everything? Leave it unmodified?
- Currently, both under MySQL and PostgreSQL, ADODB_FETCH_BOTH (default) is used so all the information is, practically, duplicated. In other side, SQL*Server, by default, uses ADODB_FETCH_NUM (although it can be changed to ADODB_FETCH_ASSOC). Proposal, after connection, change ALWAYS to ADODB_FETCH_ASSOC. It's supported by all the DB (while ADODB_FETCH_BOTH isn't!) and it will save us near 50% memory (and speed?) for record arrays! If there was some places using ADODB_FETCH_NUM structures inside Moodle (I really thing they aren't used) we must update them. UPDATED: it seems that the id field is lost in conversion to ADODB_FETCH_ASSOC so, perhaps it wouldn't be a good idea to force this mode! :-(
- Force ADODB_ASSOC_CASE to 0 (lowercase). Some DB could break this and until now, both mysql and postgresql are working fine with lowercased field names.
- Reserver words. What to do? One horrible example: "USER": http://www.petefreitag.com/tools/sql_reserved_words_checker/?word=user
- Try to quote them.
- Change them completely under Moodle.
- Need to pre-parse the XML database schema to add prefix to all tables/indexes/constraints before parsing and executing!
- Analise how upgrades are going to succeed. Everything inside one unique upgrade.php file, ok, DML should be php, but DDL, how to handle it ?
See also
- XMLDB preliminary links - A collection of links about general info, searched and analysed at the initial stages of the project
- XMLDB column types - Some links about column types inside every RDBMS and their characteristics
- XMLDB reserved words - A collection of reserver words inside each RDBMS