Index: trunk/ippdb/src/ippdb.h
===================================================================
--- trunk/ippdb/src/ippdb.h	(revision 11635)
+++ trunk/ippdb/src/ippdb.h	(revision 11679)
@@ -20,5 +20,5 @@
 /*
  *
- * This file was generated by glueforge 1.00
+ * This file was generated by glueforge 0.36
  *
  * Do NOT directly edit this file.
@@ -6830,57 +6830,43 @@
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** p4RunRow data structure
- *
- * Structure for representing a single row of p4Run table data.
+/** p4aRunRow data structure
+ *
+ * Structure for representing a single row of p4aRun table data.
  */
 
 typedef struct {
-    psS32           p4_id;
-    char            *survey_mode;
+    psS32           p4a_id;
     char            *state;
     char            *workdir;
-    char            *filter;
-    char            *skycell_id;
-    char            *tess_id;
-    psF64           ra;
-    psF64           decl;
-    char            *input_ss;
-    char            *output_ss;
-} p4RunRow;
-
-/** Creates a new p4RunRow object
- *
- *  @return A new p4RunRow object or NULL on failure.
- */
-
-p4RunRow *p4RunRowAlloc(
-    psS32           p4_id,
-    const char      *survey_mode,
+    bool            magic;
+} p4aRunRow;
+
+/** Creates a new p4aRunRow object
+ *
+ *  @return A new p4aRunRow object or NULL on failure.
+ */
+
+p4aRunRow *p4aRunRowAlloc(
+    psS32           p4a_id,
     const char      *state,
     const char      *workdir,
-    const char      *filter,
-    const char      *skycell_id,
-    const char      *tess_id,
-    psF64           ra,
-    psF64           decl,
-    const char      *input_ss,
-    const char      *output_ss
-);
-
-/** Creates a new p4Run table
- *
- * @return true on success
- */
-
-bool p4RunCreateTable(
+    bool            magic
+);
+
+/** Creates a new p4aRun table
+ *
+ * @return true on success
+ */
+
+bool p4aRunCreateTable(
     psDB            *dbh                ///< Database handle
 );
 
-/** Deletes a p4Run table
- *
- * @return true on success
- */
-
-bool p4RunDropTable(
+/** Deletes a p4aRun table
+ *
+ * @return true on success
+ */
+
+bool p4aRunDropTable(
     psDB            *dbh                ///< Database handle
 );
@@ -6893,17 +6879,10 @@
  */
 
-bool p4RunInsert(
-    psDB            *dbh,               ///< Database handle
-    psS32           p4_id,
-    const char      *survey_mode,
+bool p4aRunInsert(
+    psDB            *dbh,               ///< Database handle
+    psS32           p4a_id,
     const char      *state,
     const char      *workdir,
-    const char      *filter,
-    const char      *skycell_id,
-    const char      *tess_id,
-    psF64           ra,
-    psF64           decl,
-    const char      *input_ss,
-    const char      *output_ss
+    bool            magic
 );
 
@@ -6913,5 +6892,5 @@
  */
 
-long long p4RunDelete(
+long long p4aRunDelete(
     psDB            *dbh,               ///< Database handle
     const psMetadata *where,            ///< Row match criteria
@@ -6919,5 +6898,5 @@
 );
 
-/** Insert a single p4RunRow object into a table
+/** Insert a single p4aRunRow object into a table
  *
  * This function constructs and inserts a single row based on it's parameters.
@@ -6926,10 +6905,10 @@
  */
 
-bool p4RunInsertObject(
-    psDB            *dbh,               ///< Database handle
-    p4RunRow        *object             ///< p4RunRow object
-);
-
-/** Insert an array of p4RunRow object into a table
+bool p4aRunInsertObject(
+    psDB            *dbh,               ///< Database handle
+    p4aRunRow       *object             ///< p4aRunRow object
+);
+
+/** Insert an array of p4aRunRow object into a table
  *
  * This function constructs and inserts multiple rows based on it's parameters.
@@ -6938,10 +6917,10 @@
  */
 
-bool p4RunInsertObjects(
-    psDB            *dbh,               ///< Database handle
-    psArray         *objects            ///< array of p4RunRow objects
-);
-
-/** Insert data from a binary FITS table p4RunRow into the database
+bool p4aRunInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of p4aRunRow objects
+);
+
+/** Insert data from a binary FITS table p4aRunRow into the database
  *
  * This function expects a psFits object with a FITS table as the first
@@ -6953,5 +6932,5 @@
  */
 
-bool p4RunInsertFits(
+bool p4aRunInsertFits(
     psDB            *dbh,               ///< Database handle
     const psFits    *fits               ///< psFits object
@@ -6968,5 +6947,5 @@
  */
 
-bool p4RunSelectRowsFits(
+bool p4aRunSelectRowsFits(
     psDB            *dbh,               ///< Database handle
     psFits          *fits,              ///< psFits object
@@ -6975,22 +6954,22 @@
 );
 
-/** Convert a p4RunRow into an equivalent psMetadata
+/** Convert a p4aRunRow into an equivalent psMetadata
  *
  * @return A psMetadata pointer or NULL on error
  */
 
-psMetadata *p4RunMetadataFromObject(
-    const p4RunRow  *object             ///< fooRow to convert into a psMetadata
+psMetadata *p4aRunMetadataFromObject(
+    const p4aRunRow *object             ///< fooRow to convert into a psMetadata
 );
 
 /** Convert a psMetadata into an equivalent fooRow
  *
- * @return A p4RunRow pointer or NULL on error
- */
-
-p4RunRow *p4RunObjectFromMetadata(
+ * @return A p4aRunRow pointer or NULL on error
+ */
+
+p4aRunRow *p4aRunObjectFromMetadata(
     psMetadata      *md                 ///< psMetadata to convert into a fooRow
 );
-/** Selects up to limit rows from the database and returns as p4RunRow objects in a psArray
+/** Selects up to limit rows from the database and returns as p4aRunRow objects in a psArray
  *
  *  See psDBSelectRows() for documentation on the format of where.
@@ -6999,10 +6978,10 @@
  */
 
-psArray *p4RunSelectRowObjects(
+psArray *p4aRunSelectRowObjects(
     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 p4Run
+/** Deletes a row from the database coresponding to an p4aRun
  *
  *  Note that a 'where' search psMetadata is constructed from each object and
@@ -7012,7 +6991,7 @@
  */
 
-bool p4RunDeleteObject(
-    psDB            *dbh,               ///< Database handle
-    const p4RunRow *object    ///< Object to delete
+bool p4aRunDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const p4aRunRow *object    ///< Object to delete
 );
 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
@@ -7024,10 +7003,10 @@
  */
 
-long long p4RunDeleteRowObjects(
+long long p4aRunDeleteRowObjects(
     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 p4RunRow objects
+/** Formats and prints an array of p4aRunRow objects
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -7037,10 +7016,10 @@
  */
 
-bool p4RunPrintObjects(
+bool p4aRunPrintObjects(
     FILE            *stream,            ///< a stream
-    psArray         *objects,           ///< An array of p4RunRow objects
+    psArray         *objects,           ///< An array of p4aRunRow objects
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** Formats and prints an p4RunRow object
+/** Formats and prints an p4aRunRow object
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -7050,48 +7029,46 @@
  */
 
-bool p4RunPrintObject(
+bool p4aRunPrintObject(
     FILE            *stream,            ///< a stream
-    p4RunRow *object,    ///< an p4RunRow object
+    p4aRunRow *object,    ///< an p4aRunRow object
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** p4InputImfileRow data structure
- *
- * Structure for representing a single row of p4InputImfile table data.
+/** p4aInputExpRow data structure
+ *
+ * Structure for representing a single row of p4aInputExp table data.
  */
 
 typedef struct {
-    psS32           p4_id;
+    psS32           p4a_id;
     char            *exp_tag;
     psS32           p3_version;
-    char            *class_id;
-} p4InputImfileRow;
-
-/** Creates a new p4InputImfileRow object
- *
- *  @return A new p4InputImfileRow object or NULL on failure.
- */
-
-p4InputImfileRow *p4InputImfileRowAlloc(
-    psS32           p4_id,
+} p4aInputExpRow;
+
+/** Creates a new p4aInputExpRow object
+ *
+ *  @return A new p4aInputExpRow object or NULL on failure.
+ */
+
+p4aInputExpRow *p4aInputExpRowAlloc(
+    psS32           p4a_id,
     const char      *exp_tag,
-    psS32           p3_version,
-    const char      *class_id
-);
-
-/** Creates a new p4InputImfile table
- *
- * @return true on success
- */
-
-bool p4InputImfileCreateTable(
+    psS32           p3_version
+);
+
+/** Creates a new p4aInputExp table
+ *
+ * @return true on success
+ */
+
+bool p4aInputExpCreateTable(
     psDB            *dbh                ///< Database handle
 );
 
-/** Deletes a p4InputImfile table
- *
- * @return true on success
- */
-
-bool p4InputImfileDropTable(
+/** Deletes a p4aInputExp table
+ *
+ * @return true on success
+ */
+
+bool p4aInputExpDropTable(
     psDB            *dbh                ///< Database handle
 );
@@ -7104,10 +7081,9 @@
  */
 
-bool p4InputImfileInsert(
-    psDB            *dbh,               ///< Database handle
-    psS32           p4_id,
+bool p4aInputExpInsert(
+    psDB            *dbh,               ///< Database handle
+    psS32           p4a_id,
     const char      *exp_tag,
-    psS32           p3_version,
-    const char      *class_id
+    psS32           p3_version
 );
 
@@ -7117,5 +7093,5 @@
  */
 
-long long p4InputImfileDelete(
+long long p4aInputExpDelete(
     psDB            *dbh,               ///< Database handle
     const psMetadata *where,            ///< Row match criteria
@@ -7123,5 +7099,5 @@
 );
 
-/** Insert a single p4InputImfileRow object into a table
+/** Insert a single p4aInputExpRow object into a table
  *
  * This function constructs and inserts a single row based on it's parameters.
@@ -7130,10 +7106,10 @@
  */
 
-bool p4InputImfileInsertObject(
-    psDB            *dbh,               ///< Database handle
-    p4InputImfileRow *object             ///< p4InputImfileRow object
-);
-
-/** Insert an array of p4InputImfileRow object into a table
+bool p4aInputExpInsertObject(
+    psDB            *dbh,               ///< Database handle
+    p4aInputExpRow  *object             ///< p4aInputExpRow object
+);
+
+/** Insert an array of p4aInputExpRow object into a table
  *
  * This function constructs and inserts multiple rows based on it's parameters.
@@ -7142,10 +7118,10 @@
  */
 
-bool p4InputImfileInsertObjects(
-    psDB            *dbh,               ///< Database handle
-    psArray         *objects            ///< array of p4InputImfileRow objects
-);
-
-/** Insert data from a binary FITS table p4InputImfileRow into the database
+bool p4aInputExpInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of p4aInputExpRow objects
+);
+
+/** Insert data from a binary FITS table p4aInputExpRow into the database
  *
  * This function expects a psFits object with a FITS table as the first
@@ -7157,5 +7133,5 @@
  */
 
-bool p4InputImfileInsertFits(
+bool p4aInputExpInsertFits(
     psDB            *dbh,               ///< Database handle
     const psFits    *fits               ///< psFits object
@@ -7172,5 +7148,5 @@
  */
 
-bool p4InputImfileSelectRowsFits(
+bool p4aInputExpSelectRowsFits(
     psDB            *dbh,               ///< Database handle
     psFits          *fits,              ///< psFits object
@@ -7179,22 +7155,22 @@
 );
 
-/** Convert a p4InputImfileRow into an equivalent psMetadata
+/** Convert a p4aInputExpRow into an equivalent psMetadata
  *
  * @return A psMetadata pointer or NULL on error
  */
 
-psMetadata *p4InputImfileMetadataFromObject(
-    const p4InputImfileRow *object             ///< fooRow to convert into a psMetadata
+psMetadata *p4aInputExpMetadataFromObject(
+    const p4aInputExpRow *object             ///< fooRow to convert into a psMetadata
 );
 
 /** Convert a psMetadata into an equivalent fooRow
  *
- * @return A p4InputImfileRow pointer or NULL on error
- */
-
-p4InputImfileRow *p4InputImfileObjectFromMetadata(
+ * @return A p4aInputExpRow pointer or NULL on error
+ */
+
+p4aInputExpRow *p4aInputExpObjectFromMetadata(
     psMetadata      *md                 ///< psMetadata to convert into a fooRow
 );
-/** Selects up to limit rows from the database and returns as p4InputImfileRow objects in a psArray
+/** Selects up to limit rows from the database and returns as p4aInputExpRow objects in a psArray
  *
  *  See psDBSelectRows() for documentation on the format of where.
@@ -7203,10 +7179,10 @@
  */
 
-psArray *p4InputImfileSelectRowObjects(
+psArray *p4aInputExpSelectRowObjects(
     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 p4InputImfile
+/** Deletes a row from the database coresponding to an p4aInputExp
  *
  *  Note that a 'where' search psMetadata is constructed from each object and
@@ -7216,7 +7192,7 @@
  */
 
-bool p4InputImfileDeleteObject(
-    psDB            *dbh,               ///< Database handle
-    const p4InputImfileRow *object    ///< Object to delete
+bool p4aInputExpDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const p4aInputExpRow *object    ///< Object to delete
 );
 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
@@ -7228,10 +7204,10 @@
  */
 
-long long p4InputImfileDeleteRowObjects(
+long long p4aInputExpDeleteRowObjects(
     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 p4InputImfileRow objects
+/** Formats and prints an array of p4aInputExpRow objects
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -7241,10 +7217,10 @@
  */
 
-bool p4InputImfilePrintObjects(
+bool p4aInputExpPrintObjects(
     FILE            *stream,            ///< a stream
-    psArray         *objects,           ///< An array of p4InputImfileRow objects
+    psArray         *objects,           ///< An array of p4aInputExpRow objects
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** Formats and prints an p4InputImfileRow object
+/** Formats and prints an p4aInputExpRow object
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -7254,54 +7230,56 @@
  */
 
-bool p4InputImfilePrintObject(
+bool p4aInputExpPrintObject(
     FILE            *stream,            ///< a stream
-    p4InputImfileRow *object,    ///< an p4InputImfileRow object
+    p4aInputExpRow *object,    ///< an p4aInputExpRow object
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** p4WarpedImfileRow data structure
- *
- * Structure for representing a single row of p4WarpedImfile table data.
+/** p4aScfileRow data structure
+ *
+ * Structure for representing a single row of p4aScfile table data.
  */
 
 typedef struct {
-    psS32           p4_id;
+    psS32           p4a_id;
+    char            *skycell_id;
+    char            *tess_id;
     char            *exp_tag;
     psS32           p3_version;
-    char            *class_id;
     char            *uri;
-    char            *b1_uri;
-    char            *b2_uri;
-} p4WarpedImfileRow;
-
-/** Creates a new p4WarpedImfileRow object
- *
- *  @return A new p4WarpedImfileRow object or NULL on failure.
- */
-
-p4WarpedImfileRow *p4WarpedImfileRowAlloc(
-    psS32           p4_id,
+    psF64           bg;
+    psF64           bg_mean_stdev;
+} p4aScfileRow;
+
+/** Creates a new p4aScfileRow object
+ *
+ *  @return A new p4aScfileRow object or NULL on failure.
+ */
+
+p4aScfileRow *p4aScfileRowAlloc(
+    psS32           p4a_id,
+    const char      *skycell_id,
+    const char      *tess_id,
     const char      *exp_tag,
     psS32           p3_version,
-    const char      *class_id,
     const char      *uri,
-    const char      *b1_uri,
-    const char      *b2_uri
-);
-
-/** Creates a new p4WarpedImfile table
- *
- * @return true on success
- */
-
-bool p4WarpedImfileCreateTable(
+    psF64           bg,
+    psF64           bg_mean_stdev
+);
+
+/** Creates a new p4aScfile table
+ *
+ * @return true on success
+ */
+
+bool p4aScfileCreateTable(
     psDB            *dbh                ///< Database handle
 );
 
-/** Deletes a p4WarpedImfile table
- *
- * @return true on success
- */
-
-bool p4WarpedImfileDropTable(
+/** Deletes a p4aScfile table
+ *
+ * @return true on success
+ */
+
+bool p4aScfileDropTable(
     psDB            *dbh                ///< Database handle
 );
@@ -7314,13 +7292,14 @@
  */
 
-bool p4WarpedImfileInsert(
-    psDB            *dbh,               ///< Database handle
-    psS32           p4_id,
+bool p4aScfileInsert(
+    psDB            *dbh,               ///< Database handle
+    psS32           p4a_id,
+    const char      *skycell_id,
+    const char      *tess_id,
     const char      *exp_tag,
     psS32           p3_version,
-    const char      *class_id,
     const char      *uri,
-    const char      *b1_uri,
-    const char      *b2_uri
+    psF64           bg,
+    psF64           bg_mean_stdev
 );
 
@@ -7330,5 +7309,5 @@
  */
 
-long long p4WarpedImfileDelete(
+long long p4aScfileDelete(
     psDB            *dbh,               ///< Database handle
     const psMetadata *where,            ///< Row match criteria
@@ -7336,5 +7315,5 @@
 );
 
-/** Insert a single p4WarpedImfileRow object into a table
+/** Insert a single p4aScfileRow object into a table
  *
  * This function constructs and inserts a single row based on it's parameters.
@@ -7343,10 +7322,10 @@
  */
 
-bool p4WarpedImfileInsertObject(
-    psDB            *dbh,               ///< Database handle
-    p4WarpedImfileRow *object             ///< p4WarpedImfileRow object
-);
-
-/** Insert an array of p4WarpedImfileRow object into a table
+bool p4aScfileInsertObject(
+    psDB            *dbh,               ///< Database handle
+    p4aScfileRow    *object             ///< p4aScfileRow object
+);
+
+/** Insert an array of p4aScfileRow object into a table
  *
  * This function constructs and inserts multiple rows based on it's parameters.
@@ -7355,10 +7334,10 @@
  */
 
-bool p4WarpedImfileInsertObjects(
-    psDB            *dbh,               ///< Database handle
-    psArray         *objects            ///< array of p4WarpedImfileRow objects
-);
-
-/** Insert data from a binary FITS table p4WarpedImfileRow into the database
+bool p4aScfileInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of p4aScfileRow objects
+);
+
+/** Insert data from a binary FITS table p4aScfileRow into the database
  *
  * This function expects a psFits object with a FITS table as the first
@@ -7370,5 +7349,5 @@
  */
 
-bool p4WarpedImfileInsertFits(
+bool p4aScfileInsertFits(
     psDB            *dbh,               ///< Database handle
     const psFits    *fits               ///< psFits object
@@ -7385,5 +7364,5 @@
  */
 
-bool p4WarpedImfileSelectRowsFits(
+bool p4aScfileSelectRowsFits(
     psDB            *dbh,               ///< Database handle
     psFits          *fits,              ///< psFits object
@@ -7392,22 +7371,22 @@
 );
 
-/** Convert a p4WarpedImfileRow into an equivalent psMetadata
+/** Convert a p4aScfileRow into an equivalent psMetadata
  *
  * @return A psMetadata pointer or NULL on error
  */
 
-psMetadata *p4WarpedImfileMetadataFromObject(
-    const p4WarpedImfileRow *object             ///< fooRow to convert into a psMetadata
+psMetadata *p4aScfileMetadataFromObject(
+    const p4aScfileRow *object             ///< fooRow to convert into a psMetadata
 );
 
 /** Convert a psMetadata into an equivalent fooRow
  *
- * @return A p4WarpedImfileRow pointer or NULL on error
- */
-
-p4WarpedImfileRow *p4WarpedImfileObjectFromMetadata(
+ * @return A p4aScfileRow pointer or NULL on error
+ */
+
+p4aScfileRow *p4aScfileObjectFromMetadata(
     psMetadata      *md                 ///< psMetadata to convert into a fooRow
 );
-/** Selects up to limit rows from the database and returns as p4WarpedImfileRow objects in a psArray
+/** Selects up to limit rows from the database and returns as p4aScfileRow objects in a psArray
  *
  *  See psDBSelectRows() for documentation on the format of where.
@@ -7416,10 +7395,10 @@
  */
 
-psArray *p4WarpedImfileSelectRowObjects(
+psArray *p4aScfileSelectRowObjects(
     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 p4WarpedImfile
+/** Deletes a row from the database coresponding to an p4aScfile
  *
  *  Note that a 'where' search psMetadata is constructed from each object and
@@ -7429,7 +7408,7 @@
  */
 
-bool p4WarpedImfileDeleteObject(
-    psDB            *dbh,               ///< Database handle
-    const p4WarpedImfileRow *object    ///< Object to delete
+bool p4aScfileDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const p4aScfileRow *object    ///< Object to delete
 );
 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
@@ -7441,10 +7420,10 @@
  */
 
-long long p4WarpedImfileDeleteRowObjects(
+long long p4aScfileDeleteRowObjects(
     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 p4WarpedImfileRow objects
+/** Formats and prints an array of p4aScfileRow objects
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -7454,10 +7433,10 @@
  */
 
-bool p4WarpedImfilePrintObjects(
+bool p4aScfilePrintObjects(
     FILE            *stream,            ///< a stream
-    psArray         *objects,           ///< An array of p4WarpedImfileRow objects
+    psArray         *objects,           ///< An array of p4aScfileRow objects
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** Formats and prints an p4WarpedImfileRow object
+/** Formats and prints an p4aScfileRow object
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -7467,50 +7446,48 @@
  */
 
-bool p4WarpedImfilePrintObject(
+bool p4aScfilePrintObject(
     FILE            *stream,            ///< a stream
-    p4WarpedImfileRow *object,    ///< an p4WarpedImfileRow object
+    p4aScfileRow *object,    ///< an p4aScfileRow object
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** p4StackedImfileRow data structure
- *
- * Structure for representing a single row of p4StackedImfile table data.
+/** p4bRunRow data structure
+ *
+ * Structure for representing a single row of p4bRun table data.
  */
 
 typedef struct {
-    psS32           p4_id;
-    char            *class_id;
-    char            *uri;
-    char            *b1_uri;
-    char            *b2_uri;
-} p4StackedImfileRow;
-
-/** Creates a new p4StackedImfileRow object
- *
- *  @return A new p4StackedImfileRow object or NULL on failure.
- */
-
-p4StackedImfileRow *p4StackedImfileRowAlloc(
-    psS32           p4_id,
-    const char      *class_id,
-    const char      *uri,
-    const char      *b1_uri,
-    const char      *b2_uri
-);
-
-/** Creates a new p4StackedImfile table
- *
- * @return true on success
- */
-
-bool p4StackedImfileCreateTable(
+    psS32           p4b_id;
+    char            *state;
+    char            *workdir;
+    bool            magic;
+} p4bRunRow;
+
+/** Creates a new p4bRunRow object
+ *
+ *  @return A new p4bRunRow object or NULL on failure.
+ */
+
+p4bRunRow *p4bRunRowAlloc(
+    psS32           p4b_id,
+    const char      *state,
+    const char      *workdir,
+    bool            magic
+);
+
+/** Creates a new p4bRun table
+ *
+ * @return true on success
+ */
+
+bool p4bRunCreateTable(
     psDB            *dbh                ///< Database handle
 );
 
-/** Deletes a p4StackedImfile table
- *
- * @return true on success
- */
-
-bool p4StackedImfileDropTable(
+/** Deletes a p4bRun table
+ *
+ * @return true on success
+ */
+
+bool p4bRunDropTable(
     psDB            *dbh                ///< Database handle
 );
@@ -7523,11 +7500,10 @@
  */
 
-bool p4StackedImfileInsert(
-    psDB            *dbh,               ///< Database handle
-    psS32           p4_id,
-    const char      *class_id,
-    const char      *uri,
-    const char      *b1_uri,
-    const char      *b2_uri
+bool p4bRunInsert(
+    psDB            *dbh,               ///< Database handle
+    psS32           p4b_id,
+    const char      *state,
+    const char      *workdir,
+    bool            magic
 );
 
@@ -7537,5 +7513,5 @@
  */
 
-long long p4StackedImfileDelete(
+long long p4bRunDelete(
     psDB            *dbh,               ///< Database handle
     const psMetadata *where,            ///< Row match criteria
@@ -7543,5 +7519,5 @@
 );
 
-/** Insert a single p4StackedImfileRow object into a table
+/** Insert a single p4bRunRow object into a table
  *
  * This function constructs and inserts a single row based on it's parameters.
@@ -7550,10 +7526,10 @@
  */
 
-bool p4StackedImfileInsertObject(
-    psDB            *dbh,               ///< Database handle
-    p4StackedImfileRow *object             ///< p4StackedImfileRow object
-);
-
-/** Insert an array of p4StackedImfileRow object into a table
+bool p4bRunInsertObject(
+    psDB            *dbh,               ///< Database handle
+    p4bRunRow       *object             ///< p4bRunRow object
+);
+
+/** Insert an array of p4bRunRow object into a table
  *
  * This function constructs and inserts multiple rows based on it's parameters.
@@ -7562,10 +7538,10 @@
  */
 
-bool p4StackedImfileInsertObjects(
-    psDB            *dbh,               ///< Database handle
-    psArray         *objects            ///< array of p4StackedImfileRow objects
-);
-
-/** Insert data from a binary FITS table p4StackedImfileRow into the database
+bool p4bRunInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of p4bRunRow objects
+);
+
+/** Insert data from a binary FITS table p4bRunRow into the database
  *
  * This function expects a psFits object with a FITS table as the first
@@ -7577,5 +7553,5 @@
  */
 
-bool p4StackedImfileInsertFits(
+bool p4bRunInsertFits(
     psDB            *dbh,               ///< Database handle
     const psFits    *fits               ///< psFits object
@@ -7592,5 +7568,5 @@
  */
 
-bool p4StackedImfileSelectRowsFits(
+bool p4bRunSelectRowsFits(
     psDB            *dbh,               ///< Database handle
     psFits          *fits,              ///< psFits object
@@ -7599,22 +7575,22 @@
 );
 
-/** Convert a p4StackedImfileRow into an equivalent psMetadata
+/** Convert a p4bRunRow into an equivalent psMetadata
  *
  * @return A psMetadata pointer or NULL on error
  */
 
-psMetadata *p4StackedImfileMetadataFromObject(
-    const p4StackedImfileRow *object             ///< fooRow to convert into a psMetadata
+psMetadata *p4bRunMetadataFromObject(
+    const p4bRunRow *object             ///< fooRow to convert into a psMetadata
 );
 
 /** Convert a psMetadata into an equivalent fooRow
  *
- * @return A p4StackedImfileRow pointer or NULL on error
- */
-
-p4StackedImfileRow *p4StackedImfileObjectFromMetadata(
+ * @return A p4bRunRow pointer or NULL on error
+ */
+
+p4bRunRow *p4bRunObjectFromMetadata(
     psMetadata      *md                 ///< psMetadata to convert into a fooRow
 );
-/** Selects up to limit rows from the database and returns as p4StackedImfileRow objects in a psArray
+/** Selects up to limit rows from the database and returns as p4bRunRow objects in a psArray
  *
  *  See psDBSelectRows() for documentation on the format of where.
@@ -7623,10 +7599,10 @@
  */
 
-psArray *p4StackedImfileSelectRowObjects(
+psArray *p4bRunSelectRowObjects(
     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 p4StackedImfile
+/** Deletes a row from the database coresponding to an p4bRun
  *
  *  Note that a 'where' search psMetadata is constructed from each object and
@@ -7636,7 +7612,7 @@
  */
 
-bool p4StackedImfileDeleteObject(
-    psDB            *dbh,               ///< Database handle
-    const p4StackedImfileRow *object    ///< Object to delete
+bool p4bRunDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const p4bRunRow *object    ///< Object to delete
 );
 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
@@ -7648,10 +7624,10 @@
  */
 
-long long p4StackedImfileDeleteRowObjects(
+long long p4bRunDeleteRowObjects(
     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 p4StackedImfileRow objects
+/** Formats and prints an array of p4bRunRow objects
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -7661,10 +7637,10 @@
  */
 
-bool p4StackedImfilePrintObjects(
+bool p4bRunPrintObjects(
     FILE            *stream,            ///< a stream
-    psArray         *objects,           ///< An array of p4StackedImfileRow objects
+    psArray         *objects,           ///< An array of p4bRunRow objects
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** Formats and prints an p4StackedImfileRow object
+/** Formats and prints an p4bRunRow object
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -7674,54 +7650,52 @@
  */
 
-bool p4StackedImfilePrintObject(
+bool p4bRunPrintObject(
     FILE            *stream,            ///< a stream
-    p4StackedImfileRow *object,    ///< an p4StackedImfileRow object
+    p4bRunRow *object,    ///< an p4bRunRow object
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** p4DiffImfileRow data structure
- *
- * Structure for representing a single row of p4DiffImfile table data.
+/** p4bInputScfileRow data structure
+ *
+ * Structure for representing a single row of p4bInputScfile table data.
  */
 
 typedef struct {
-    psS32           p4_id;
+    psS32           p4b_id;
+    char            *skycell_id;
+    char            *tess_id;
     char            *exp_tag;
     psS32           p3_version;
-    char            *class_id;
-    char            *uri;
-    char            *b1_uri;
-    char            *b2_uri;
-} p4DiffImfileRow;
-
-/** Creates a new p4DiffImfileRow object
- *
- *  @return A new p4DiffImfileRow object or NULL on failure.
- */
-
-p4DiffImfileRow *p4DiffImfileRowAlloc(
-    psS32           p4_id,
+    char            *kind;
+} p4bInputScfileRow;
+
+/** Creates a new p4bInputScfileRow object
+ *
+ *  @return A new p4bInputScfileRow object or NULL on failure.
+ */
+
+p4bInputScfileRow *p4bInputScfileRowAlloc(
+    psS32           p4b_id,
+    const char      *skycell_id,
+    const char      *tess_id,
     const char      *exp_tag,
     psS32           p3_version,
-    const char      *class_id,
-    const char      *uri,
-    const char      *b1_uri,
-    const char      *b2_uri
-);
-
-/** Creates a new p4DiffImfile table
- *
- * @return true on success
- */
-
-bool p4DiffImfileCreateTable(
+    const char      *kind
+);
+
+/** Creates a new p4bInputScfile table
+ *
+ * @return true on success
+ */
+
+bool p4bInputScfileCreateTable(
     psDB            *dbh                ///< Database handle
 );
 
-/** Deletes a p4DiffImfile table
- *
- * @return true on success
- */
-
-bool p4DiffImfileDropTable(
+/** Deletes a p4bInputScfile table
+ *
+ * @return true on success
+ */
+
+bool p4bInputScfileDropTable(
     psDB            *dbh                ///< Database handle
 );
@@ -7734,13 +7708,12 @@
  */
 
-bool p4DiffImfileInsert(
-    psDB            *dbh,               ///< Database handle
-    psS32           p4_id,
+bool p4bInputScfileInsert(
+    psDB            *dbh,               ///< Database handle
+    psS32           p4b_id,
+    const char      *skycell_id,
+    const char      *tess_id,
     const char      *exp_tag,
     psS32           p3_version,
-    const char      *class_id,
-    const char      *uri,
-    const char      *b1_uri,
-    const char      *b2_uri
+    const char      *kind
 );
 
@@ -7750,5 +7723,5 @@
  */
 
-long long p4DiffImfileDelete(
+long long p4bInputScfileDelete(
     psDB            *dbh,               ///< Database handle
     const psMetadata *where,            ///< Row match criteria
@@ -7756,5 +7729,5 @@
 );
 
-/** Insert a single p4DiffImfileRow object into a table
+/** Insert a single p4bInputScfileRow object into a table
  *
  * This function constructs and inserts a single row based on it's parameters.
@@ -7763,10 +7736,10 @@
  */
 
-bool p4DiffImfileInsertObject(
-    psDB            *dbh,               ///< Database handle
-    p4DiffImfileRow *object             ///< p4DiffImfileRow object
-);
-
-/** Insert an array of p4DiffImfileRow object into a table
+bool p4bInputScfileInsertObject(
+    psDB            *dbh,               ///< Database handle
+    p4bInputScfileRow *object             ///< p4bInputScfileRow object
+);
+
+/** Insert an array of p4bInputScfileRow object into a table
  *
  * This function constructs and inserts multiple rows based on it's parameters.
@@ -7775,10 +7748,10 @@
  */
 
-bool p4DiffImfileInsertObjects(
-    psDB            *dbh,               ///< Database handle
-    psArray         *objects            ///< array of p4DiffImfileRow objects
-);
-
-/** Insert data from a binary FITS table p4DiffImfileRow into the database
+bool p4bInputScfileInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of p4bInputScfileRow objects
+);
+
+/** Insert data from a binary FITS table p4bInputScfileRow into the database
  *
  * This function expects a psFits object with a FITS table as the first
@@ -7790,5 +7763,5 @@
  */
 
-bool p4DiffImfileInsertFits(
+bool p4bInputScfileInsertFits(
     psDB            *dbh,               ///< Database handle
     const psFits    *fits               ///< psFits object
@@ -7805,5 +7778,5 @@
  */
 
-bool p4DiffImfileSelectRowsFits(
+bool p4bInputScfileSelectRowsFits(
     psDB            *dbh,               ///< Database handle
     psFits          *fits,              ///< psFits object
@@ -7812,22 +7785,22 @@
 );
 
-/** Convert a p4DiffImfileRow into an equivalent psMetadata
+/** Convert a p4bInputScfileRow into an equivalent psMetadata
  *
  * @return A psMetadata pointer or NULL on error
  */
 
-psMetadata *p4DiffImfileMetadataFromObject(
-    const p4DiffImfileRow *object             ///< fooRow to convert into a psMetadata
+psMetadata *p4bInputScfileMetadataFromObject(
+    const p4bInputScfileRow *object             ///< fooRow to convert into a psMetadata
 );
 
 /** Convert a psMetadata into an equivalent fooRow
  *
- * @return A p4DiffImfileRow pointer or NULL on error
- */
-
-p4DiffImfileRow *p4DiffImfileObjectFromMetadata(
+ * @return A p4bInputScfileRow pointer or NULL on error
+ */
+
+p4bInputScfileRow *p4bInputScfileObjectFromMetadata(
     psMetadata      *md                 ///< psMetadata to convert into a fooRow
 );
-/** Selects up to limit rows from the database and returns as p4DiffImfileRow objects in a psArray
+/** Selects up to limit rows from the database and returns as p4bInputScfileRow objects in a psArray
  *
  *  See psDBSelectRows() for documentation on the format of where.
@@ -7836,10 +7809,10 @@
  */
 
-psArray *p4DiffImfileSelectRowObjects(
+psArray *p4bInputScfileSelectRowObjects(
     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 p4DiffImfile
+/** Deletes a row from the database coresponding to an p4bInputScfile
  *
  *  Note that a 'where' search psMetadata is constructed from each object and
@@ -7849,7 +7822,7 @@
  */
 
-bool p4DiffImfileDeleteObject(
-    psDB            *dbh,               ///< Database handle
-    const p4DiffImfileRow *object    ///< Object to delete
+bool p4bInputScfileDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const p4bInputScfileRow *object    ///< Object to delete
 );
 /** Deletes up to limit rows from the database and returns the number of rows actually deleted. 
@@ -7861,10 +7834,10 @@
  */
 
-long long p4DiffImfileDeleteRowObjects(
+long long p4bInputScfileDeleteRowObjects(
     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 p4DiffImfileRow objects
+/** Formats and prints an array of p4bInputScfileRow objects
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -7874,10 +7847,10 @@
  */
 
-bool p4DiffImfilePrintObjects(
+bool p4bInputScfilePrintObjects(
     FILE            *stream,            ///< a stream
-    psArray         *objects,           ///< An array of p4DiffImfileRow objects
+    psArray         *objects,           ///< An array of p4bInputScfileRow objects
     bool            mdcf                ///< format as mdconfig or simple
 );
-/** Formats and prints an p4DiffImfileRow object
+/** Formats and prints an p4bInputScfileRow object
  *
  * When mdcf is set the formated output is in psMetadataConfig
@@ -7887,9 +7860,630 @@
  */
 
-bool p4DiffImfilePrintObject(
+bool p4bInputScfilePrintObject(
     FILE            *stream,            ///< a stream
-    p4DiffImfileRow *object,    ///< an p4DiffImfileRow object
+    p4bInputScfileRow *object,    ///< an p4bInputScfileRow object
     bool            mdcf                ///< format as mdconfig or simple
 );
+/** p4bDiffScfileRow data structure
+ *
+ * Structure for representing a single row of p4bDiffScfile table data.
+ */
+
+typedef struct {
+    psS32           p4b_id;
+    char            *skycell_id;
+    char            *tess_id;
+    char            *exp_tag;
+    psS32           p3_version;
+    char            *uri;
+    psF64           bg;
+    psF64           bg_mean_stdev;
+} p4bDiffScfileRow;
+
+/** Creates a new p4bDiffScfileRow object
+ *
+ *  @return A new p4bDiffScfileRow object or NULL on failure.
+ */
+
+p4bDiffScfileRow *p4bDiffScfileRowAlloc(
+    psS32           p4b_id,
+    const char      *skycell_id,
+    const char      *tess_id,
+    const char      *exp_tag,
+    psS32           p3_version,
+    const char      *uri,
+    psF64           bg,
+    psF64           bg_mean_stdev
+);
+
+/** Creates a new p4bDiffScfile table
+ *
+ * @return true on success
+ */
+
+bool p4bDiffScfileCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a p4bDiffScfile table
+ *
+ * @return true on success
+ */
+
+bool p4bDiffScfileDropTable(
+    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 p4bDiffScfileInsert(
+    psDB            *dbh,               ///< Database handle
+    psS32           p4b_id,
+    const char      *skycell_id,
+    const char      *tess_id,
+    const char      *exp_tag,
+    psS32           p3_version,
+    const char      *uri,
+    psF64           bg,
+    psF64           bg_mean_stdev
+);
+
+/** 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 p4bDiffScfileDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single p4bDiffScfileRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool p4bDiffScfileInsertObject(
+    psDB            *dbh,               ///< Database handle
+    p4bDiffScfileRow *object             ///< p4bDiffScfileRow object
+);
+
+/** Insert an array of p4bDiffScfileRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool p4bDiffScfileInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of p4bDiffScfileRow objects
+);
+
+/** Insert data from a binary FITS table p4bDiffScfileRow 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 p4bDiffScfileInsertFits(
+    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 p4bDiffScfileSelectRowsFits(
+    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 p4bDiffScfileRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *p4bDiffScfileMetadataFromObject(
+    const p4bDiffScfileRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A p4bDiffScfileRow pointer or NULL on error
+ */
+
+p4bDiffScfileRow *p4bDiffScfileObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as p4bDiffScfileRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *p4bDiffScfileSelectRowObjects(
+    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 p4bDiffScfile
+ *
+ *  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 p4bDiffScfileDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const p4bDiffScfileRow *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 p4bDiffScfileDeleteRowObjects(
+    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 p4bDiffScfileRow 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 p4bDiffScfilePrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of p4bDiffScfileRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an p4bDiffScfileRow 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 p4bDiffScfilePrintObject(
+    FILE            *stream,            ///< a stream
+    p4bDiffScfileRow *object,    ///< an p4bDiffScfileRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** p4cRunRow data structure
+ *
+ * Structure for representing a single row of p4cRun table data.
+ */
+
+typedef struct {
+    psS32           p4c_id;
+    char            *state;
+    char            *workdir;
+    bool            magic;
+} p4cRunRow;
+
+/** Creates a new p4cRunRow object
+ *
+ *  @return A new p4cRunRow object or NULL on failure.
+ */
+
+p4cRunRow *p4cRunRowAlloc(
+    psS32           p4c_id,
+    const char      *state,
+    const char      *workdir,
+    bool            magic
+);
+
+/** Creates a new p4cRun table
+ *
+ * @return true on success
+ */
+
+bool p4cRunCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a p4cRun table
+ *
+ * @return true on success
+ */
+
+bool p4cRunDropTable(
+    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 p4cRunInsert(
+    psDB            *dbh,               ///< Database handle
+    psS32           p4c_id,
+    const char      *state,
+    const char      *workdir,
+    bool            magic
+);
+
+/** 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 p4cRunDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single p4cRunRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool p4cRunInsertObject(
+    psDB            *dbh,               ///< Database handle
+    p4cRunRow       *object             ///< p4cRunRow object
+);
+
+/** Insert an array of p4cRunRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool p4cRunInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of p4cRunRow objects
+);
+
+/** Insert data from a binary FITS table p4cRunRow 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 p4cRunInsertFits(
+    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 p4cRunSelectRowsFits(
+    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 p4cRunRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *p4cRunMetadataFromObject(
+    const p4cRunRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A p4cRunRow pointer or NULL on error
+ */
+
+p4cRunRow *p4cRunObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as p4cRunRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *p4cRunSelectRowObjects(
+    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 p4cRun
+ *
+ *  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 p4cRunDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const p4cRunRow *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 p4cRunDeleteRowObjects(
+    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 p4cRunRow 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 p4cRunPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of p4cRunRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an p4cRunRow 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 p4cRunPrintObject(
+    FILE            *stream,            ///< a stream
+    p4cRunRow *object,    ///< an p4cRunRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** p4cInputExpRow data structure
+ *
+ * Structure for representing a single row of p4cInputExp table data.
+ */
+
+typedef struct {
+    psS32           p4c_id;
+    char            *exp_tag;
+    psS32           p3_version;
+} p4cInputExpRow;
+
+/** Creates a new p4cInputExpRow object
+ *
+ *  @return A new p4cInputExpRow object or NULL on failure.
+ */
+
+p4cInputExpRow *p4cInputExpRowAlloc(
+    psS32           p4c_id,
+    const char      *exp_tag,
+    psS32           p3_version
+);
+
+/** Creates a new p4cInputExp table
+ *
+ * @return true on success
+ */
+
+bool p4cInputExpCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a p4cInputExp table
+ *
+ * @return true on success
+ */
+
+bool p4cInputExpDropTable(
+    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 p4cInputExpInsert(
+    psDB            *dbh,               ///< Database handle
+    psS32           p4c_id,
+    const char      *exp_tag,
+    psS32           p3_version
+);
+
+/** 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 p4cInputExpDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single p4cInputExpRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool p4cInputExpInsertObject(
+    psDB            *dbh,               ///< Database handle
+    p4cInputExpRow  *object             ///< p4cInputExpRow object
+);
+
+/** Insert an array of p4cInputExpRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool p4cInputExpInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of p4cInputExpRow objects
+);
+
+/** Insert data from a binary FITS table p4cInputExpRow 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 p4cInputExpInsertFits(
+    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 p4cInputExpSelectRowsFits(
+    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 p4cInputExpRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *p4cInputExpMetadataFromObject(
+    const p4cInputExpRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A p4cInputExpRow pointer or NULL on error
+ */
+
+p4cInputExpRow *p4cInputExpObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as p4cInputExpRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *p4cInputExpSelectRowObjects(
+    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 p4cInputExp
+ *
+ *  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 p4cInputExpDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const p4cInputExpRow *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 p4cInputExpDeleteRowObjects(
+    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 p4cInputExpRow 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 p4cInputExpPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of p4cInputExpRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an p4cInputExpRow 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 p4cInputExpPrintObject(
+    FILE            *stream,            ///< a stream
+    p4cInputExpRow *object,    ///< an p4cInputExpRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
 /** p4MagicMaskImfileRow data structure
  *
@@ -7898,5 +8492,5 @@
 
 typedef struct {
-    psS32           p4_id;
+    psS32           p4c_id;
     char            *exp_tag;
     psS32           p3_version;
@@ -7911,5 +8505,5 @@
 
 p4MagicMaskImfileRow *p4MagicMaskImfileRowAlloc(
-    psS32           p4_id,
+    psS32           p4c_id,
     const char      *exp_tag,
     psS32           p3_version,
@@ -7945,5 +8539,5 @@
 bool p4MagicMaskImfileInsert(
     psDB            *dbh,               ///< Database handle
-    psS32           p4_id,
+    psS32           p4c_id,
     const char      *exp_tag,
     psS32           p3_version,
@@ -8099,4 +8693,430 @@
     bool            mdcf                ///< format as mdconfig or simple
 );
+/** skyCellRow data structure
+ *
+ * Structure for representing a single row of skyCell table data.
+ */
+
+typedef struct {
+    char            *skycell_id;
+    char            *tess_id;
+    psF64           ra1;
+    psF64           decl1;
+    psF64           ra2;
+    psF64           decl2;
+    psF64           ra3;
+    psF64           decl3;
+    psF64           ra4;
+    psF64           decl4;
+} skyCellRow;
+
+/** Creates a new skyCellRow object
+ *
+ *  @return A new skyCellRow object or NULL on failure.
+ */
+
+skyCellRow *skyCellRowAlloc(
+    const char      *skycell_id,
+    const char      *tess_id,
+    psF64           ra1,
+    psF64           decl1,
+    psF64           ra2,
+    psF64           decl2,
+    psF64           ra3,
+    psF64           decl3,
+    psF64           ra4,
+    psF64           decl4
+);
+
+/** Creates a new skyCell table
+ *
+ * @return true on success
+ */
+
+bool skyCellCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a skyCell table
+ *
+ * @return true on success
+ */
+
+bool skyCellDropTable(
+    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 skyCellInsert(
+    psDB            *dbh,               ///< Database handle
+    const char      *skycell_id,
+    const char      *tess_id,
+    psF64           ra1,
+    psF64           decl1,
+    psF64           ra2,
+    psF64           decl2,
+    psF64           ra3,
+    psF64           decl3,
+    psF64           ra4,
+    psF64           decl4
+);
+
+/** 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 skyCellDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single skyCellRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool skyCellInsertObject(
+    psDB            *dbh,               ///< Database handle
+    skyCellRow      *object             ///< skyCellRow object
+);
+
+/** Insert an array of skyCellRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool skyCellInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of skyCellRow objects
+);
+
+/** Insert data from a binary FITS table skyCellRow 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 skyCellInsertFits(
+    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 skyCellSelectRowsFits(
+    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 skyCellRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *skyCellMetadataFromObject(
+    const skyCellRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A skyCellRow pointer or NULL on error
+ */
+
+skyCellRow *skyCellObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as skyCellRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *skyCellSelectRowObjects(
+    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 skyCell
+ *
+ *  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 skyCellDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const skyCellRow *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 skyCellDeleteRowObjects(
+    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 skyCellRow 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 skyCellPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of skyCellRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an skyCellRow 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 skyCellPrintObject(
+    FILE            *stream,            ///< a stream
+    skyCellRow *object,    ///< an skyCellRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** skyCellMapRow data structure
+ *
+ * Structure for representing a single row of skyCellMap table data.
+ */
+
+typedef struct {
+    char            *skycell_id;
+    char            *tess_id;
+    char            *exp_tag;
+    char            *class_id;
+} skyCellMapRow;
+
+/** Creates a new skyCellMapRow object
+ *
+ *  @return A new skyCellMapRow object or NULL on failure.
+ */
+
+skyCellMapRow *skyCellMapRowAlloc(
+    const char      *skycell_id,
+    const char      *tess_id,
+    const char      *exp_tag,
+    const char      *class_id
+);
+
+/** Creates a new skyCellMap table
+ *
+ * @return true on success
+ */
+
+bool skyCellMapCreateTable(
+    psDB            *dbh                ///< Database handle
+);
+
+/** Deletes a skyCellMap table
+ *
+ * @return true on success
+ */
+
+bool skyCellMapDropTable(
+    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 skyCellMapInsert(
+    psDB            *dbh,               ///< Database handle
+    const char      *skycell_id,
+    const char      *tess_id,
+    const char      *exp_tag,
+    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 skyCellMapDelete(
+    psDB            *dbh,               ///< Database handle
+    const psMetadata *where,            ///< Row match criteria
+    unsigned long long limit            ///< Maximum number of elements to delete 
+);
+
+/** Insert a single skyCellMapRow object into a table
+ *
+ * This function constructs and inserts a single row based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool skyCellMapInsertObject(
+    psDB            *dbh,               ///< Database handle
+    skyCellMapRow   *object             ///< skyCellMapRow object
+);
+
+/** Insert an array of skyCellMapRow object into a table
+ *
+ * This function constructs and inserts multiple rows based on it's parameters.
+ *
+ * @return true on success
+ */
+
+bool skyCellMapInsertObjects(
+    psDB            *dbh,               ///< Database handle
+    psArray         *objects            ///< array of skyCellMapRow objects
+);
+
+/** Insert data from a binary FITS table skyCellMapRow 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 skyCellMapInsertFits(
+    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 skyCellMapSelectRowsFits(
+    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 skyCellMapRow into an equivalent psMetadata
+ *
+ * @return A psMetadata pointer or NULL on error
+ */
+
+psMetadata *skyCellMapMetadataFromObject(
+    const skyCellMapRow *object             ///< fooRow to convert into a psMetadata
+);
+
+/** Convert a psMetadata into an equivalent fooRow
+ *
+ * @return A skyCellMapRow pointer or NULL on error
+ */
+
+skyCellMapRow *skyCellMapObjectFromMetadata(
+    psMetadata      *md                 ///< psMetadata to convert into a fooRow
+);
+/** Selects up to limit rows from the database and returns as skyCellMapRow objects in a psArray
+ *
+ *  See psDBSelectRows() for documentation on the format of where.
+ *
+ * @return A psArray pointer or NULL on error
+ */
+
+psArray *skyCellMapSelectRowObjects(
+    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 skyCellMap
+ *
+ *  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 skyCellMapDeleteObject(
+    psDB            *dbh,               ///< Database handle
+    const skyCellMapRow *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 skyCellMapDeleteRowObjects(
+    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 skyCellMapRow 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 skyCellMapPrintObjects(
+    FILE            *stream,            ///< a stream
+    psArray         *objects,           ///< An array of skyCellMapRow objects
+    bool            mdcf                ///< format as mdconfig or simple
+);
+/** Formats and prints an skyCellMapRow 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 skyCellMapPrintObject(
+    FILE            *stream,            ///< a stream
+    skyCellMapRow *object,    ///< an skyCellMapRow object
+    bool            mdcf                ///< format as mdconfig or simple
+);
 
 /// @}
@@ -8106,3 +9126,3 @@
 #endif
 
-#endif // P4MAGICMASKIMFILE_DB_H
+#endif // SKYCELLMAP_DB_H
