Skip to content

Latest commit

 

History

History
87 lines (69 loc) · 1.67 KB

README.adoc

File metadata and controls

87 lines (69 loc) · 1.67 KB

SAP CDS Entity Relationship Diagrams

The small AWK script generate mermaid Entity Relationship diagrams from SAP Cloud Application Programming Model files.

How to run script

gawk -f src/cds2erd.awk db/* > bookstore.mermaid

Alternatively, you can move the script to the bin directory and make it executable:

chmod +x cds2erd.awk

In this case you can call the script without specifying an interpreter:

cds2erd.awk schema.cds > schema.mermaid

Sample generated ER diagram

Below is the database schema from the project SAP Cloud CAP Samples Bookstore

erDiagram
    Books {
        String title
        String descr
        Integer stock
        Decimal price
        Currency currency
        Decimal rating
        TechnicalBooleanFlag isReviewable
    }

    Authors {
        String name
        Date dateOfBirth
        Date dateOfDeath
        String placeOfBirth
        String placeOfDeath
    }

    Genres {
        String name
        String descr
        Integer ID PK
    }

    Notes {
        String note
    }

    Orders {
        String OrderNo
        User buyer
        Decimal total
        Currency currency
    }

    OrderItems {
        Integer quantity
        Decimal amount
    }

    Reviews {
        Rating rating
        String title
        String text
    }

    Orders |o--o{ OrderItems : ""
    OrderItems |o--o| Books : ""
    Genres }o--o| Genres : ""
    Books |o--o{ Reviews : ""
    Books |o--o| Genres : ""
    Books }o--o| Authors : ""
Loading