Version 4 (modified by jbecla, 11 years ago) (diff)

updated section about schema browser

Standardizing names in C++ code and in database schema


At the moment many names of database columns and their corresponding C++ names do not match. Here are some examples:

C++ database
visitTime dataObs
exposureTime expTime
airMass airmass


  • We should come up with a project wide standard and apply it consistently for all database columns and all C++ names, such that database columns and their corresponding C++ names fully match wherever it makes sense (there may be unavoidable differences, for example we may want to represent per-filter data as an array in C++).
  • We should standardize units, such that all corresponding database columns and their C++ attributes use the same units.



How about if we adopt the convention used for naming database columns:

  • names should start with small letter. Example: imageId
  • Avoid using short, common names like "id", instead, use more descriptive names like imageId, sourceId etc. This helps to simplify writing queries, for example as long as column names are distinct we can use NATURAL JOIN.
  • If a name consists of multiple words, use "camel case" convention: capitalize first character of each word except the first, example sourceId, not sourceid and not sourceID
  • if a column is specific to a filter, put the filter name first, for example uAmplitude, gPeriod
  • put column keeping error for another column one after another, and append Err at the end, for example raErr column should be immediately after ra column
  • for right ascension and declination use ra, and decl. Notice that dec is a reserved word in some DBMSes (short for DECIMAL)
  • if there are more than one per-filter columns, group them together: all columns for one filter together. Put non-filter specific columns before filter-specific ones.


The units in the database are currently poorly defined. We are actively working on defining units for all columns (see ticket #428), it includes checking what units are used by the C++ code. We could leverage this work to ensure the units in database and C++ are in sync.

Other notes

The Schema Browser which allows to browse all database column names, see their descriptions and units should be helpful in the process. (The unit definitions for database columns are kept along with the master schema in EA, as tagged values).

Add comment