{"id":95,"date":"2026-05-26T08:05:43","date_gmt":"2026-05-26T08:05:43","guid":{"rendered":"https:\/\/www.vpascode.com\/in\/docs\/uncategorized\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/"},"modified":"2026-07-29T08:33:22","modified_gmt":"2026-07-29T08:33:22","slug":"mermaid-js-erd-syntax-guide","status":"publish","type":"ld_docs","link":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/","title":{"rendered":"Mermaid.js ERD Syntax Guide"},"content":{"rendered":"<h2>What is an Entity Relationship Diagram (ERD)?<\/h2>\n<p>An <strong>Entity Relationship Diagram (ERD)<\/strong> is a structural blueprint used to design, document, and analyze relational database schemas. It outlines the specific data tables (entities) within an application, the columns (attributes) nested inside those tables, and the referential integrity rules that bind them together. Written using standard <strong>Information Engineering (IE) notation<\/strong>, it implements clear <strong>crow&#8217;s foot notation<\/strong> heads to show data constraints and multi-table dependencies.<\/p>\n<p>With <strong>Mermaid.js<\/strong>, you can define your production table indexes, data types, and foreign key connections using a clean, declarative text block. The engine automatically handles sizing for multi-column layout containers and routes connection lines without letting text labels overlap.<\/p>\n<h2>Core Syntax Guide: Elements and Constructs<\/h2>\n<p>Building a valid, fully runnable database schema in Mermaid relies on structural entity blocks, data type mappings, index tags, and cardinality operators.<\/p>\n<h3>1. Declaring Entities and Table Columns<\/h3>\n<p>You initialize an ERD canvas on line one using the <code>erDiagram<\/code> keyword. To define a table, write the entity name followed by an open curly brace, listing your column configurations sequentially on individual lines:<\/p>\n            <div class=\"vpascode-viewer-container vpascode-fancy-active\">\r\n                                <div class=\"vpascode-header\">\r\n                    <span class=\"vpascode-lang-label\">Mermaid<\/span>\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNpLLXLJTEwvSszl5VIAgtBg16BghWoIBwQy80oUMlMQ\/OKSosy8dIXU3MTMHIRoSWZuanFJYm6BQnJRamJJakp8YglEthYAu7UZoQ==\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 8px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n                                <div class=\"vpascode-code-wrapper\">\r\n                    <pre class=\"lang-mermaid\"><code data-language=\"mermaid\" class=\"language-mermaid\">erDiagram\r\n    USERS {\r\n        int id\r\n        string email\r\n        timestamp created_at\r\n    }<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNpLLXLJTEwvSszl5VIAgtBg16BghWoIBwQy80oUMlMQ\/OKSosy8dIXU3MTMHIRoSWZuanFJYm6BQnJRamJJakp8YglEthYAu7UZoQ==\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 6px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n            <\/div>\r\n            \n<p id=\"VkXootV\"><img decoding=\"async\" width=\"221\" height=\"187\" class=\"alignnone size-full wp-image-629 \" src=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903a383fb3.png\" alt=\"\" \/><\/p>\n<h3>2. Marking Primary Keys, Foreign Keys, and Comments<\/h3>\n<p>Mermaid&#8217;s ERD engine allows you to assign structural indexing tags directly after the column name and data type definition. You can also append an optional text comment to a column by wrapping it in double quotes:<\/p>\n<ul>\n<li><code>PK<\/code> \u2014 Explicitly flags a column as the table&#8217;s Primary Key.<\/li>\n<li><code>FK<\/code> \u2014 Flags a column as a Foreign Key linked to a parent table.<\/li>\n<\/ul>\n            <div class=\"vpascode-viewer-container vpascode-fancy-active\">\r\n                                <div class=\"vpascode-header\">\r\n                    <span class=\"vpascode-lang-label\">Mermaid<\/span>\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNpLLXLJTEwvSszl5VIAAv8gF9egYIVqCA8EMvNKFDJTFAK8UYVKi1OL4oHibt4KSj6ZednFCiX5CqHBQM16mSlKCLXFJUWZeekKyfmlBfl58cn5KakQuVoAct0gOw==\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 8px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n                                <div class=\"vpascode-code-wrapper\">\r\n                    <pre class=\"lang-mermaid\"><code data-language=\"mermaid\" class=\"language-mermaid\">erDiagram\r\n    ORDERS {\r\n        int id PK\r\n        int user_id FK \"Links to USERS.id\"\r\n        string coupon_code\r\n    }<\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNpLLXLJTEwvSszl5VIAAv8gF9egYIVqCA8EMvNKFDJTFAK8UYVKi1OL4oHibt4KSj6ZednFCiX5CqHBQM16mSlKCLXFJUWZeekKyfmlBfl58cn5KakQuVoAct0gOw==\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 6px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n            <\/div>\r\n            \n<p id=\"aCCwRBw\"><img fetchpriority=\"high\" decoding=\"async\" width=\"268\" height=\"817\" class=\"alignnone size-full wp-image-632 \" src=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903b8be451.png\" alt=\"\" srcset=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903b8be451.png 268w, https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903b8be451-98x300.png 98w\" sizes=\"(max-width: 268px) 100vw, 268px\" \/><\/p>\n<h3>3. Mastering Crow&#8217;s Foot Cardinality Modifiers<\/h3>\n<p>To connect tables and enforce referential integrity rules, map their relationships using specialized line operators. The character heads form visual crow&#8217;s foot shapes that dictate data multiplicity constraints:<\/p>\n<ul>\n<li><code>||--||<\/code> **Exactly One to Exactly One:** A strict, mandatory 1:1 mapping.<\/li>\n<li><code>||--o|<\/code> **Exactly One to Zero or One:** An optional 1:1 dependency.<\/li>\n<li><code>||--|{<\/code> **Exactly One to One or Many:** A mandatory 1:N parental linkage.<\/li>\n<li><code>||--o{<\/code> **Exactly One to Zero, One, or Many:** A standard, optional 1:N relationship.<\/li>\n<\/ul>\n            <div class=\"vpascode-viewer-container vpascode-fancy-active\">\r\n                                <div class=\"vpascode-header\">\r\n                    <span class=\"vpascode-lang-label\">Mermaid<\/span>\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNpLLXLJTEwvSszl5VIAgtBg16BghZoaXd38agX\/IBcQz0pBqSAnMTm1WAkAMZMNNw==\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 8px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n                                <div class=\"vpascode-code-wrapper\">\r\n                    <pre class=\"lang-mermaid\"><code data-language=\"mermaid\" class=\"language-mermaid\">erDiagram\r\n    USERS ||--o{ ORDERS : \"places\" <\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNpLLXLJTEwvSszl5VIAgtBg16BghZoaXd38agX\/IBcQz0pBqSAnMTm1WAkAMZMNNw==\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 6px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n            <\/div>\r\n            \n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-631\" src=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903aca991c.png\" alt=\"\" width=\"116\" height=\"285\" \/><\/p>\n<h2>Best Practices for Relational Data Schemas<\/h2>\n<ul>\n<li><strong>Maintain Consistent Table Casing:<\/strong> Keep entity names predictable. Use uppercase strings (e.g., <code>USER_ACCOUNTS<\/code>) or strict lowercase snake_case (e.g., <code>user_accounts<\/code>) to match your real-world SQL infrastructure code.<\/li>\n<li><strong>Always Include Data Types:<\/strong> Avoid declaring raw column text without types. Explicitly listing definitions like <code>int<\/code>, <code>varchar<\/code>, or <code>boolean<\/code> ensures your architecture charts serve as an accurate technical reference.<\/li>\n<li><strong>Keep Relationship Labels Verbs:<\/strong> When linking elements, provide a brief, lowercase active verb string inside your relationship assignment (e.g., <code>||--o{ : \"contains\"<\/code>) to document the business logic mapping.<\/li>\n<\/ul>\n<h2>Real-World Mermaid.js ERD Examples<\/h2>\n<h3>Example 1: Core E-Commerce Transactional Model (Keys &amp; Mappings)<\/h3>\n<p>This functional blueprint models a core e-commerce database transaction loop, showing how users, orders, and payment tracking systems link together using strict crow&#8217;s foot constraints.<\/p>\n            <div class=\"vpascode-viewer-container vpascode-fancy-active\">\r\n                                <div class=\"vpascode-header\">\r\n                    <span class=\"vpascode-lang-label\">Mermaid<\/span>\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNqNkM0KwjAQhO+C7xB69wW8iVURfyptPYelXWuwSSS7RcT67qZU8aeC7inMJJlvB12ooHCg+z3hZ7xN0mg1iRNxaYVmlGGhcrFZPCVip0whUIMqO+oRiE7W5XIPtG\/da7\/XHqI4\/P17I2UVsdXopPemL16OmdJQCrYMpQRtK8MdAmLgij6i03i0TkbjdB6t5XISzv7j8Ht0Ie4xDnfo0GQo2R7QdPwCGE9w\/uB4dlzXg4G9PDoZiuBYQoYUvFXVXKrrr\/T+RYEGnY+h4Aa9SHin\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 8px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n                                <div class=\"vpascode-code-wrapper\">\r\n                    <pre class=\"lang-mermaid\"><code data-language=\"mermaid\" class=\"language-mermaid\">erDiagram\r\n    CUSTOMERS {\r\n        int id PK\r\n        string email\r\n        string password_hash\r\n    }\r\n\r\n    ORDERS {\r\n        int id PK\r\n        int customer_id FK\r\n        decimal total_amount\r\n        string status\r\n    }\r\n\r\n    TRANSACTION_LEDGERS {\r\n        int id PK\r\n        int order_id FK\r\n        string reference_token\r\n        string gateway\r\n    }\r\n\r\n    CUSTOMERS ||--o{ ORDERS : \"places\"\r\n    ORDERS ||--|| TRANSACTION_LEDGERS : \"generates\" <\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNqNkM0KwjAQhO+C7xB69wW8iVURfyptPYelXWuwSSS7RcT67qZU8aeC7inMJJlvB12ooHCg+z3hZ7xN0mg1iRNxaYVmlGGhcrFZPCVip0whUIMqO+oRiE7W5XIPtG\/da7\/XHqI4\/P17I2UVsdXopPemL16OmdJQCrYMpQRtK8MdAmLgij6i03i0TkbjdB6t5XISzv7j8Ht0Ie4xDnfo0GQo2R7QdPwCGE9w\/uB4dlzXg4G9PDoZiuBYQoYUvFXVXKrrr\/T+RYEGnY+h4Aa9SHin\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 6px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n            <\/div>\r\n            \n<p id=\"qqEcCcA\"><img fetchpriority=\"high\" decoding=\"async\" width=\"268\" height=\"817\" class=\"alignnone size-full wp-image-632 \" src=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903b8be451.png\" alt=\"\" srcset=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903b8be451.png 268w, https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903b8be451-98x300.png 98w\" sizes=\"(max-width: 268px) 100vw, 268px\" \/><\/p>\n<p><strong>Syntax Breakdown:<\/strong> This schema maps transaction boundaries cleanly. The mapping rules dictate that a customer can place zero or many orders over time (<code>||--o{<\/code>), while an individual order record must generate exactly one matching transaction ledger entry (<code>||--||<\/code>).<\/p>\n<h3>Example 2: Enterprise Content Management System Schema (Many-to-Many Intersection)<\/h3>\n<p>This advanced database blueprint maps out a content management platform architecture. It details how to resolve complex many-to-many configurations by introducing an explicit bridge mapping entity.<\/p>\n            <div class=\"vpascode-viewer-container vpascode-fancy-active\">\r\n                                <div class=\"vpascode-header\">\r\n                    <span class=\"vpascode-lang-label\">Mermaid<\/span>\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNqNkU1uwjAQhfdI3GHEulygO9QGhFBIRNh0ZU0d14wU25E9SCDo3RuTtjQ1FZ2VPT9+\/t4o\/0yoPZrxCLooi2pbwam\/xCDLQDWUq2sqsCergYkblWRDs9fXJKsDw6urj0I6y8pyX3ofj\/rD02ybLYrNMvunpkWTStYqSE8tk7O\/no804lPjReSzslyuF4lU6wKLi94DzFfDmkRW2vnjrTqTUYHRtIAhkLaqFpgAFnmere9a+vMb8xQb97xzXgzpL95KZ0xnq4ge34Cv4HyeTt3pLyceYRIXg2TDJNnI\/dEmgr+R+hoeSH6jd53IjHLX9X0AN3qkJw==\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 8px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n                                <div class=\"vpascode-code-wrapper\">\r\n                    <pre class=\"lang-mermaid\"><code data-language=\"mermaid\" class=\"language-mermaid\">erDiagram\r\n    POSTS {\r\n        int id PK\r\n        string title\r\n        string slug\r\n        text body_content\r\n    }\r\n\r\n    CATEGORIES {\r\n        int id PK\r\n        string name\r\n        string description\r\n    }\r\n\r\n    POST_CATEGORY_MAPPINGS {\r\n        int post_id PK, FK\r\n        int category_id PK, FK\r\n        timestamp assigned_at\r\n    }\r\n\r\n    COMMENTS {\r\n        int id PK\r\n        int post_id FK\r\n        string author_name\r\n        text comment_body\r\n    }\r\n\r\n    POSTS ||--o{ POST_CATEGORY_MAPPINGS : \"contains\"\r\n    CATEGORIES ||--o{ POST_CATEGORY_MAPPINGS : \"classifies\"\r\n    POSTS ||--o{ COMMENTS : \"attaches\" <\/code><\/pre>                <\/div>\r\n                <div class=\"vpascode-actions\">\r\n                    <a href=\"https:\/\/www.vpascode.com\/#mermaid:eNqNkU1uwjAQhfdI3GHEulygO9QGhFBIRNh0ZU0d14wU25E9SCDo3RuTtjQ1FZ2VPT9+\/t4o\/0yoPZrxCLooi2pbwam\/xCDLQDWUq2sqsCergYkblWRDs9fXJKsDw6urj0I6y8pyX3ofj\/rD02ybLYrNMvunpkWTStYqSE8tk7O\/no804lPjReSzslyuF4lU6wKLi94DzFfDmkRW2vnjrTqTUYHRtIAhkLaqFpgAFnmere9a+vMb8xQb97xzXgzpL95KZ0xnq4ge34Cv4HyeTt3pLyceYRIXg2TDJNnI\/dEmgr+R+hoeSH6jd53IjHLX9X0AN3qkJw==\" \r\n                       target=\"_blank\" \r\n                       rel=\"noopener noreferrer\" \r\n                       class=\"vpascode-fancy-btn\">\r\n                        <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\" style=\"margin-right: 6px;\"><path d=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\"><\/path><path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\"><\/path><\/svg>\r\n                        <span>Edit Mermaid in VPasCode<\/span>\r\n                    <\/a>\r\n                <\/div>\r\n            <\/div>\r\n            \n<p id=\"NkBriQB\"><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"545\" class=\"alignnone size-full wp-image-633 \" src=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903d115d5e.png\" alt=\"\" srcset=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903d115d5e.png 709w, https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903d115d5e-300x231.png 300w\" sizes=\"(max-width: 709px) 100vw, 709px\" \/><\/p>\n<p><strong>Syntax Breakdown:<\/strong> To handle the many-to-many relationship between `POSTS` and `CATEGORIES`, the script introduces an intersection table (`POST_CATEGORY_MAPPINGS`). This mapping box uses composite keys acting simultaneously as primary and foreign keys (<code>PK FK<\/code>), linking the outer nodes together using standard one-to-many crow&#8217;s foot connections.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is an Entity Relationship Diagram (ERD)? An Entity Relationship Diagram (ERD) is a structural blueprint used to design, document, and analyze relational database schemas. It outlines the specific data tables (entities) within an application, the columns (attributes) nested inside&#8230;<\/p>\n","protected":false},"author":4,"featured_media":633,"parent":48,"menu_order":4,"template":"","meta":{"inline_featured_image":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}}},"ld_collection":[14],"class_list":["post-95","ld_docs","type-ld_docs","status-publish","has-post-thumbnail","hentry","ld_collection-vpascode-docs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Mermaid ERD Diagram Syntax | VPasCode Text to Diagram Guide<\/title>\n<meta name=\"description\" content=\"Draft database schemas effortlessly using Mermaid entity relationship diagrams in VPasCode, your text to diagram tool.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/\" \/>\n<meta property=\"og:locale\" content=\"hi_IN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mermaid ERD Diagram Syntax | VPasCode Text to Diagram Guide\" \/>\n<meta property=\"og:description\" content=\"Draft database schemas effortlessly using Mermaid entity relationship diagrams in VPasCode, your text to diagram tool.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/\" \/>\n<meta property=\"og:site_name\" content=\"VPasCode\" \/>\n<meta property=\"article:modified_time\" content=\"2026-07-29T08:33:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903d115d5e.png\" \/>\n\t<meta property=\"og:image:width\" content=\"709\" \/>\n\t<meta property=\"og:image:height\" content=\"545\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u0905\u0928\u0941\u092e\u093e\u0928\u093f\u0924 \u092a\u0922\u093c\u0928\u0947 \u0915\u093e \u0938\u092e\u092f\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 \u092e\u093f\u0928\u091f\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-erd-syntax-guide\\\/\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-erd-syntax-guide\\\/\",\"name\":\"Mermaid ERD Diagram Syntax | VPasCode Text to Diagram Guide\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-erd-syntax-guide\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-erd-syntax-guide\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/wp-content\\\/uploads\\\/sites\\\/13\\\/2026\\\/05\\\/img_6a1903d115d5e.png\",\"datePublished\":\"2026-05-26T08:05:43+00:00\",\"dateModified\":\"2026-07-29T08:33:22+00:00\",\"description\":\"Draft database schemas effortlessly using Mermaid entity relationship diagrams in VPasCode, your text to diagram tool.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-erd-syntax-guide\\\/#breadcrumb\"},\"inLanguage\":\"hi-IN\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-erd-syntax-guide\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"hi-IN\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-erd-syntax-guide\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/wp-content\\\/uploads\\\/sites\\\/13\\\/2026\\\/05\\\/img_6a1903d115d5e.png\",\"contentUrl\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/wp-content\\\/uploads\\\/sites\\\/13\\\/2026\\\/05\\\/img_6a1903d115d5e.png\",\"width\":709,\"height\":545,\"caption\":\"Mermaid entity relationship diagram generated using VPasCode diagram-as-code tool\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/mermaid-js-erd-syntax-guide\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Lean Docs\",\"item\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/%ld_collection%\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Mermaid.js Playbook\",\"item\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/docs\\\/vpascode-docs\\\/mermaid-js-playbook\\\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Mermaid.js ERD Syntax Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/#website\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/\",\"name\":\"VPasCode\",\"description\":\"by Visual Paradigm\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"hi-IN\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/#organization\",\"name\":\"VPasCode\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"hi-IN\",\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/wp-content\\\/uploads\\\/sites\\\/13\\\/2026\\\/06\\\/cropped-vp-online-logo-v1.png\",\"contentUrl\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/wp-content\\\/uploads\\\/sites\\\/13\\\/2026\\\/06\\\/cropped-vp-online-logo-v1.png\",\"width\":128,\"height\":138,\"caption\":\"VPasCode\"},\"image\":{\"@id\":\"https:\\\/\\\/www.vpascode.com\\\/in\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mermaid ERD Diagram Syntax | VPasCode Text to Diagram Guide","description":"Draft database schemas effortlessly using Mermaid entity relationship diagrams in VPasCode, your text to diagram tool.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/","og_locale":"hi_IN","og_type":"article","og_title":"Mermaid ERD Diagram Syntax | VPasCode Text to Diagram Guide","og_description":"Draft database schemas effortlessly using Mermaid entity relationship diagrams in VPasCode, your text to diagram tool.","og_url":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/","og_site_name":"VPasCode","article_modified_time":"2026-07-29T08:33:22+00:00","og_image":[{"width":709,"height":545,"url":"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903d115d5e.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"\u0905\u0928\u0941\u092e\u093e\u0928\u093f\u0924 \u092a\u0922\u093c\u0928\u0947 \u0915\u093e \u0938\u092e\u092f":"4 \u092e\u093f\u0928\u091f"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/","url":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/","name":"Mermaid ERD Diagram Syntax | VPasCode Text to Diagram Guide","isPartOf":{"@id":"https:\/\/www.vpascode.com\/in\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/#primaryimage"},"image":{"@id":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/#primaryimage"},"thumbnailUrl":"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903d115d5e.png","datePublished":"2026-05-26T08:05:43+00:00","dateModified":"2026-07-29T08:33:22+00:00","description":"Draft database schemas effortlessly using Mermaid entity relationship diagrams in VPasCode, your text to diagram tool.","breadcrumb":{"@id":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/#breadcrumb"},"inLanguage":"hi-IN","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/"]}]},{"@type":"ImageObject","inLanguage":"hi-IN","@id":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/#primaryimage","url":"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903d115d5e.png","contentUrl":"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/05\/img_6a1903d115d5e.png","width":709,"height":545,"caption":"Mermaid entity relationship diagram generated using VPasCode diagram-as-code tool"},{"@type":"BreadcrumbList","@id":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/mermaid-js-erd-syntax-guide\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vpascode.com\/in\/"},{"@type":"ListItem","position":2,"name":"Lean Docs","item":"https:\/\/www.vpascode.com\/in\/docs\/%ld_collection%\/"},{"@type":"ListItem","position":3,"name":"Mermaid.js Playbook","item":"https:\/\/www.vpascode.com\/in\/docs\/vpascode-docs\/mermaid-js-playbook\/"},{"@type":"ListItem","position":4,"name":"Mermaid.js ERD Syntax Guide"}]},{"@type":"WebSite","@id":"https:\/\/www.vpascode.com\/in\/#website","url":"https:\/\/www.vpascode.com\/in\/","name":"VPasCode","description":"by Visual Paradigm","publisher":{"@id":"https:\/\/www.vpascode.com\/in\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vpascode.com\/in\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"hi-IN"},{"@type":"Organization","@id":"https:\/\/www.vpascode.com\/in\/#organization","name":"VPasCode","url":"https:\/\/www.vpascode.com\/in\/","logo":{"@type":"ImageObject","inLanguage":"hi-IN","@id":"https:\/\/www.vpascode.com\/in\/#\/schema\/logo\/image\/","url":"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/06\/cropped-vp-online-logo-v1.png","contentUrl":"https:\/\/www.vpascode.com\/in\/wp-content\/uploads\/sites\/13\/2026\/06\/cropped-vp-online-logo-v1.png","width":128,"height":138,"caption":"VPasCode"},"image":{"@id":"https:\/\/www.vpascode.com\/in\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/ld_docs\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/ld_docs"}],"about":[{"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/types\/ld_docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/users\/4"}],"up":[{"embeddable":true,"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/ld_docs\/48"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/media\/633"}],"wp:attachment":[{"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"ld_collection","embeddable":true,"href":"https:\/\/www.vpascode.com\/in\/wp-json\/wp\/v2\/ld_collection?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}