2015-06-04 16:52:58 +02:00
|
|
|
-- Clear database from previous tables (just in case...)
|
2015-07-09 15:38:56 +02:00
|
|
|
DROP TABLE IF EXISTS Users CASCADE;
|
|
|
|
DROP TABLE IF EXISTS Arrowclicked CASCADE;
|
|
|
|
DROP TABLE IF EXISTS CoinClicked CASCADE;
|
|
|
|
DROP TABLE IF EXISTS KeyboardEvent CASCADE;
|
|
|
|
DROP TABLE IF EXISTS ResetClicked CASCADE;
|
|
|
|
DROP TABLE IF EXISTS PreviousNextClicked CASCADE;
|
|
|
|
DROP TABLE IF EXISTS Hovered CASCADE;
|
|
|
|
DROP TABLE IF EXISTS Scene CASCADE;
|
|
|
|
DROP TABLE IF EXISTS Experiment CASCADE;
|
|
|
|
DROP TABLE IF EXISTS FpsCounter CASCADE;
|
|
|
|
DROP TABLE IF EXISTS PointerLocked CASCADE;
|
|
|
|
DROP TABLE IF EXISTS SwitchedLockOption CASCADE;
|
2015-05-18 09:52:04 +02:00
|
|
|
|
2015-05-19 11:50:12 +02:00
|
|
|
DROP TYPE IF EXISTS VECTOR3 CASCADE;
|
|
|
|
DROP TYPE IF EXISTS CAMERA CASCADE;
|
2015-05-20 16:28:53 +02:00
|
|
|
DROP TYPE IF EXISTS PREVIOUSNEXT CASCADE;
|
|
|
|
|
2015-06-04 16:52:58 +02:00
|
|
|
-- Elementary types
|
2015-05-20 16:28:53 +02:00
|
|
|
CREATE TYPE PREVIOUSNEXT AS ENUM(
|
|
|
|
'p', 'n'
|
|
|
|
);
|
2015-05-19 11:50:12 +02:00
|
|
|
|
|
|
|
CREATE TYPE VECTOR3 AS(
|
2015-05-22 16:59:33 +02:00
|
|
|
x REAL,
|
|
|
|
y REAL,
|
|
|
|
z REAL
|
2015-05-19 11:50:12 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TYPE CAMERA AS(
|
|
|
|
position VECTOR3,
|
|
|
|
target VECTOR3
|
|
|
|
);
|
|
|
|
|
2015-06-04 16:52:58 +02:00
|
|
|
-- Base tables
|
2015-05-19 11:50:12 +02:00
|
|
|
CREATE TABLE users(
|
2015-05-18 09:52:04 +02:00
|
|
|
id SERIAL PRIMARY KEY,
|
2015-05-19 11:50:12 +02:00
|
|
|
name CHAR(50)
|
2015-05-18 09:52:04 +02:00
|
|
|
);
|
2015-05-18 15:33:14 +02:00
|
|
|
|
2015-06-04 16:52:58 +02:00
|
|
|
CREATE TABLE scene(
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
name CHAR(50)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE experiment(
|
2015-05-18 15:33:14 +02:00
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
user_id SERIAL REFERENCES users (id),
|
2015-06-04 16:52:58 +02:00
|
|
|
scene_id SERIAL REFERENCES scene (id)
|
|
|
|
);
|
|
|
|
|
|
|
|
-- Init scene table
|
|
|
|
INSERT INTO scene(name) VALUES ('peachcastle');
|
|
|
|
INSERT INTO scene(name) VALUES ('bobomb');
|
|
|
|
INSERT INTO scene(name) VALUES ('coolcoolmountain');
|
|
|
|
INSERT INTO scene(name) VALUES ('whomp');
|
|
|
|
|
|
|
|
-- Events
|
|
|
|
CREATE TABLE arrowclicked(
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
exp_id SERIAL REFERENCES experiment (id),
|
2015-05-18 15:33:14 +02:00
|
|
|
time TIMESTAMP DEFAULT NOW(),
|
|
|
|
arrow_id INTEGER
|
|
|
|
);
|
|
|
|
|
2015-05-19 11:03:53 +02:00
|
|
|
CREATE TABLE coinclicked(
|
|
|
|
id SERIAL PRIMARY KEY,
|
2015-06-04 16:52:58 +02:00
|
|
|
exp_id SERIAL REFERENCES experiment (id),
|
2015-05-19 11:03:53 +02:00
|
|
|
time TIMESTAMP DEFAULT NOW(),
|
|
|
|
coin_id INTEGER
|
|
|
|
);
|
2015-05-19 11:50:12 +02:00
|
|
|
|
|
|
|
CREATE TABLE keyboardevent(
|
|
|
|
id SERIAL PRIMARY KEY,
|
2015-06-04 16:52:58 +02:00
|
|
|
exp_id SERIAL REFERENCES experiment (id),
|
2015-05-19 11:50:12 +02:00
|
|
|
time TIMESTAMP DEFAULT NOW(),
|
|
|
|
camera CAMERA
|
|
|
|
);
|
2015-05-20 15:20:59 +02:00
|
|
|
|
|
|
|
CREATE TABLE resetclicked(
|
|
|
|
id SERIAL PRIMARY KEY,
|
2015-06-04 16:52:58 +02:00
|
|
|
exp_id SERIAL REFERENCES experiment (id),
|
2015-05-20 15:20:59 +02:00
|
|
|
time TIMESTAMP DEFAULT NOW()
|
|
|
|
);
|
2015-05-20 16:28:53 +02:00
|
|
|
|
|
|
|
CREATE TABLE previousnextclicked(
|
|
|
|
id SERIAL PRIMARY KEY,
|
2015-06-04 16:52:58 +02:00
|
|
|
exp_id SERIAL REFERENCES experiment (id),
|
2015-05-20 16:28:53 +02:00
|
|
|
previousnext PREVIOUSNEXT NOT NULL,
|
|
|
|
time TIMESTAMP DEFAULT NOW(),
|
|
|
|
camera CAMERA
|
|
|
|
);
|
2015-05-21 15:35:40 +02:00
|
|
|
|
|
|
|
CREATE TABLE hovered(
|
|
|
|
id SERIAL PRIMARY KEY,
|
2015-06-04 16:52:58 +02:00
|
|
|
exp_id SERIAL REFERENCES experiment (id),
|
2015-05-21 15:35:40 +02:00
|
|
|
start BOOLEAN NOT NULL,
|
|
|
|
time TIMESTAMP DEFAULT NOW(),
|
2015-06-04 16:52:58 +02:00
|
|
|
arrow_id INTEGER
|
2015-05-21 15:35:40 +02:00
|
|
|
);
|
2015-06-22 09:41:59 +02:00
|
|
|
|
|
|
|
CREATE TABLE fpscounter(
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
exp_id SERIAL REFERENCES experiment (id),
|
2015-07-09 15:38:56 +02:00
|
|
|
time TIMESTAMP DEFAULT NOW(),
|
2015-06-22 09:41:59 +02:00
|
|
|
fps REAL
|
|
|
|
);
|
2015-07-09 15:38:56 +02:00
|
|
|
|
|
|
|
CREATE TABLE pointerlocked(
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
exp_id SERIAL REFERENCES experiment (id),
|
|
|
|
time TIMESTAMP DEFAULT NOW(),
|
|
|
|
locked BOOLEAN
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE switchedlockoption(
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
exp_id SERIAL REFERENCES experiment (id),
|
|
|
|
time TIMESTAMP DEFAULT NOW(),
|
|
|
|
locked BOOLEAN
|
|
|
|
);
|