Erd

Crow's-foot notation: the head at each end states that end's cardinality, so "a customer places many orders, each order belongs to one customer" is drawn rather than written. arrow="both" gives both ends a head; head is the to end and tail the from end. from-label and to-label write the cardinality AT the end it describes, which one mid-edge label cannot do.

Diagrams 549 × 364 <column><connect><entity><import><row><text>

Result

Source examples/erd.svgn

<diagram padding="30">
  <import name="er"/>

  <!-- Crow's-foot notation: the head at each end states that end's cardinality,
       so "a customer places many orders, each order belongs to one customer" is
       drawn rather than written. `arrow="both"` gives both ends a head; `head`
       is the `to` end and `tail` the `from` end.

       `from-label` and `to-label` write the cardinality AT the end it
       describes, which one mid-edge label cannot do. -->
  <row gap="120" align="center">
    <entity id="customer" title="CUSTOMER">
      <text class="key">id  PK</text>
      <text class="field">name</text>
      <text class="field">email</text>
    </entity>
    <column gap="86" align="center">
      <entity id="order" title="ORDER">
        <text class="key">id  PK</text>
        <text class="field">placed_at</text>
      </entity>
      <entity id="item" title="LINE_ITEM">
        <text class="key">id  PK</text>
        <text class="field">qty</text>
      </entity>
    </column>
    <entity id="product" title="PRODUCT">
      <text class="key">sku  PK</text>
      <text class="field">title</text>
    </entity>
  </row>

  <!-- one customer, many orders -->
  <connect from="customer" to="order" arrow="both" head="crow" tail="bar"
           label="places" from-label="1" to-label="0..*"/>
  <!-- one order, many line items -->
  <connect from="order" to="item" arrow="both" head="crow" tail="bar"
           label="contains" from-label="1" to-label="1..*"/>
  <!-- each line item names exactly one product -->
  <connect from="item" to="product" arrow="both" head="bar" tail="crow"
           label="is a" from-label="0..*" to-label="1"/>
</diagram>

Open the SVG →