After many previous attempts and false starts, Drupal 6's entire core database schema is now documented and cross referenced. You can view the documentation using the contributed Schema module; see the attached screenshot for a demonstration (click to enlarge). Thanks to webchick, add1sun, pwolanin, JirkaRybka, Moshe, chx, yched, and others for contributing their knowledge of the dusty corners of the schema.
If you are a module author, when you port a module to Drupal 6 and create your hook_schema() function, you should also document the schema. Doing so is easy: just add 'description' fields to each table and field in the schema structure. For example:
<?php
function mymodule_schema() {
$schema['mytable'] = array(
'description' => t('Stores whiz-bang cool data for nodes provided by the MyModule module.'),
'fields' => array(
'nid' => array(
'type' => 'int',
'not null' => TRUE,
'description' => t('The {node}.nid that this row is for.'),
),
// etc.
return $schema;
}
?>Placing a table reference within a description inside of curly-braces causes the reference to be displayed as a hyperlink to that table's documentation on the Schema Describe page.
Comments
Frustrating... That's was my
Frustrating... That's was my initial thought trying to understand the Drupal schema. I was trying to figure out how I can enrich a "Node" with auxiliary information, and to do that properly, i.e., not by copying other's code and modifying it. So I worked a bit on understanding the Schema, and slightly more, and ...
Frustrating... That's my final thought with regard to my attempt of understanding the schema.
Not that frustrating, I had
Not that frustrating, I had to construct an ER-Diagram of 60+ tables not only the 45 tables of the basic installation as I had installed other modules. I just requires hell lots of patience and you've too see which tables are affected after you do each action. I did it in Drupal 5. Don't know how the schema is in Drupal 6.
Post new comment