]> git.mjollnir.org Git - moodle.git/commitdiff
Added information about databases
authormoodler <moodler>
Sun, 30 Nov 2003 08:31:08 +0000 (08:31 +0000)
committermoodler <moodler>
Sun, 30 Nov 2003 08:31:08 +0000 (08:31 +0000)
lang/en/docs/coding.html

index e1679c6fad2e50679a94461886218b4c176fff52..dd9df05621d661b937662a36cd68279f3d430efd 100755 (executable)
@@ -161,6 +161,16 @@ GOOD: $assignments (for an array of objects)<br>
       } </font></p>
   </li>
 </ol>
+<h2>Database structures</h2>
+<ol class="normaltext">
+  <li class="spaced">Every table must have an auto-incrementing <strong>id</strong> field (INT(10)) as primary index.</li>
+  <li>The main table containing instances of each module must have the same name as the module (eg <strong>widget</strong>)</li>
+  <li>Other tables associated with a module that contain information about 'things' should be named <strong>widget_things</strong> (note the plural)</li>
+  <li>Column names should be simple and short, following the same rules as for variable names.</li>
+  <li>Columns that contain a reference to the id field of another table (eg <strong>widget</strong>) should be called <strong>widgetid</strong>.</li>
+  <li>Boolean fields should be implemented as small integer fields (eg INT(4)) containing 0 or 1, to allow for later expansion of values if necessary.</li>
+  <li>Most tables should have a <strong>timemodified</strong> field (INT(10) which is updated with a current timestamp obtained with the PHP <strong>time</strong>() function.</li>
+</ol>
 <hr>
 <p align="CENTER"><font size="1"><a href="." target="_top">Moodle Documentation</a></font></p>
 <p align="CENTER"><font size="1">Version: $Id$</font></p>