Skip to content

Instantly share code, notes, and snippets.

@machristie
Last active February 1, 2023 17:19
Show Gist options
  • Save machristie/0c7e28f11347d735f5517c3b5bf14d57 to your computer and use it in GitHub Desktop.
Save machristie/0c7e28f11347d735f5517c3b5bf14d57 to your computer and use it in GitHub Desktop.
erDiagram
    DATA_PRODUCT {
        int data_product_id PK
        int parent_id FK "optional parent data product"
        text name
        text description
        json metadata
        int owner_id FK
        string type "FILE | COLLECTION"
        int size
        string content_type
        timestamp data_created_date
        timestamp data_updated_date
        timestamp created_date
        timestamp updated_date
    }
    USER {
        int user_id PK
        string external_id "UK, this would be the Custos user id"
        int tenant_id FK
        etc etc "additional fields synced from Custos"
    }
    USER ||--o{ TENANT : "belongs to"
    TENANT {
        int tenant_id PK
        string external_id "UK, this would be the Custos tenant id"
        etc etc "additional fields synced from Custos"
    }
    DATA_PRODUCT }o--|| USER : "owned by"
    METADATA_SCHEMA {
        int metadata_schema_id PK
        string schema_name "unique for a given tenant_id"
        int owner_id FK
        int tenant_id FK
    }
    METADATA_SCHEMA }o--|| USER : "owned by"
    DATA_PRODUCT }o--o{ METADATA_SCHEMA : "supports (MANY-TO-MANY)"
    METADATA_SCHEMA_FIELD {
        int metadata_schema_field_id PK
        int metadata_schema_id FK
        string field_name
        jsonpath json_path
        string data_type "one of INTEGER, FLOAT, STRING, DATESTRING, ARRAY"
    }
    METADATA_SCHEMA ||--o{ METADATA_SCHEMA_FIELD : "has"
    SHARING {
        int sharing_id
        int data_product_id FK "NOT NULL"
        string group "one of COMMUNITY or PUBLIC"
        string permission "one of READ or WRITE"
    }
    DATA_PRODUCT ||--o{ SHARING : "has"

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment