-
Notifications
You must be signed in to change notification settings - Fork 40
Visualize schemas as entity-relationship diagrams #918
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
Conversation
715eb8e to
9a35f33
Compare
9a35f33 to
643cead
Compare
|
643cead to
767b4e6
Compare
adebea4 to
473ac84
Compare
473ac84 to
c4cf716
Compare
epatters
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Kaspar, this is great! A few small comments below.
Yeah, I dunno. "ER diagram" is the standard term, so I'm inclined to go with it despite the possibility of confusion. In a different direction, @tim-at-topos and I have discussed renaming the "diagrams" in CatColab to "diagrammatic instances," which is longer but less confusing and suggests the connection with instances in general. At the root of all this is the fact that diagram is a technical term in category theory that is inspired by, but also clashes with, the colloquial meaning of "diagram."
I think not. You can think of diagrams in CatColab as more like knowledge graphs, displaying particular entities and their relationships, rather than the general schema of database/knowledge graph as in an ER diagram. |
c4cf716 to
991dbb6
Compare
| `Unexpected morphism co-domain. Expecting 'Basic' got: ${mor.dom.tag}`, | ||
| ); | ||
| invariant(entities.includes(mor.dom.content), "Domain content not in entities"); | ||
| invariant(entities.includes(mor.cod.content), "Codomain content not in entities"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this code is using the elaborated model, but regardless of whether it validates, the model can be ill-typed if the user has made a mistake. Thus, the safe thing is to replace these invariants with conditionals of the form
if (!(...)) {
continue;
}Alternatively, you could only show the visualization when the model validates, in which case it would be correct to use invariants, but IMO it's better to make visualization analyses degrade gracefully in the face of user error when possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks. I briefly tried to create an invalid model but failed to do so, so I jumped to the conclusion that it wasn't possible. I've gone back to using an if block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Yeah, I actually thought this code would trigger errors and was surprised when it didn't during my testing. I think this has to do with recent changes to the elaborator for models of discrete theories (now using DoubleTT rather than the previous, more direct method) which is causing invalid arrows to be filtered out during elaboration when they weren't before. However, this behavior should be considered accidental and isn't guaranteed to persist. The general rule is that you can't assume a model to be valid/well-typed unless it passes validation.
991dbb6 to
a729911
Compare
Adds entity-relationship diagram analysis for simple schemas that uses Graphviz HTML-like tables and crows-foot edges.
https://branch-918-merge--catcolab.netlify.app/analysis/019b3206-c98c-7f40-a3df-027faf6ee5a6