 (def probemap-sources-table
   ["CREATE TABLE IF NOT EXISTS `probemap_sources` (
    `probemaps_id` INT NOT NULL,
+   `sources_id` INT NOT NULL,
    FOREIGN KEY (probemaps_id) REFERENCES `probemaps` (`id`),
-   `sources_id` INT NOT NULL,
-   FOREIGN KEY (sources_id) REFERENCES `sources` (`id`))"
-   "CREATE INDEX IF NOT EXISTS probemap ON `probemap_sources` (`probemaps_id`)"
-   "CREATE INDEX IF NOT EXISTS source ON `probemap_sources` (`sources_id`)"])
+   FOREIGN KEY (sources_id) REFERENCES `sources` (`id`))"])
 
 (def ^:private probemaps-columns
   #{:name

  ["CREATE TABLE IF NOT EXISTS `probemap_probes` (
   `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
   `probemaps_id` INT NOT NULL,
   FOREIGN KEY (probemaps_id) REFERENCES `probemaps` (`id`) ON DELETE CASCADE,
   `probe` VARCHAR(1000) NOT NULL)"])

; XXX CASCADE might perform badly. Might need to do this incrementally in application code.
(def probemap-positions-table
  ["CREATE TABLE IF NOT EXISTS `probemap_positions` (
   `probemaps_id` INT NOT NULL,
   FOREIGN KEY (`probemaps_id`) REFERENCES `probemaps` (`id`) ON DELETE CASCADE,
   `probemap_probes_id` INT NOT NULL,
   FOREIGN KEY (`probemap_probes_id`) REFERENCES `probemap_probes` (`id`) ON DELETE CASCADE,
   `bin` INT,
   `chrom` VARCHAR(255) NOT NULL,
   `chromStart` INT NOT NULL,
   `chromEnd` INT NOT NULL,
   `strand` CHAR(1))"
   "CREATE INDEX IF NOT EXISTS chrom_bin ON probemap_positions
   (`probemaps_id`, `chrom`, `bin`)"])

(def probemap-genes-table
  ["CREATE TABLE IF NOT EXISTS `probemap_genes` (
   `probemaps_id` INT NOT NULL,
   FOREIGN KEY (`probemaps_id`) REFERENCES `probemaps` (`id`) ON DELETE CASCADE,
   `probemap_probes_id` INT NOT NULL,
   FOREIGN KEY (`probemap_probes_id`) REFERENCES `probemap_probes` (`id`) ON DELETE CASCADE,
   `gene` VARCHAR(255))"
   "CREATE INDEX IF NOT EXISTS gene ON probemap_genes
   (`probemaps_id`, `gene`)"])

;
; feature tables

   `security` varchar(255),
   `gain` double DEFAULT NULL,
   `text` varchar (65535),
   `dataSubType` varchar (255))"])

;
; experiments in making a macro for metadata tables
