Index: /trunk/dbconfig/chip.md
===================================================================
--- /trunk/dbconfig/chip.md	(revision 14064)
+++ /trunk/dbconfig/chip.md	(revision 14065)
@@ -1,27 +1,17 @@
-#
-#  We are dependant on the assumption that there is only ever one exp_id in a
-#  chipRun although the database does not enforce this.
-#
-
 chipRun METADATA
     chip_id     S64         0       # Primary Key AUTO_INCREMENT
-    state       STR         64      # key
+    exp_id      S64         64      # Primary Key fkey (exp_id) ref rawExp(exp_id)
+    state       STR         64      # Key
     workdir     STR         255 
-    workdir_state STR       64      # key
-    label       STR         64      # key
+    workdir_state STR       64      # Key
+    label       STR         64      # Key
     reduction   STR         64      # Reduction class
-    expgroup    STR         64      # key
+    expgroup    STR         64      # Key
     dvodb       STR         255
 END
 
-chipInputImfile METADATA
-    chip_id     S64         0       # Primary Key fkey (chip_id) ref chipRun(chip_id)
-    exp_id      S64         64      # Primary Key fkey (exp_id, class_id) ref rawImfile (exp_id, class_id)
-    class_id    STR         64      # Primary Key
-END
-
 chipProcessedImfile METADATA
-    chip_id     S64         0       # Primary Key fkey (chip_id, exp_id, class_id) ref chipInputImfile(chip_id, exp_id, class_id)
-    exp_id     S64         64      # Primary Key
+    chip_id         S64     0       # Primary Key fkey (chip_id, exp_id) ref chipRun(chip_id, exp_id)
+    exp_id          S64     64      # Primary Key fkey (exp_id, class_id) ref rawImfile(exp_id, class_id)
     class_id        STR     64      # Primary Key
     uri             STR     255
Index: /trunk/ippTools/share/Makefile.am
===================================================================
--- /trunk/ippTools/share/Makefile.am	(revision 14064)
+++ /trunk/ippTools/share/Makefile.am	(revision 14065)
@@ -9,5 +9,4 @@
 	chiptool_pendingimfile.sql \
 	chiptool_processedimfile.sql \
-	chiptool_queuerawimfile.sql \
 	detselect_search.sql \
 	detselect_select.sql \
Index: /trunk/ippTools/share/chiptool_completely_processed_exp.sql
===================================================================
--- /trunk/ippTools/share/chiptool_completely_processed_exp.sql	(revision 14064)
+++ /trunk/ippTools/share/chiptool_completely_processed_exp.sql	(revision 14065)
@@ -2,4 +2,5 @@
 SELECT DISTINCT
     chip_id,
+    exp_id,
     state,
     workdir,
@@ -15,20 +16,16 @@
         chipProcessedImfile.class_id
     FROM chipRun
-    JOIN chipInputImfile
-        USING(chip_id)
-    JOIN rawExp
-        ON chipInputImfile.exp_id = rawExp.exp_id
     JOIN rawImfile
-        ON rawExp.exp_id = rawImfile.exp_id
+        USING(exp_id)
     LEFT JOIN chipProcessedImfile
-        ON chipInputImfile.chip_id = chipProcessedImfile.chip_id
-        AND chipInputImfile.exp_id = chipProcessedImfile.exp_id
-        AND chipInputImfile.class_id = chipProcessedImfile.class_id
+        ON chipRun.chip_id = chipProcessedImfile.chip_id
+        AND rawImfile.exp_id = chipProcessedImfile.exp_id
+        AND rawImfile.class_id = chipProcessedImfile.class_id
     WHERE
         chipRun.state = 'run'
         AND chipProcessedImfile.fault = 0
     GROUP BY
-        chipInputImfile.chip_id,
-        chipInputImfile.exp_id
+        chipRun.chip_id,
+        chipRun.exp_id
     HAVING COUNT(rawImfile.class_id) = COUNT(chipProcessedImfile.class_id)
     ) as Foo
Index: /trunk/ippTools/share/chiptool_pendingimfile.sql
===================================================================
--- /trunk/ippTools/share/chiptool_pendingimfile.sql	(revision 14064)
+++ /trunk/ippTools/share/chiptool_pendingimfile.sql	(revision 14065)
@@ -1,6 +1,5 @@
 SELECT
     chipRun.*,
-    chipInputImfile.exp_id,
-    chipInputImfile.class_id,
+    rawImfile.class_id,
     rawImfile.uri,
     rawExp.exp_tag,
@@ -10,15 +9,12 @@
     rawExp.filelevel
 FROM chipRun
-JOIN chipInputImfile
-    USING(chip_id)
+JOIN rawExp
+    USING(exp_id)
+JOIN rawImfile
+    USING(exp_id)
 LEFT JOIN chipProcessedImfile
-    ON chipInputImfile.chip_id = chipProcessedImfile.chip_id
-    AND chipInputImfile.exp_id = chipProcessedImfile.exp_id
-    AND chipInputImfile.class_id = chipProcessedImfile.class_id
-JOIN rawImfile
-    ON chipInputImfile.exp_id = rawImfile.exp_id
-    AND chipInputImfile.class_id = rawImfile.class_id
-JOIN rawExp
-    ON rawImfile.exp_id = rawExp.exp_id
+    ON chipRun.chip_id = chipProcessedImfile.chip_id
+    AND rawImfile.exp_id = chipProcessedImfile.exp_id
+    AND rawImfile.class_id = chipProcessedImfile.class_id
 LEFT JOIN chipMask
     ON chipRun.label = chipMask.label
Index: unk/ippTools/share/chiptool_queuerawimfile.sql
===================================================================
--- /trunk/ippTools/share/chiptool_queuerawimfile.sql	(revision 14064)
+++ 	(revision )
@@ -1,13 +1,0 @@
-INSERT INTO chipInputImfile
-    SELECT
-        LAST_INSERT_ID(),
-        rawImfile.exp_id,
-        rawImfile.class_id
-    FROM rawImfile
-    JOIN newExp
-        USING(exp_id)
-    WHERE
-        rawImfile.fault = 0
-        AND newExp.state = 'stop'
-        AND rawImfile.exp_id = '%s'
-
Index: /trunk/ippTools/src/pxchip.c
===================================================================
--- /trunk/ippTools/src/pxchip.c	(revision 14064)
+++ /trunk/ippTools/src/pxchip.c	(revision 14065)
@@ -75,4 +75,5 @@
     if (!chipRunInsert(config->dbh,
             0x0,
+            (psS64)atoll(exp_id),
             "run",      // state                
             workdir,
@@ -91,30 +92,4 @@
     }
 
-#if 0
-    // get the chip_id
-    long chip_id = psDBLastInsertID(config->dbh);
-#endif
-
-    // populate the chipInputImfile table from rawImfile based on exp_id,
-    // where the coresponding newExp.state entry is set to stop
-    psString query = pxDataGetCached("chiptool_queuerawimfile.sql");
-    if (!query) {
-        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
-        return false;
-    }
-
-    // queue the imfiles for the exp_id
-    if (!p_psDBRunQuery(config->dbh, query, exp_id)) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
-        return false;
-    }
-
-    // just to be safe, we should have changed at least one row
-    if (psDBAffectedRows(config->dbh) < 1) {
-        psError(PS_ERR_UNKNOWN, false,
-                "no rows affected - should have changed at least one row");
-        return false;
-    }
-
     // point of no return
     if (!psDBCommit(config->dbh)) {
Index: /trunk/ippTools/src/pxtables.c
===================================================================
--- /trunk/ippTools/src/pxtables.c	(revision 14064)
+++ /trunk/ippTools/src/pxtables.c	(revision 14065)
@@ -63,5 +63,5 @@
     CREATE_TABLE(guidePendingExpCreateTable);
     CREATE_TABLE(chipRunCreateTable);
-    CREATE_TABLE(chipInputImfileCreateTable);
+//    CREATE_TABLE(chipInputImfileCreateTable);
     CREATE_TABLE(chipProcessedImfileCreateTable);
     CREATE_TABLE(chipMaskCreateTable);
@@ -144,5 +144,5 @@
     DROP_TABLE(guidePendingExpDropTable);
     DROP_TABLE(chipRunDropTable);
-    DROP_TABLE(chipInputImfileDropTable);
+//    DROP_TABLE(chipInputImfileDropTable);
     DROP_TABLE(chipProcessedImfileDropTable);
     DROP_TABLE(chipMaskDropTable);
