CREATE TABLE run ( runId       INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, runName     TEXT NOT NULL, simtimeExp  INTEGER NOT NULL );
CREATE TABLE runattr ( runId       INTEGER  NOT NULL REFERENCES run(runId) on DELETE CASCADE, attrName    TEXT NOT NULL, attrValue   TEXT NOT NULL );
CREATE TABLE runparam ( runId       INTEGER  NOT NULL REFERENCES run(runId) on DELETE CASCADE, parName     TEXT NOT NULL, parValue    TEXT NOT NULL );
CREATE TABLE scalar ( scalarId      INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, runId         INTEGER  NOT NULL REFERENCES run(runId) on DELETE CASCADE, moduleName    TEXT NOT NULL, scalarName    TEXT NOT NULL, scalarValue   REAL );
CREATE TABLE scalarattr ( scalarId      INTEGER  NOT NULL REFERENCES scalar(scalarId) on DELETE CASCADE, runId         INTEGER  NOT NULL REFERENCES run(runId) on DELETE CASCADE, attrName      TEXT NOT NULL, attrValue     TEXT NOT NULL );
CREATE TABLE histogram ( histId        INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, runId         INTEGER  NOT NULL REFERENCES run(runId) on DELETE CASCADE, moduleName    TEXT NOT NULL, histName      TEXT NOT NULL, histCount     INTEGER NOT NULL, histMean      REAL NOT NULL, histStddev    REAL NOT NULL, histSum       REAL NOT NULL, histSqrsum    REAL NOT NULL, histMin       REAL NOT NULL, histMax       REAL NOT NULL, histWeights          REAL, histWeightedSum      REAL, histSqrSumWeights    REAL, histWeightedSqrSum   REAL );
CREATE TABLE statisticattr ( histId        INTEGER  NOT NULL REFERENCES histogram(histId) on DELETE CASCADE, runId         INTEGER  NOT NULL REFERENCES run(runId) on DELETE CASCADE, attrName      TEXT NOT NULL, attrValue     TEXT NOT NULL );
CREATE TABLE histbin ( histId        INTEGER  NOT NULL REFERENCES histogram(histId) on DELETE CASCADE, runId         INTEGER  NOT NULL REFERENCES run(runId) on DELETE CASCADE, lowerEdge     NUMERIC NOT NULL, binValue     NUMERIC NOT NULL );
CREATE TABLE vector ( vectorId      INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, runId         INTEGER  NOT NULL REFERENCES run(runId) on DELETE CASCADE, moduleName    TEXT NOT NULL, vectorName    TEXT NOT NULL );
CREATE TABLE vectorattr ( vectorId      INTEGER  NOT NULL REFERENCES vector(vectorId) on DELETE CASCADE, runId         INTEGER  NOT NULL REFERENCES run(runId) on DELETE CASCADE, attrName      TEXT NOT NULL, attrValue     TEXT NOT NULL );
CREATE TABLE vectordata ( vectorId      INTEGER  NOT NULL REFERENCES vector(vectorId) on DELETE CASCADE, runId         INTEGER  NOT NULL REFERENCES run(runId) on DELETE CASCADE, eventNumber   INTEGER NOT NULL, simtimeRaw    INTEGER NOT NULL, value         NUMERIC NOT NULL );
