schema-viz icon indicating copy to clipboard operation
schema-viz copied to clipboard

Show cardinality for relations

Open Reefersleep opened this issue 9 years ago • 2 comments

Currently, all relations are showed in the same way - a line going from the containing element to the contained element, with a black diamond on the contained end. For example, the relations in these three examples look identical, even though there is a difference in the cardinality:

;;Example 1: Zero to many
(s/defschema State
  {:name s/Str})

(s/defschema Country
  {:name s/Str
   :states [State]})
;;Example 2: Exactly one
(s/defschema State
  {:name s/Str})

(s/defschema Citizen
  {:first-name s/Str
   :last-name s/Str
   :home-state State})
;;Example 3: Optional
(s/defschema State
  {:name s/Str})

(s/defschema Burger
  {:name s/Str
   (s/optional-key :origin-state) State})

The difference between these relations could be shown as:

  • Example 1: A * on the end of the line going to the contained element
  • Example 2: A 1 on the end of the line going to the contained element
  • Example 2: A 0..1 on the end of the line going to the contained element

Reefersleep avatar Mar 25 '16 13:03 Reefersleep

Thanks for the report! Also, sequential schemas could have lower bound, e.g. [(s/one s/Str "s") s/Str] => 1..*

ikitommi avatar Mar 29 '16 12:03 ikitommi

Indeed, I missed that one :) :+1:

Reefersleep avatar Mar 29 '16 16:03 Reefersleep