Skip to content

Mermaid JS ER Diagrams

jsipahio edited this page Nov 16, 2023 · 2 revisions
  1. create a basic html file for your diagram with the following markup, or simply copy the example.html file
<!DOCTYPE html>
<html>
    <head>
        <title>Example ER Diagram</title>
        <script type="module">
            import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
          </script>
    </head>
    <body>
        <pre class="mermaid">
            erDiagram
        </pre>
    </body>
</html>
  1. underneath erDiagram, you can create the entity sets and relationships
  2. the pattern for an entity set is (data types are not needed at this stage):
course{
    id
    title
    credit_hours
}
  1. create entity relations with the following connectors
    image so course ||--o{ instructor is a 0 to many relation in both directions between instructor and course, as an instructor may be teaching 0 to many courses, and a course (in this example) has only one instructor.

Clone this wiki locally