   [head]
   (delete heads
           (where {:name (:name head)})))
+
+(defn create-mapping!
+  [head tentacle]
+  (let [head-name (:name head)
+        tentacle-name (:name tentacle)
+        existing-mapping (select head-tentacle-mappings
+                                 (where {:head_name head-name
+                                         :tentacle_name tentacle-name}))]
+    (if (empty? existing-mapping)
+      (insert head-tentacle-mappings
+              (values {:head-name head-name :tentacle-name tentacle-name})))))
+
+(defn get-all-mappings
+  []
+  (select head-tentacle-mappings))
+
+(defn get-mappings-for-head
+  [head]
+  (select head-tentacle-mappings
+          (where {:name (:name head)})))
+
+(defn get-mappings-for-tentacle
+  [tentacle]
+  (select head-tentacle-mappings
+          (where {:name (:name tentacle)})))


(defn get-tentacles-for-head
  [head]
  (select tentacles
          (where {:head-name (:name head)})))

(defn save-tentacle!
  [tentacle]

  (transform-keys ->snake_case_keyword fields))

(defdb main (postgres
             (select-keys (get-in (server-config) [:database :dev])
                          [:db :user :password :host :port])))

(declare head-tentacle-mappings)
