BEGIN TRANSACTION;
CREATE TABLE uploadedfiles (hash TEXT, endtime NUMERIC, file_id INTEGER PRIMARY KEY, uploaded NUMERIC, filedata BLOB, unittype INTEGER NOT NULL DEFAULT '0', unitname TEXT NOT NULL DEFAULT "");
CREATE TABLE units (name TEXT, created NUMERIC, unit_id INTEGER PRIMARY KEY);
CREATE TABLE humans (human_id INTEGER PRIMARY KEY, fullname TEXT, cardnumber TEXT, created NUMERIC);
CREATE TABLE events (human_id NUMERIC, event_id INTEGER PRIMARY KEY, event_time NUMERIC, event_type NUMERIC, event_data BLOB, unit_id NUMERIC, event_caption TEXT);
CREATE INDEX unittypeindex ON uploadedfiles(unittype ASC);
CREATE INDEX unitnameindex ON uploadedfiles(unitname ASC);
CREATE INDEX unitindex ON events(unit_id ASC);
CREATE INDEX nameindex ON units(name ASC);
CREATE INDEX humanindex ON events(human_id ASC);
CREATE UNIQUE INDEX hashdupprevent ON uploadedfiles(hash ASC);
CREATE INDEX eventtimeindex ON events(event_time ASC);
CREATE INDEX endtimeindex ON uploadedfiles(endtime ASC);
CREATE INDEX cardnumberindex ON humans(cardnumber ASC);
COMMIT;
