metosin / malli

High-performance data-driven data specification library for Clojure/Script.
Eclipse Public License 2.0
1.44k stars 205 forks source link

Cardinalities with dot & plantuml #469

Open ikitommi opened 3 years ago

ikitommi commented 3 years ago

Btw it would be also nice if the association lines had cardinalities (0..1 / 1 / 0..*) on the "arrow side". But it seems that md/-get-links only provides the from-to entity names (such as ["OrderLine" #{"Burger"}] ), not the cardinality. Or is there any easy way of finding out the cardinality of the relation between entities?

brdloush commented 3 years ago

1) Do you have any proposition regarding how to restructure the code? Currently the md/-get-links returns shape like this:

["OrderLine" #{"Burger"}]

... so perhaps it might be changed so that it becomes set of maps containing more details about each individual "to" side of that link? Something like:

["OrderLine" #{{:entity "Burger", :cardinality :one, :optional false}] 

2) what are the "rules" for deriving cardinality of those links? My very wild quess:

Unfortunately I don't know much malli yet, to the problem might be way more complex than I'm currently imagining.

3) I wonder if result like this one looks OK. (I added a few more relations to OrderLine just to see what happens if there's more links between two entities)

image

ikitommi commented 3 years ago

something like that. Collection schemas have :min and :max| props that can be used. Sequence (regex) schemas already have m/-regex-min-max method to figure out their limits.

Interested on doing a PR for this?