    source-entity :- Entity
    target-entity :- Entity
    source-record :- t/RecordSchema
+   denorm-rel-kw :- s/Keyword
    denorm-rel :- t/DenormalizationRelationshipSchema
    denorm-op :- DenormalizeOp]
   (with-context deferred-context

                             (st/map #(denormalize-to-target-record
                                       session
                                       source-entity
                                       (-> % :target deref-target-entity)
                                       source-record
                                       denorm-rel
                                       %

(s/defschema DenormalizeOp
  (s/enum :upsert :delete))

(defn- deref-target-entity
  "given a namespace qualififed symbol or keyword referring to a
   var with an Entity, return the Entity... otherwise return whatever
   is given"
  [entity-var-ref]
  (if (or (keyword? entity-var-ref)
          (symbol? entity-var-ref))
    (deref
     (ns-resolve (namespace entity-var-ref) (name entity-var-ref)))

    entity-var-ref))

(s/defn foreign-key-val
  "returns [fk fk-val] for the denorm relationship"
