     	   [:a2 :b2 :c2] (->ABC [:a2 :b2 :c2] [0 0 0] "b2-data" "c2-data")
     	   }
     	   (data joined-model)))
+    ;;;(is (= {:b1 b1 :b2 b2} (data a-b-joined-model)))
+    (is (= {:b2 b2} (data a-b-joined-model)))
+    (is (= {} (data a-b-unjoined-model)))
 
     ;; rhs update - relevant joins should update
     (on-upsert bs b1v1)

    (on-upsert bs b1)
    (is (= [[{}{}{}] [[{:b1 b1}{:b {:b1 b1}}][{}{}]] [{}{}{}]] (data join)))
    (is (= {} (data joined-model)))

    ;; rhs insertion - no join
    (on-upsert cs c1)
    (is (= [[{}{}{}] [[{:b1 b1}{:b {:b1 b1}}][{:c1 c1}{:c {:c1 c1}}]] [{}{}{}]] (data join)))
    (is (= {} (data joined-model)))

    ;; lhs-insertion - first join
    (on-upsert as a1)

       (permute [[]] [[:a1 :a2][:b1 :b2 :b3][:c1]]))))

;;--------------------------------------------------------------------------------
;; TODO: split the calculation of the joins and their transposition...

(defn- transpose [lhs join-fn permutations]
  (map (fn [permutation] (apply join-fn lhs permutation)) permutations))

(defn- lhs-join [rhs-indeces lhs-fk-keys lhs join-fn]
  "calculate the set of joins for a newly arriving lhs"
  (let [permutations (permute [[]] (rhses-get rhs-indeces lhs-fk-keys lhs))]
        (if (= [[]] permutations)
          nil
          (transpose lhs join-fn permutations))))

(defn- rhs-join [rhs-indeces lhs-fk-keys join-fn lhs-indeces i fk]
  "calculate the set of joins for a newly arriving rhs"
