]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed up some ommissions about database structure
authormoodler <moodler>
Tue, 9 Dec 2003 06:07:12 +0000 (06:07 +0000)
committermoodler <moodler>
Tue, 9 Dec 2003 06:07:12 +0000 (06:07 +0000)
lang/en/docs/coding.html

index d29bd64cae93a94f376eb71bf781582ddc97b107..faad02f9d85640a35631eafeba037f4f18fe7a30 100755 (executable)
@@ -165,10 +165,16 @@ GOOD: $assignments (for an array of objects)<br>
 <h2>Database structures</h2>
 <ol class="normaltext">
   <li class="spaced">Every table must have an auto-incrementing <strong>id</strong> field (INT10) as primary index.</li>
-  <li class="spaced">The main table containing instances of each module must have the same name as the module (eg <strong>widget</strong>).</li>
+  <li class="spaced">The main table containing instances of each module must have the same name as the module (eg <strong>widget</strong>) and contain the following minimum fields:
+    <ul>
+      <li><strong>id</strong> - as described above</li>
+      <li><strong>course</strong> - the id of the course that each instance belongs to</li>
+      <li><strong>name</strong> - the full name of each instance of the module</li>
+    </ul>
+  </li>
   <li class="spaced">Other tables associated with a module that contain information about 'things' should be named <strong>widget_things</strong> (note the plural).</li>
   <li class="spaced">Column names should be simple and short, following the same rules as for variable names.</li>
-  <li class="spaced">Columns that contain a reference to the id field of another table (eg <strong>widget</strong>) should be called <strong>widgetid</strong>.</li>
+  <li class="spaced">Where possible, columns that contain a reference to the id field of another table (eg <strong>widget</strong>) should be called <strong>widgetid</strong>. (Note that this convention is newish and not followed in some older tables)</li>
   <li class="spaced">Boolean fields should be implemented as small integer fields (eg INT4) containing 0 or 1, to allow for later expansion of values if necessary.</li>
   <li class="spaced">Most tables should have a <strong>timemodified</strong> field (INT10) which is updated with a current timestamp obtained with the PHP <strong>time</strong>() function.</li>
 </ol>