Index: trunk/dbconfig/det.md
===================================================================
--- trunk/dbconfig/det.md	(revision 14269)
+++ trunk/dbconfig/det.md	(revision 14270)
@@ -1,5 +1,5 @@
 detRun METADATA
     det_id      S64         0       # Primary Key AUTO_INCREMENT
-    iteration   S32         0       # Key
+    iteration   S32         0       # Key INDEX(det_id, iteration)
     det_type    STR         64      # Key
     mode        STR         64      # Key
@@ -208,2 +208,23 @@
     fault       S16         0       # Key NOT NULL
 END
+
+#
+# Note: This table needs to stay more or less identical to detNormalizedImfile.
+# It only exists as a seperate entity so they it can have different fkeys
+#
+detRegisteredImfile METADATA
+    det_id      S64         0       # Primary Key fkey(det_id, iteration) ref detRun(det_id, iteration)
+    iteration   S32         0       # Primary Key
+    class_id    STR         64      # Primary Key
+    uri         STR         255
+    bg          F64         0.0
+    bg_stdev    F64         0.0
+    bg_mean_stdev   F64     0.0
+    user_1      F64         0.0
+    user_2      F64         0.0
+    user_3      F64         0.0
+    user_4      F64         0.0
+    user_5      F64         0.0
+    path_base   STR         255
+    fault       S16         0       # Key NOT NULL
+END
Index: trunk/ippTools/src/dettool.c
===================================================================
--- trunk/ippTools/src/dettool.c	(revision 14269)
+++ trunk/ippTools/src/dettool.c	(revision 14270)
@@ -6974,9 +6974,5 @@
     }
 
-    // XXX this is going in without checking that the det_id is valid.
-    // it seems like it be better to be using foreign key constraints rather
-    // then having to resort to a seperate query (and locking) to check that
-    // the det_id is valid
-    if (!detNormalizedImfileInsert(config->dbh,
+    if (!detRegisteredImfileInsert(config->dbh,
                                    (psS64)atoll(det_id),
                                    0,  // the iteration is fixed at 0
Index: trunk/ippTools/src/pxtables.c
===================================================================
--- trunk/ippTools/src/pxtables.c	(revision 14269)
+++ trunk/ippTools/src/pxtables.c	(revision 14270)
@@ -79,4 +79,5 @@
     CREATE_TABLE(detResidExpCreateTable);
     CREATE_TABLE(detRunSummaryCreateTable);
+    CREATE_TABLE(detRegisteredImfileCreateTable);
     CREATE_TABLE(warpRunCreateTable);
     CREATE_TABLE(warpInputExpCreateTable);
@@ -159,4 +160,5 @@
     DROP_TABLE(detResidExpDropTable);
     DROP_TABLE(detRunSummaryDropTable);
+    DROP_TABLE(detRegisteredImfileDropTable);
     DROP_TABLE(warpRunDropTable);
     DROP_TABLE(warpInputExpDropTable);
