Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show cardinality for relations #6

Open
Reefersleep opened this issue Mar 25, 2016 · 2 comments
Open

Show cardinality for relations #6

Reefersleep opened this issue Mar 25, 2016 · 2 comments

Comments

@Reefersleep
Copy link

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
@ikitommi
Copy link
Member

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

@Reefersleep
Copy link
Author

Indeed, I missed that one :) 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants