# enochemerald/hospital-database-system_data-control-language architecture

> Architecture diagram of the GitHub repository enochemerald/hospital-database-system_data-control-language, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/enochemerald/hospital-database-system_data-control-language
- Repository: https://github.com/enochemerald/hospital-database-system_data-control-language

## Overview

##### Project type and purpose
- This is a **database-centric security project** that implements Data Control Language (DCL) for a hospital management system.
- Its primary goal is to define user roles, assign table-level privileges, and enforce a Role-Based Access Control (RBAC) strategy for sensitive medical data.

##### File structure
- Top level:
- `Advanced - Data Control Language.sql` – the single SQL script that creates roles, users, and grants/revokes permissions.
- `README.md` – describes the DCL design, user roles, privileges, and security principles.
- No frontend or backend code; all logic lives in the database layer.

##### README for additional insights
- Four core user roles (Admin, Physician, Nurse, Pharmacist), each mapped to a dedicated database user account.
- Privilege matrix at table level to enforce the **principle of least privilege**.
- Emphasis on **RBAC**, **user isolation**, and **granular permissions**.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    AdminClient["Admin Console"]:::client
    PhysicianClient["Physician Console"]:::client
    NurseClient["Nurse Console"]:::client
    PharmacistClient["Pharmacist Console"]:::client

    %% Database Server Boundary
    subgraph "Database Server" 
        direction TB
        DCL["DCL Script"]:::script
        subgraph "Roles" 
            direction TB
            AdminR["Admin Role\n(admin@localhost)"]:::role
            DoctorR["Physician Role\n(doctor@localhost)"]:::role
            NurseR["Nurse Role\n(nurse@localhost)"]:::role
            PharmacistR["Pharmacist Role\n(pharmacist@localhost)"]:::role
        end
        subgraph "Clinical Data" 
            direction TB
            PatientTable["patient Table"]:::table
            PrescribesTable["prescribes Table"]:::table
        end
    end

    %% Documentation
    README["Project Documentation\nREADME.md"]:::doc

    %% Connections: Clients to Database Server
    AdminClient -->|"connects with credentials"| DCL
    PhysicianClient -->|"connects with credentials"| DCL
    NurseClient -->|"connects with credentials"| DCL
    PharmacistClient -->|"connects with credentials"| DCL

    %% DCL script provisions roles and tables
    DCL -->|"creates roles and tables"| AdminR
    DCL --> AdminR
    DCL --> DoctorR
    DCL --> NurseR
    DCL --> PharmacistR
    DCL --> PatientTable
    DCL --> PrescribesTable

    %% Grants from roles to tables
    AdminR -->|"GRANT ALL"| PatientTable
    AdminR -->|"GRANT ALL"| PrescribesTable
    DoctorR -->|"GRANT SELECT,INSERT,UPDATE"| PatientTable
    DoctorR -->|"GRANT SELECT,INSERT"| PrescribesTable
    NurseR -->|"GRANT SELECT,UPDATE"| PatientTable
    PharmacistR -->|"GRANT SELECT,UPDATE"| PrescribesTable

    %% Documentation link
    README -.-> DCL

    %% Click Events
    click DCL "https://github.com/enochemerald/hospital-database-system_data-control-language/blob/main/Advanced - Data Control Language.sql"
    click README "https://github.com/enochemerald/hospital-database-system_data-control-language/blob/main/README.md"

    %% Styles
    classDef client fill:#AED6F1,stroke:#21618C,color:#1B4F72
    classDef db fill:#D5D8DC,stroke:#566573,color:#2C3E50
    classDef role fill:#A9DFBF,stroke:#239B56,color:#145A32
    classDef table fill:#F5CBA7,stroke:#CD6155,color:#78281F
    classDef script fill:#F9E79F,stroke:#B7950B,color:#7D6608
    classDef doc fill:#FCF3CF,stroke:#B9770E,color:#7E5109
```
