mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
72.01k stars 6.53k forks source link

Star Schema #5722

Open mikeahmarani opened 2 months ago

mikeahmarani commented 2 months ago

Proposal

Mermaid.js should add star schema support.

Use Cases

A star schema is used to denormalize business data into dimensions (like time and product) and facts (like transactions in amounts and quantities).

Screenshots

image

Syntax

starSchema
    class FactTable {
        product_id: int
        time_id: int
        promotion_id: int
        customer_id: int
        revenue: BigDecimal
        units_sold: int
    }
    class ProductDim {
        product_id: int
        product_name: string
        unit_price: BigDecimal
        product_line: string
    }
    class CustomerDim {
        customer_id: int
        name: string
        city: string
        zip: string
    }
    class TimeDim {
        time_id: int
        order_date: date
        month: int
        quarter: int
        year: int
    }
    class PromotionDim{
        promotion_id: int
        promo_name: string
        ad_type: string
        coupon_type: string
        price_reduction_type: string
    }

    FactTable --> ProductDim
    FactTable --> CustomerDim
    FactTable --> TimeDim
    FactTable --> PromotionDim

    ---- Alternative, Simpler ----

starSchema
    FactTable [product_id, time_id, promotion_id, customer_id, revenue, units_sold] --> ProductDim [product_id, product_name, unit_price, product_line]
    FactTable --> TimeDim [time_id, order_date, month, quarter, year]
    FactTable --> CustomerDim [customer_id, name, city, zip]
    FactTable --> PromotionDim [promotion_id, promo_name, ad_type, coupon_type, reduction_type]

Implementation

This is a proposal which I'd love to see built into mermaid by the wonderful community.

tah96 commented 2 months ago

I second this! My team is running into an issue where Star schema would be very helpful