Next: , Previous: , Up: STARTER   [Contents]


Appendix A Database Schema & Initialization

As we explored in the previous chapters, STARTER is a data-driven ecosystem. For the Core to manage persistence, track event history, and monitor system performance, it requires a solid and correctly configured storage infrastructure.

This appendix provides the SQL queries necessary to initialize the MariaDB/MySQL database, which should be named STARTER. The schema is built around three foundational tables:

labels

Maps I/O identifiers to human-readable descriptions and metadata.

history

The primary ledger where every single event and state change is recorded for long-term analysis.

stats

Dedicated to gathering diagnostic data and runtime statistics from your various services.

CREATE DATABASE STARTER;

USE STARTER;

CREATE TABLE labels (
    id INT NOT NULL AUTO_INCREMENT,
    name VARCHAR(100) NOT NULL UNIQUE,
    description TEXT NOT NULL,
    type VARCHAR(50) NOT NULL,
    unit INT NOT NULL,
    min DOUBLE NOT NULL,
    max DOUBLE NOT NULL,
    step DOUBLE NOT NULL,
    PRIMARY KEY (id),
    INDEX idx_labels_type (type)
);

CREATE TABLE history (
    id BIGINT NOT NULL AUTO_INCREMENT,
    timestamp DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    source VARCHAR(100) NOT NULL,
    label_id INT NOT NULL,
    value DOUBLE NOT NULL,
    flags BIGINT UNSIGNED NOT NULL, 
    PRIMARY KEY (id),
    FOREIGN KEY (label_id) REFERENCES labels(id),
    INDEX idx_label_time (label_id, timestamp),
    INDEX idx_history_source (source)
);

CREATE TABLE stats (
    id                INTEGER PRIMARY KEY AUTO_INCREMENT,
    service_name      VARCHAR(100) NOT NULL UNIQUE,
    updated_at        TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,

    vmsize_min        REAL NOT NULL,
    vmsize_max        REAL NOT NULL,
    vmsize_last       REAL NOT NULL,

    vmrss_min         REAL NOT NULL,
    vmrss_max         REAL NOT NULL,
    vmrss_last        REAL NOT NULL,

    vmswap_min        REAL NOT NULL,
    vmswap_max        REAL NOT NULL,
    vmswap_last       REAL NOT NULL,

    io_read_min       REAL NOT NULL,
    io_read_max       REAL NOT NULL,
    io_read_last      REAL NOT NULL,

    io_write_min      REAL NOT NULL,
    io_write_max      REAL NOT NULL,
    io_write_last     REAL NOT NULL,

    cpu_min           REAL NOT NULL,
    cpu_max           REAL NOT NULL,
    cpu_last          REAL NOT NULL,

    icswitch_min      REAL NOT NULL,
    icswitch_max      REAL NOT NULL,
    icswitch_last     REAL NOT NULL,

    priority_min      REAL NOT NULL,
    priority_max      REAL NOT NULL,
    priority_last     REAL NOT NULL,

    threads_min       REAL NOT NULL,
    threads_max       REAL NOT NULL,
    threads_last      REAL NOT NULL,
    INDEX idx_service_name (service_name)
);

Security Note: Ensure the db-user defined in your gsettings configuration has full Read/Write permissions (GRANT ALL PRIVILEGES) on these tables. Without this, the Core will be unable to commit the "memory" of your system to the disk.


Next: API Reference, Previous: Conclusions: The World is Your Input, Up: STARTER   [Contents]