Index: trunk/ippdb/src/ippdb.h
===================================================================
--- trunk/ippdb/src/ippdb.h	(revision 15420)
+++ trunk/ippdb/src/ippdb.h	(revision 15421)
@@ -125,4 +125,205 @@
 );
 
+/** pzDataStoreRow data structure
+ *
+ * Structure for representing a single row of pzDataStore table data.
+ */
+
+typedef struct {
+    char            *camera;
+    char            *telescope;
+    char            *uri;
+} pzDataStoreRow;
+
+/** Creates a new pzDataStoreRow object
+ *
+ *  @return A new pzDataStoreRow object or NULL on failure.
+ */
+
+pzDataStoreRow *pzDataStoreRowAlloc(
+    const char      *camera,
+    const char      *telescope,
+    const char      *uri
+);
+
+/** Creates a new pzDataStore table
+ *
+ * @return true on success
+ */
+
+bool pzDataStoreCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a pzDataStore table
+ *
+ * @return true on success
+ */
+
+bool pzDataStoreDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool pzDataStoreInsert(
+    psDB            *dbh,               ///< Database handle
+    const char      *camera,
+    const char      *telescope,
+    const char      *uri
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long pzDataStoreDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single pzDataStoreRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool pzDataStoreInsertObject(
+    psDB            *dbh,               ///< Database handle
+    pzDataStoreRow  *object             ///< pzDataStoreRow object
+);
+
+/** Insert an array of pzDataStoreRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool pzDataStoreInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of pzDataStoreRow objects
+);
+
+/** Insert data from a binary FITS table pzDataStoreRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool pzDataStoreInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool pzDataStoreSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a pzDataStoreRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *pzDataStoreMetadataFromObject(
+    const pzDataStoreRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A pzDataStoreRow pointer or NULL on error
+ */
+
+pzDataStoreRow *pzDataStoreObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as pzDataStoreRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *pzDataStoreSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an pzDataStore
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool pzDataStoreDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const pzDataStoreRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long pzDataStoreDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of pzDataStoreRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool pzDataStorePrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of pzDataStoreRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an pzDataStoreRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool pzDataStorePrintObject(
+    FILE            *stream,            ///< a stream
+    pzDataStoreRow *object,    ///< an pzDataStoreRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
 /** summitExpRow data structure
  *
@@ -769,5 +970,4 @@
     char            *class;
     char            *class_id;
-    psS64           exp_id;
 } pzPendingImfileRow;
 
@@ -782,6 +982,5 @@
     const char      *telescope,
     const char      *class,
-    const char      *class_id,
-    psS64           exp_id
+    const char      *class_id
 );
 
@@ -817,6 +1016,5 @@
     const char      *telescope,
     const char      *class,
-    const char      *class_id,
-    psS64           exp_id
+    const char      *class_id
 );
 
@@ -1180,5 +1378,4 @@
     char            *class;
     char            *class_id;
-    psS64           exp_id;
     char            *uri;
 } pzDoneImfileRow;
@@ -1195,5 +1392,4 @@
     const char      *class,
     const char      *class_id,
-    psS64           exp_id,
     const char      *uri
 );
@@ -1231,5 +1427,4 @@
     const char      *class,
     const char      *class_id,
-    psS64           exp_id,
     const char      *uri
 );
@@ -1393,7 +1588,7 @@
     char            *tmp_telescope;
     char            *state;
-    psS32           imfiles;
     char            *workdir;
     char            *workdir_state;
+    char            *reduction;
 } newExpRow;
 
@@ -1409,7 +1604,7 @@
     const char      *tmp_telescope,
     const char      *state,
-    psS32           imfiles,
     const char      *workdir,
-    const char      *workdir_state
+    const char      *workdir_state,
+    const char      *reduction
 );
 
@@ -1446,7 +1641,7 @@
     const char      *tmp_telescope,
     const char      *state,
-    psS32           imfiles,
     const char      *workdir,
-    const char      *workdir_state
+    const char      *workdir_state,
+    const char      *reduction
 );
 
@@ -1812,7 +2007,7 @@
     char            *exp_tag;
     char            *exp_type;
-    psS32           imfiles;
     char            *filelevel;
     char            *workdir;
+    char            *reduction;
     char            *filter;
     psF32           airmass;
@@ -1851,7 +2046,7 @@
     const char      *exp_tag,
     const char      *exp_type,
-    psS32           imfiles,
     const char      *filelevel,
     const char      *workdir,
+    const char      *reduction,
     const char      *filter,
     psF32           airmass,
@@ -1911,7 +2106,7 @@
     const char      *exp_tag,
     const char      *exp_type,
-    psS32           imfiles,
     const char      *filelevel,
     const char      *workdir,
+    const char      *reduction,
     const char      *filter,
     psF32           airmass,
@@ -2574,4 +2769,5 @@
 typedef struct {
     psS64           chip_id;
+    psS64           exp_id;
     char            *state;
     char            *workdir;
@@ -2590,4 +2786,5 @@
 chipRunRow *chipRunRowAlloc(
     psS64           chip_id,
+    psS64           exp_id,
     const char      *state,
     const char      *workdir,
@@ -2627,4 +2824,5 @@
     psDB            *dbh,               ///< Database handle
     psS64           chip_id,
+    psS64           exp_id,
     const char      *state,
     const char      *workdir,
@@ -2781,205 +2979,4 @@
     FILE            *stream,            ///< a stream
     chipRunRow *object,    ///< an chipRunRow object
-    bool            mdcf                ///< format as mdconfig or simple
-);
-/** chipInputImfileRow data structure
- *
- * Structure for representing a single row of chipInputImfile table data.
- */
-
-typedef struct {
-    psS64           chip_id;
-    psS64           exp_id;
-    char            *class_id;
-} chipInputImfileRow;
-
-/** Creates a new chipInputImfileRow object
- *
- *  @return A new chipInputImfileRow object or NULL on failure.
- */
-
-chipInputImfileRow *chipInputImfileRowAlloc(
-    psS64           chip_id,
-    psS64           exp_id,
-    const char      *class_id
-);
-
-/** Creates a new chipInputImfile table
- *
- * @return true on success
- */
-
-bool chipInputImfileCreateTable(
-    psDB            *dbh                ///< Database handle
-);
-
-/** Deletes a chipInputImfile table
- *
- * @return true on success
- */
-
-bool chipInputImfileDropTable(
-    psDB            *dbh                ///< Database handle
-);
-
-/** Insert a single row into a table
- *
- * This function constructs and inserts a single row based on it's parameters.
- *
- * @return true on success
- */
-
-bool chipInputImfileInsert(
-    psDB            *dbh,               ///< Database handle
-    psS64           chip_id,
-    psS64           exp_id,
-    const char      *class_id
-);
-
-/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
- *
- * @return A The number of rows removed or a negative value on error
- */
-
-long long chipInputImfileDelete(
-    psDB            *dbh,               ///< Database handle
-    const psMetadata *where,            ///< Row match criteria
-    unsigned long long limit            ///< Maximum number of elements to delete 
-);
-
-/** Insert a single chipInputImfileRow object into a table
- *
- * This function constructs and inserts a single row based on it's parameters.
- *
- * @return true on success
- */
-
-bool chipInputImfileInsertObject(
-    psDB            *dbh,               ///< Database handle
-    chipInputImfileRow *object             ///< chipInputImfileRow object
-);
-
-/** Insert an array of chipInputImfileRow object into a table
- *
- * This function constructs and inserts multiple rows based on it's parameters.
- *
- * @return true on success
- */
-
-bool chipInputImfileInsertObjects(
-    psDB            *dbh,               ///< Database handle
-    psArray         *objects            ///< array of chipInputImfileRow objects
-);
-
-/** Insert data from a binary FITS table chipInputImfileRow into the database
- *
- * This function expects a psFits object with a FITS table as the first
- * extension.  The table must have at least one row of data in it, that is of
- * the appropriate format (number of columns and their type).  All other
- * extensions are ignored.
- *
- * @return true on success
- */
-
-bool chipInputImfileInsertFits(
-    psDB            *dbh,               ///< Database handle
-    const psFits    *fits               ///< psFits object
-);
-
-/** Selects up to limit from the database and returns them in a binary FITS table
- *
- * This function assumes an empty psFits object and will create a FITS table
- * as the first extension.
- *
- *  See psDBSelectRows() for documentation on the format of where.
- *
- * @return true on success
- */
-
-bool chipInputImfileSelectRowsFits(
-    psDB            *dbh,               ///< Database handle
-    psFits          *fits,              ///< psFits object
-    const psMetadata *where,            ///< Row match criteria
-    unsigned long long limit            ///< Maximum number of elements to return
-);
-
-/** Convert a chipInputImfileRow into an equivalent psMetadata
- *
- * @return A psMetadata pointer or NULL on error
- */
-
-psMetadata *chipInputImfileMetadataFromObject(
-    const chipInputImfileRow *object             ///< fooRow to convert into a psMetadata
-);
-
-/** Convert a psMetadata into an equivalent fooRow
- *
- * @return A chipInputImfileRow pointer or NULL on error
- */
-
-chipInputImfileRow *chipInputImfileObjectFromMetadata(
-    psMetadata      *md                 ///< psMetadata to convert into a fooRow
-);
-/** Selects up to limit rows from the database and returns as chipInputImfileRow objects in a psArray
- *
- *  See psDBSelectRows() for documentation on the format of where.
- *
- * @return A psArray pointer or NULL on error
- */
-
-psArray *chipInputImfileSelectRowObjects(
-    psDB            *dbh,               ///< Database handle
-    const psMetadata *where,            ///< Row match criteria
-    unsigned long long limit            ///< Maximum number of elements to return
-);
-/** Deletes a row from the database coresponding to an chipInputImfile
- *
- *  Note that a 'where' search psMetadata is constructed from each object and
- *  used to find rows to delete.
- *
- * @return A The number of rows removed or a negative value on error
- */
-
-bool chipInputImfileDeleteObject(
-    psDB            *dbh,               ///< Database handle
-    const chipInputImfileRow *object    ///< Object to delete
-);
-/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
- *
- *  Note that a 'where' search psMetadata is constructed from each object and
- *  used to find rows to delete.
- *
- * @return A The number of rows removed or a negative value on error
- */
-
-long long chipInputImfileDeleteRowObjects(
-    psDB            *dbh,               ///< Database handle
-    const psArray   *objects,           ///< Array of objects to delete
-    unsigned long long limit            ///< Maximum number of elements to delete 
-);
-/** Formats and prints an array of chipInputImfileRow objects
- *
- * When mdcf is set the formated output is in psMetadataConfig
- * format, otherwise it is in a simple tabular format.
- *
- * @return true on success
- */
-
-bool chipInputImfilePrintObjects(
-    FILE            *stream,            ///< a stream
-    psArray         *objects,           ///< An array of chipInputImfileRow objects
-    bool            mdcf                ///< format as mdconfig or simple
-);
-/** Formats and prints an chipInputImfileRow object
- *
- * When mdcf is set the formated output is in psMetadataConfig
- * format, otherwise it is in a simple tabular format.
- *
- * @return true on success
- */
-
-bool chipInputImfilePrintObject(
-    FILE            *stream,            ///< a stream
-    chipInputImfileRow *object,    ///< an chipInputImfileRow object
     bool            mdcf                ///< format as mdconfig or simple
 );
@@ -4737,4 +4734,6 @@
     psF64           bg;
     psF64           bg_stdev;
+    psF64           good_frac;
+    psS16           fault;
 } warpSkyfileRow;
 
@@ -4751,5 +4750,7 @@
     const char      *path_base,
     psF64           bg,
-    psF64           bg_stdev
+    psF64           bg_stdev,
+    psF64           good_frac,
+    psS16           fault
 );
 
@@ -4787,5 +4788,7 @@
     const char      *path_base,
     psF64           bg,
-    psF64           bg_stdev
+    psF64           bg_stdev,
+    psF64           good_frac,
+    psS16           fault
 );
 
@@ -5157,9 +5160,10 @@
 typedef struct {
     psS64           diff_id;
+    bool            template;
+    psS64           stack_id;
     psS64           warp_id;
     char            *skycell_id;
     char            *tess_id;
     char            *kind;
-    bool            template;
 } diffInputSkyfileRow;
 
@@ -5171,9 +5175,10 @@
 diffInputSkyfileRow *diffInputSkyfileRowAlloc(
     psS64           diff_id,
+    bool            template,
+    psS64           stack_id,
     psS64           warp_id,
     const char      *skycell_id,
     const char      *tess_id,
-    const char      *kind,
-    bool            template
+    const char      *kind
 );
 
@@ -5206,9 +5211,10 @@
     psDB            *dbh,               ///< Database handle
     psS64           diff_id,
+    bool            template,
+    psS64           stack_id,
     psS64           warp_id,
     const char      *skycell_id,
     const char      *tess_id,
-    const char      *kind,
-    bool            template
+    const char      *kind
 );
 
@@ -5371,4 +5377,6 @@
     psF64           bg;
     psF64           bg_stdev;
+    psF64           good_frac;
+    psS16           fault;
 } diffSkyfileRow;
 
@@ -5383,5 +5391,7 @@
     const char      *path_base,
     psF64           bg,
-    psF64           bg_stdev
+    psF64           bg_stdev,
+    psF64           good_frac,
+    psS16           fault
 );
 
@@ -5417,5 +5427,7 @@
     const char      *path_base,
     psF64           bg,
-    psF64           bg_stdev
+    psF64           bg_stdev,
+    psF64           good_frac,
+    psS16           fault
 );
 
@@ -5989,4 +6001,6 @@
     psF64           bg;
     psF64           bg_stdev;
+    psF64           good_frac;
+    psS16           fault;
 } stackSumSkyfileRow;
 
@@ -6001,5 +6015,7 @@
     const char      *path_base,
     psF64           bg,
-    psF64           bg_stdev
+    psF64           bg_stdev,
+    psF64           good_frac,
+    psS16           fault
 );
 
@@ -6035,5 +6051,7 @@
     const char      *path_base,
     psF64           bg,
-    psF64           bg_stdev
+    psF64           bg_stdev,
+    psF64           good_frac,
+    psS16           fault
 );
 
@@ -8075,8 +8093,13 @@
     psF64           bg_stdev;
     psF64           bg_mean_stdev;
+    psF64           bg_skewness;
+    psF64           bg_kurtosis;
     psF64           bin_stdev;
     psF64           fringe_0;
     psF64           fringe_1;
     psF64           fringe_2;
+    psF64           fringe_resid_0;
+    psF64           fringe_resid_1;
+    psF64           fringe_resid_2;
     psF64           user_1;
     psF64           user_2;
@@ -8103,8 +8126,13 @@
     psF64           bg_stdev,
     psF64           bg_mean_stdev,
+    psF64           bg_skewness,
+    psF64           bg_kurtosis,
     psF64           bin_stdev,
     psF64           fringe_0,
     psF64           fringe_1,
     psF64           fringe_2,
+    psF64           fringe_resid_0,
+    psF64           fringe_resid_1,
+    psF64           fringe_resid_2,
     psF64           user_1,
     psF64           user_2,
@@ -8152,8 +8180,13 @@
     psF64           bg_stdev,
     psF64           bg_mean_stdev,
+    psF64           bg_skewness,
+    psF64           bg_kurtosis,
     psF64           bin_stdev,
     psF64           fringe_0,
     psF64           fringe_1,
     psF64           fringe_2,
+    psF64           fringe_resid_0,
+    psF64           fringe_resid_1,
+    psF64           fringe_resid_2,
     psF64           user_1,
     psF64           user_2,
@@ -8325,8 +8358,13 @@
     psF64           bg_stdev;
     psF64           bg_mean_stdev;
+    psF64           bg_skewness;
+    psF64           bg_kurtosis;
     psF64           bin_stdev;
     psF64           fringe_0;
     psF64           fringe_1;
     psF64           fringe_2;
+    psF64           fringe_resid_0;
+    psF64           fringe_resid_1;
+    psF64           fringe_resid_2;
     psF64           user_1;
     psF64           user_2;
@@ -8352,8 +8390,13 @@
     psF64           bg_stdev,
     psF64           bg_mean_stdev,
+    psF64           bg_skewness,
+    psF64           bg_kurtosis,
     psF64           bin_stdev,
     psF64           fringe_0,
     psF64           fringe_1,
     psF64           fringe_2,
+    psF64           fringe_resid_0,
+    psF64           fringe_resid_1,
+    psF64           fringe_resid_2,
     psF64           user_1,
     psF64           user_2,
@@ -8400,8 +8443,13 @@
     psF64           bg_stdev,
     psF64           bg_mean_stdev,
+    psF64           bg_skewness,
+    psF64           bg_kurtosis,
     psF64           bin_stdev,
     psF64           fringe_0,
     psF64           fringe_1,
     psF64           fringe_2,
+    psF64           fringe_resid_0,
+    psF64           fringe_resid_1,
+    psF64           fringe_resid_2,
     psF64           user_1,
     psF64           user_2,
@@ -8774,4 +8822,1879 @@
     bool            mdcf                ///< format as mdconfig or simple
 );
+/** detRegisteredImfileRow data structure
+ *
+ * Structure for representing a single row of detRegisteredImfile table data.
+ */
+
+typedef struct {
+    psS64           det_id;
+    psS32           iteration;
+    char            *class_id;
+    char            *uri;
+    psF64           bg;
+    psF64           bg_stdev;
+    psF64           bg_mean_stdev;
+    psF64           user_1;
+    psF64           user_2;
+    psF64           user_3;
+    psF64           user_4;
+    psF64           user_5;
+    char            *path_base;
+    psS16           fault;
+} detRegisteredImfileRow;
+
+/** Creates a new detRegisteredImfileRow object
+ *
+ *  @return A new detRegisteredImfileRow object or NULL on failure.
+ */
+
+detRegisteredImfileRow *detRegisteredImfileRowAlloc(
+    psS64           det_id,
+    psS32           iteration,
+    const char      *class_id,
+    const char      *uri,
+    psF64           bg,
+    psF64           bg_stdev,
+    psF64           bg_mean_stdev,
+    psF64           user_1,
+    psF64           user_2,
+    psF64           user_3,
+    psF64           user_4,
+    psF64           user_5,
+    const char      *path_base,
+    psS16           fault
+);
+
+/** Creates a new detRegisteredImfile table
+ *
+ * @return true on success
+ */
+
+bool detRegisteredImfileCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a detRegisteredImfile table
+ *
+ * @return true on success
+ */
+
+bool detRegisteredImfileDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool detRegisteredImfileInsert(
+    psDB            *dbh,               ///< Database handle
+    psS64           det_id,
+    psS32           iteration,
+    const char      *class_id,
+    const char      *uri,
+    psF64           bg,
+    psF64           bg_stdev,
+    psF64           bg_mean_stdev,
+    psF64           user_1,
+    psF64           user_2,
+    psF64           user_3,
+    psF64           user_4,
+    psF64           user_5,
+    const char      *path_base,
+    psS16           fault
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long detRegisteredImfileDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single detRegisteredImfileRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool detRegisteredImfileInsertObject(
+    psDB            *dbh,               ///< Database handle
+    detRegisteredImfileRow *object             ///< detRegisteredImfileRow object
+);
+
+/** Insert an array of detRegisteredImfileRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool detRegisteredImfileInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of detRegisteredImfileRow objects
+);
+
+/** Insert data from a binary FITS table detRegisteredImfileRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool detRegisteredImfileInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool detRegisteredImfileSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a detRegisteredImfileRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *detRegisteredImfileMetadataFromObject(
+    const detRegisteredImfileRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A detRegisteredImfileRow pointer or NULL on error
+ */
+
+detRegisteredImfileRow *detRegisteredImfileObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as detRegisteredImfileRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *detRegisteredImfileSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an detRegisteredImfile
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool detRegisteredImfileDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const detRegisteredImfileRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long detRegisteredImfileDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of detRegisteredImfileRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool detRegisteredImfilePrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of detRegisteredImfileRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an detRegisteredImfileRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool detRegisteredImfilePrintObject(
+    FILE            *stream,            ///< a stream
+    detRegisteredImfileRow *object,    ///< an detRegisteredImfileRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** detCorrectedExpRow data structure
+ *
+ * Structure for representing a single row of detCorrectedExp table data.
+ */
+
+typedef struct {
+    psS64           det_id;
+    psS64           exp_id;
+    char            *uri;
+    psS64           corr_id;
+    char            *corr_type;
+    char            *recipe;
+    char            *path_base;
+    psS16           fault;
+} detCorrectedExpRow;
+
+/** Creates a new detCorrectedExpRow object
+ *
+ *  @return A new detCorrectedExpRow object or NULL on failure.
+ */
+
+detCorrectedExpRow *detCorrectedExpRowAlloc(
+    psS64           det_id,
+    psS64           exp_id,
+    const char      *uri,
+    psS64           corr_id,
+    const char      *corr_type,
+    const char      *recipe,
+    const char      *path_base,
+    psS16           fault
+);
+
+/** Creates a new detCorrectedExp table
+ *
+ * @return true on success
+ */
+
+bool detCorrectedExpCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a detCorrectedExp table
+ *
+ * @return true on success
+ */
+
+bool detCorrectedExpDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedExpInsert(
+    psDB            *dbh,               ///< Database handle
+    psS64           det_id,
+    psS64           exp_id,
+    const char      *uri,
+    psS64           corr_id,
+    const char      *corr_type,
+    const char      *recipe,
+    const char      *path_base,
+    psS16           fault
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long detCorrectedExpDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single detCorrectedExpRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedExpInsertObject(
+    psDB            *dbh,               ///< Database handle
+    detCorrectedExpRow *object             ///< detCorrectedExpRow object
+);
+
+/** Insert an array of detCorrectedExpRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedExpInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of detCorrectedExpRow objects
+);
+
+/** Insert data from a binary FITS table detCorrectedExpRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedExpInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedExpSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a detCorrectedExpRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *detCorrectedExpMetadataFromObject(
+    const detCorrectedExpRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A detCorrectedExpRow pointer or NULL on error
+ */
+
+detCorrectedExpRow *detCorrectedExpObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as detCorrectedExpRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *detCorrectedExpSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an detCorrectedExp
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool detCorrectedExpDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const detCorrectedExpRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long detCorrectedExpDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of detCorrectedExpRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedExpPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of detCorrectedExpRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an detCorrectedExpRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedExpPrintObject(
+    FILE            *stream,            ///< a stream
+    detCorrectedExpRow *object,    ///< an detCorrectedExpRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** detCorrectedImfileRow data structure
+ *
+ * Structure for representing a single row of detCorrectedImfile table data.
+ */
+
+typedef struct {
+    psS64           det_id;
+    psS64           exp_id;
+    char            *class_id;
+    char            *uri;
+    char            *path_base;
+    psS16           fault;
+} detCorrectedImfileRow;
+
+/** Creates a new detCorrectedImfileRow object
+ *
+ *  @return A new detCorrectedImfileRow object or NULL on failure.
+ */
+
+detCorrectedImfileRow *detCorrectedImfileRowAlloc(
+    psS64           det_id,
+    psS64           exp_id,
+    const char      *class_id,
+    const char      *uri,
+    const char      *path_base,
+    psS16           fault
+);
+
+/** Creates a new detCorrectedImfile table
+ *
+ * @return true on success
+ */
+
+bool detCorrectedImfileCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a detCorrectedImfile table
+ *
+ * @return true on success
+ */
+
+bool detCorrectedImfileDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedImfileInsert(
+    psDB            *dbh,               ///< Database handle
+    psS64           det_id,
+    psS64           exp_id,
+    const char      *class_id,
+    const char      *uri,
+    const char      *path_base,
+    psS16           fault
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long detCorrectedImfileDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single detCorrectedImfileRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedImfileInsertObject(
+    psDB            *dbh,               ///< Database handle
+    detCorrectedImfileRow *object             ///< detCorrectedImfileRow object
+);
+
+/** Insert an array of detCorrectedImfileRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedImfileInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of detCorrectedImfileRow objects
+);
+
+/** Insert data from a binary FITS table detCorrectedImfileRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedImfileInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedImfileSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a detCorrectedImfileRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *detCorrectedImfileMetadataFromObject(
+    const detCorrectedImfileRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A detCorrectedImfileRow pointer or NULL on error
+ */
+
+detCorrectedImfileRow *detCorrectedImfileObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as detCorrectedImfileRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *detCorrectedImfileSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an detCorrectedImfile
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool detCorrectedImfileDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const detCorrectedImfileRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long detCorrectedImfileDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of detCorrectedImfileRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedImfilePrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of detCorrectedImfileRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an detCorrectedImfileRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool detCorrectedImfilePrintObject(
+    FILE            *stream,            ///< a stream
+    detCorrectedImfileRow *object,    ///< an detCorrectedImfileRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** magicRunRow data structure
+ *
+ * Structure for representing a single row of magicRun table data.
+ */
+
+typedef struct {
+    psS64           magic_id;
+    char            *state;
+    char            *workdir;
+    char            *workdir_state;
+    char            *label;
+    char            *dvodb;
+    psTime*         registered;
+} magicRunRow;
+
+/** Creates a new magicRunRow object
+ *
+ *  @return A new magicRunRow object or NULL on failure.
+ */
+
+magicRunRow *magicRunRowAlloc(
+    psS64           magic_id,
+    const char      *state,
+    const char      *workdir,
+    const char      *workdir_state,
+    const char      *label,
+    const char      *dvodb,
+    psTime*         registered
+);
+
+/** Creates a new magicRun table
+ *
+ * @return true on success
+ */
+
+bool magicRunCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a magicRun table
+ *
+ * @return true on success
+ */
+
+bool magicRunDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicRunInsert(
+    psDB            *dbh,               ///< Database handle
+    psS64           magic_id,
+    const char      *state,
+    const char      *workdir,
+    const char      *workdir_state,
+    const char      *label,
+    const char      *dvodb,
+    psTime*         registered
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long magicRunDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single magicRunRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicRunInsertObject(
+    psDB            *dbh,               ///< Database handle
+    magicRunRow     *object             ///< magicRunRow object
+);
+
+/** Insert an array of magicRunRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicRunInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of magicRunRow objects
+);
+
+/** Insert data from a binary FITS table magicRunRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool magicRunInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool magicRunSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a magicRunRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *magicRunMetadataFromObject(
+    const magicRunRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A magicRunRow pointer or NULL on error
+ */
+
+magicRunRow *magicRunObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as magicRunRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *magicRunSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an magicRun
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool magicRunDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const magicRunRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long magicRunDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of magicRunRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool magicRunPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of magicRunRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an magicRunRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool magicRunPrintObject(
+    FILE            *stream,            ///< a stream
+    magicRunRow *object,    ///< an magicRunRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** magicInputSkyfileRow data structure
+ *
+ * Structure for representing a single row of magicInputSkyfile table data.
+ */
+
+typedef struct {
+    psS64           magic_id;
+    psS64           diff_id;
+    char            *node;
+} magicInputSkyfileRow;
+
+/** Creates a new magicInputSkyfileRow object
+ *
+ *  @return A new magicInputSkyfileRow object or NULL on failure.
+ */
+
+magicInputSkyfileRow *magicInputSkyfileRowAlloc(
+    psS64           magic_id,
+    psS64           diff_id,
+    const char      *node
+);
+
+/** Creates a new magicInputSkyfile table
+ *
+ * @return true on success
+ */
+
+bool magicInputSkyfileCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a magicInputSkyfile table
+ *
+ * @return true on success
+ */
+
+bool magicInputSkyfileDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicInputSkyfileInsert(
+    psDB            *dbh,               ///< Database handle
+    psS64           magic_id,
+    psS64           diff_id,
+    const char      *node
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long magicInputSkyfileDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single magicInputSkyfileRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicInputSkyfileInsertObject(
+    psDB            *dbh,               ///< Database handle
+    magicInputSkyfileRow *object             ///< magicInputSkyfileRow object
+);
+
+/** Insert an array of magicInputSkyfileRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicInputSkyfileInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of magicInputSkyfileRow objects
+);
+
+/** Insert data from a binary FITS table magicInputSkyfileRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool magicInputSkyfileInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool magicInputSkyfileSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a magicInputSkyfileRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *magicInputSkyfileMetadataFromObject(
+    const magicInputSkyfileRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A magicInputSkyfileRow pointer or NULL on error
+ */
+
+magicInputSkyfileRow *magicInputSkyfileObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as magicInputSkyfileRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *magicInputSkyfileSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an magicInputSkyfile
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool magicInputSkyfileDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const magicInputSkyfileRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long magicInputSkyfileDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of magicInputSkyfileRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool magicInputSkyfilePrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of magicInputSkyfileRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an magicInputSkyfileRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool magicInputSkyfilePrintObject(
+    FILE            *stream,            ///< a stream
+    magicInputSkyfileRow *object,    ///< an magicInputSkyfileRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** magicTreeRow data structure
+ *
+ * Structure for representing a single row of magicTree table data.
+ */
+
+typedef struct {
+    psS64           magic_id;
+    char            *node;
+    char            *dep;
+} magicTreeRow;
+
+/** Creates a new magicTreeRow object
+ *
+ *  @return A new magicTreeRow object or NULL on failure.
+ */
+
+magicTreeRow *magicTreeRowAlloc(
+    psS64           magic_id,
+    const char      *node,
+    const char      *dep
+);
+
+/** Creates a new magicTree table
+ *
+ * @return true on success
+ */
+
+bool magicTreeCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a magicTree table
+ *
+ * @return true on success
+ */
+
+bool magicTreeDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicTreeInsert(
+    psDB            *dbh,               ///< Database handle
+    psS64           magic_id,
+    const char      *node,
+    const char      *dep
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long magicTreeDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single magicTreeRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicTreeInsertObject(
+    psDB            *dbh,               ///< Database handle
+    magicTreeRow    *object             ///< magicTreeRow object
+);
+
+/** Insert an array of magicTreeRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicTreeInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of magicTreeRow objects
+);
+
+/** Insert data from a binary FITS table magicTreeRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool magicTreeInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool magicTreeSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a magicTreeRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *magicTreeMetadataFromObject(
+    const magicTreeRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A magicTreeRow pointer or NULL on error
+ */
+
+magicTreeRow *magicTreeObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as magicTreeRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *magicTreeSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an magicTree
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool magicTreeDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const magicTreeRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long magicTreeDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of magicTreeRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool magicTreePrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of magicTreeRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an magicTreeRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool magicTreePrintObject(
+    FILE            *stream,            ///< a stream
+    magicTreeRow *object,    ///< an magicTreeRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** magicNodeResultRow data structure
+ *
+ * Structure for representing a single row of magicNodeResult table data.
+ */
+
+typedef struct {
+    psS64           magic_id;
+    char            *node;
+    char            *uri;
+} magicNodeResultRow;
+
+/** Creates a new magicNodeResultRow object
+ *
+ *  @return A new magicNodeResultRow object or NULL on failure.
+ */
+
+magicNodeResultRow *magicNodeResultRowAlloc(
+    psS64           magic_id,
+    const char      *node,
+    const char      *uri
+);
+
+/** Creates a new magicNodeResult table
+ *
+ * @return true on success
+ */
+
+bool magicNodeResultCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a magicNodeResult table
+ *
+ * @return true on success
+ */
+
+bool magicNodeResultDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicNodeResultInsert(
+    psDB            *dbh,               ///< Database handle
+    psS64           magic_id,
+    const char      *node,
+    const char      *uri
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long magicNodeResultDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single magicNodeResultRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicNodeResultInsertObject(
+    psDB            *dbh,               ///< Database handle
+    magicNodeResultRow *object             ///< magicNodeResultRow object
+);
+
+/** Insert an array of magicNodeResultRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicNodeResultInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of magicNodeResultRow objects
+);
+
+/** Insert data from a binary FITS table magicNodeResultRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool magicNodeResultInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool magicNodeResultSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a magicNodeResultRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *magicNodeResultMetadataFromObject(
+    const magicNodeResultRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A magicNodeResultRow pointer or NULL on error
+ */
+
+magicNodeResultRow *magicNodeResultObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as magicNodeResultRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *magicNodeResultSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an magicNodeResult
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool magicNodeResultDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const magicNodeResultRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long magicNodeResultDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of magicNodeResultRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool magicNodeResultPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of magicNodeResultRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an magicNodeResultRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool magicNodeResultPrintObject(
+    FILE            *stream,            ///< a stream
+    magicNodeResultRow *object,    ///< an magicNodeResultRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** magicMaskRow data structure
+ *
+ * Structure for representing a single row of magicMask table data.
+ */
+
+typedef struct {
+    psS64           magic_id;
+    char            *uri;
+} magicMaskRow;
+
+/** Creates a new magicMaskRow object
+ *
+ *  @return A new magicMaskRow object or NULL on failure.
+ */
+
+magicMaskRow *magicMaskRowAlloc(
+    psS64           magic_id,
+    const char      *uri
+);
+
+/** Creates a new magicMask table
+ *
+ * @return true on success
+ */
+
+bool magicMaskCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a magicMask table
+ *
+ * @return true on success
+ */
+
+bool magicMaskDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicMaskInsert(
+    psDB            *dbh,               ///< Database handle
+    psS64           magic_id,
+    const char      *uri
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long magicMaskDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single magicMaskRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicMaskInsertObject(
+    psDB            *dbh,               ///< Database handle
+    magicMaskRow    *object             ///< magicMaskRow object
+);
+
+/** Insert an array of magicMaskRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicMaskInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of magicMaskRow objects
+);
+
+/** Insert data from a binary FITS table magicMaskRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool magicMaskInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool magicMaskSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a magicMaskRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *magicMaskMetadataFromObject(
+    const magicMaskRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A magicMaskRow pointer or NULL on error
+ */
+
+magicMaskRow *magicMaskObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as magicMaskRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *magicMaskSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an magicMask
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool magicMaskDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const magicMaskRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long magicMaskDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of magicMaskRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool magicMaskPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of magicMaskRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an magicMaskRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool magicMaskPrintObject(
+    FILE            *stream,            ///< a stream
+    magicMaskRow *object,    ///< an magicMaskRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** magicSkyfileMaskRow data structure
+ *
+ * Structure for representing a single row of magicSkyfileMask table data.
+ */
+
+typedef struct {
+    psS64           magic_id;
+    psS64           diff_id;
+    char            *uri;
+} magicSkyfileMaskRow;
+
+/** Creates a new magicSkyfileMaskRow object
+ *
+ *  @return A new magicSkyfileMaskRow object or NULL on failure.
+ */
+
+magicSkyfileMaskRow *magicSkyfileMaskRowAlloc(
+    psS64           magic_id,
+    psS64           diff_id,
+    const char      *uri
+);
+
+/** Creates a new magicSkyfileMask table
+ *
+ * @return true on success
+ */
+
+bool magicSkyfileMaskCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a magicSkyfileMask table
+ *
+ * @return true on success
+ */
+
+bool magicSkyfileMaskDropTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Insert a single row into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicSkyfileMaskInsert(
+    psDB            *dbh,               ///< Database handle
+    psS64           magic_id,
+    psS64           diff_id,
+    const char      *uri
+);
+
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long magicSkyfileMaskDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single magicSkyfileMaskRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicSkyfileMaskInsertObject(
+    psDB            *dbh,               ///< Database handle
+    magicSkyfileMaskRow *object             ///< magicSkyfileMaskRow object
+);
+
+/** Insert an array of magicSkyfileMaskRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool magicSkyfileMaskInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of magicSkyfileMaskRow objects
+);
+
+/** Insert data from a binary FITS table magicSkyfileMaskRow into the database
+ *
+ * This function expects a psFits object with a FITS table as the first
+ * extension.  The table must have at least one row of data in it, that is of
+ * the appropriate format (number of columns and their type).  All other
+ * extensions are ignored.
+ *
+ * @return true on success
+ */
+
+bool magicSkyfileMaskInsertFits(
+    psDB            *dbh,               ///< Database handle
+    const psFits    *fits               ///< psFits object
+);
+
+/** Selects up to limit from the database and returns them in a binary FITS table
+ *
+ * This function assumes an empty psFits object and will create a FITS table
+ * as the first extension.
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return true on success
+ */
+
+bool magicSkyfileMaskSelectRowsFits(
+    psDB            *dbh,               ///< Database handle
+    psFits          *fits,              ///< psFits object
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+
+/** Convert a magicSkyfileMaskRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *magicSkyfileMaskMetadataFromObject(
+    const magicSkyfileMaskRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A magicSkyfileMaskRow pointer or NULL on error
+ */
+
+magicSkyfileMaskRow *magicSkyfileMaskObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as magicSkyfileMaskRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *magicSkyfileMaskSelectRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to return
+);
+/** Deletes a row from the database coresponding to an magicSkyfileMask
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+bool magicSkyfileMaskDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const magicSkyfileMaskRow *object    ///< Object to delete
+);
+/** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
+ *
+ *  Note that a 'where' search psMetadata is constructed from each object and
+ *  used to find rows to delete.
+ *
+ * @return A The number of rows removed or a negative value on error
+ */
+
+long long magicSkyfileMaskDeleteRowObjects(
+    psDB            *dbh,               ///< Database handle
+    const psArray   *objects,           ///< Array of objects to delete
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+/** Formats and prints an array of magicSkyfileMaskRow objects
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool magicSkyfileMaskPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of magicSkyfileMaskRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an magicSkyfileMaskRow object
+ *
+ * When mdcf is set the formated output is in psMetadataConfig
+ * format, otherwise it is in a simple tabular format.
+ *
+ * @return true on success
+ */
+
+bool magicSkyfileMaskPrintObject(
+    FILE            *stream,            ///< a stream
+    magicSkyfileMaskRow *object,    ///< an magicSkyfileMaskRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
 
 /// @}
@@ -8781,3 +10704,3 @@
 #endif
 
-#endif // DETRUNSUMMARY_DB_H
+#endif // MAGICSKYFILEMASK_DB_H
