Skip to content

Conversation

@kasbah
Copy link
Member

@kasbah kasbah commented Dec 18, 2025

Adds entity-relationship diagram analysis for simple schemas that uses Graphviz HTML-like tables and crows-foot edges.

image

https://branch-918-merge--catcolab.netlify.app/analysis/019b3206-c98c-7f40-a3df-027faf6ee5a6

@github-actions github-actions bot temporarily deployed to netlify-preview December 18, 2025 16:50 Destroyed
@github-actions github-actions bot temporarily deployed to netlify-preview December 18, 2025 17:12 Destroyed
@kasbah
Copy link
Member Author

kasbah commented Dec 18, 2025

  • Possibly this should be called a "Entity relationship graph" to avoid confusion with diagrams as we currently have them?
  • Does it make sense to have this visualization as a diagramAnalysis? I am not familiar enough with diagrams to explore that.

@github-actions github-actions bot temporarily deployed to netlify-preview December 18, 2025 17:48 Destroyed
@kasbah kasbah requested a review from epatters December 18, 2025 17:55
@github-actions github-actions bot temporarily deployed to netlify-preview December 18, 2025 18:08 Destroyed
@github-actions github-actions bot temporarily deployed to netlify-preview December 18, 2025 18:10 Destroyed
@github-actions github-actions bot temporarily deployed to netlify-preview December 18, 2025 18:16 Destroyed
@epatters epatters added enhancement New feature or request visualization Visualization and plotting labels Dec 18, 2025
@epatters epatters changed the title Add entity-relationship diagrams for schemas Visualize schemas as entity-relationship diagrams Dec 18, 2025
Copy link
Member

@epatters epatters left a 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.

@epatters
Copy link
Member

epatters commented Dec 18, 2025

Possibly this should be called a "Entity relationship graph" to avoid confusion with diagrams as we currently have them?

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."

Does it make sense to have this visualization as a diagramAnalysis? I am not familiar enough with diagrams to explore that.

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.

@github-actions github-actions bot temporarily deployed to netlify-preview December 19, 2025 14:58 Destroyed
@kasbah kasbah requested a review from epatters December 19, 2025 15:02
`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");
Copy link
Member

@epatters epatters Dec 19, 2025

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.

Copy link
Member Author

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.

Copy link
Member

@epatters epatters Dec 19, 2025

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.

@epatters epatters merged commit 70277fb into main Dec 19, 2025
19 checks passed
@epatters epatters deleted the kb/schema-erd branch December 19, 2025 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request visualization Visualization and plotting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants