|
|
||||
![]() | ||||
A database is a list of records, all having the same number of fields. They provide a way of using a relatively large amount of data, without hard-coding variables into the document interface script. Currently, databases are read-only.
The first step in using a database is to read it using either the .DBARRAY or .DBHASH command. Its values can then be displayed using either the .DBDUMP command or the database variable syntax. There are also several internal variables that are created whenever a database is opened.
Databases used by the DI are in "comma-delimited ASCII" format, which can be created using most spreadsheet programs, like Excel.
A database file consists of one or more records, each separated by a newline sequence. Each field in the record is separated from the next by a comma. If the data in the field contains a comma, then the entire contents of the field are surrounded by "double-quotes".
Any line beginning with a # character is treated as a comment,
and the entire line is ignored.
The .DBARRAY command reads the data as a series of rows (records) and columns (fields). The .DBHASH command does the same for the rows, but it also assumes that the first record is a list of names to be applied to each of the subsequent records. This second type is known as an associative array, or "hash".
For example, this table:
| Fruit | Color | Shape |
| Orange | Orange | Round |
| Banana | Yellow | Thin, Pointy |
could be represented as an array by the following database file:
Orange,Orange,Round Banana,Yellow,"Thin, Pointy"
or as an associative array (hash) with this file:
Fruit,Color,Shape Orange,Orange,Round Banana,Yellow,"Thin, Pointy"
The .DBHASH Invert option causes the rows of the data file to be used as keys, instead of the columns.
See the section on database variable syntax for a description of how to extract particular records from a database.
Home | Directories | Web Email | Calendar | Campus Map | Search | Help
About the College |
Admission |
Academics |
Student Life |
Athletics Copyright © 2001 Mount Holyoke College. This page created by the OIS Operations Group and maintained by Webmaster. Last modified on November 2, 2001. |