Entity-relationship diagrams as a KG

Present

2-min readUpdated 6 days agomain

Copied Raw Markdown!
Copied copy path!

Here we draw an entity-relationship (ER) diagram with a KG pack. The pack uses crow's-foot notation. Every ER concept below maps to KG syntax that already exists, except the two edge-end attributes.

ER vocabularyURL copied

ER concept KG syntax Example in the pack
Entity (table) A parent node with kind=Entity customer
Attribute (column) A child node with kind=Column and type= customer-email
Primary key A child node with kind=PrimaryKey orders-id
Foreign key A child node with kind=ForeignKey orders-customer-id
Composite attribute Child nodes nested under the attribute none
Nullable attribute nullable=true category-parent-id
Derived attribute derived=true dashed=true orders-total
Multivalued attribute multivalued=true none
Weak entity kind=WeakEntity none
Associative entity kind=AssociativeEntity with two identifying edges order-item
Relationship An edge from the foreign-key column to the referenced key column r2
Cardinality and optionality source_end= and target_end= on the edge r4
Identifying relationship A solid edge r4
Non-identifying relationship dashed=true r2
Self-reference An edge between two columns of one table r8
Supertype and subtype Subtype edges meet at a node_look=point node, and that node has an edge with target_end=triangle to the supertype r11, r12, r13
Disjoint or complete subtypes disjoint= and complete= on the point node product-subtype
N-ary relationship An associative entity with one edge for each participant none

Edge-end markersURL copied

source_end and target_end set the mark at each end of any KG edge. These are the values:

Value Mark Meaning
one two bars exactly one
zero_one bar and circle zero or one
many crow's foot many
one_many crow's foot and bar one or more
zero_many crow's foot and circle zero or more
triangle hollow triangle generalization
arrow filled arrowhead the default target end
open open arrowhead the default target end for an async UML message
none no mark the default source end, and the default target end into a junction

A foreign-key edge reads from the many side to the one side. For example, r2 gives source_end=zero_many target_end=one: a customer places zero or more orders, and each order has exactly one customer.