Notes about modifying/adding database tables
Preamble
Most of the database tables were originally designed a few years based on guesses about what would be needed. It is entirely appropriate to change them to better serve the data analyses actually being done. However, this requires coordination between several different parties. This page will try to cover some of the relevant issues.Coordination
A new or modified table might require changes to all of the following:- The DB2 database servers running in all LDAS installations
- The LDAS software which handles database input/output
- Software in LAL which defines structures for database table entries
- The 'guild' user interface in LIGOtools
Modifying an existing table
Some modifications can be made to an existing table without disturbing the data which has already been inserted into it (if any). These include:- Add a column (with any data type)
- Change the maximum length of a variable-length character string
- Create or delete indexes
- Delete a column
- Change the name of a column
- Change the data type of a column
- Change the length of a fixed-length character string
Creating a new table
If no existing database table is suitable for your needs, even with minor modifications, then it makes sense to create a new database table from scratch. See other table definitions in the LDAS CVS repository for examples. Table definition files are not case sensitive, but we tend to type SQL statements in uppercase for readability. We generally stick to the following data types for the columns in a table (although DB2 supports some other types):- INTEGER (4-byte)
- REAL (4-byte)
- DOUBLE (8-byte)
- CHAR(n) (fixed-length string, length = n characters)
- VARCHAR(n) (variable-length string, maximum length = n characters)
- VARCHAR(n) FOR BIT DATA (variable-length string to store binary data, i.e. arbitrary bytes)
- BLOB ("Binary Large OBject" to store arbitrary bytes)
$Id: table_notes.html,v 1.3 2004/03/31 20:35:54 pshawhan Exp $