-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdatabase_structure.sql
87 lines (70 loc) · 2.75 KB
/
database_structure.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
DROP DATABASE IF EXISTS fiesta_iot;
CREATE DATABASE fiesta_iot;
USE fiesta_iot;
SET time_zone = "+00:00";
#SET time_zone = "Europe/Madrid";
CREATE TABLE resource_id_mapper (
hash VARCHAR(44),
url VARCHAR(2000) NOT NULL,
CONSTRAINT PK_resource PRIMARY KEY (hash)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE endpoint_id_mapper (
hash VARCHAR(44),
url VARCHAR(2000) NOT NULL,
CONSTRAINT PK_endpoint PRIMARY KEY (hash)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE observation_id_mapper (
hash VARCHAR(44),
url VARCHAR(2000) NOT NULL,
CONSTRAINT PK_observation PRIMARY KEY (hash)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE sparql_query (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`value` TEXT NOT NULL,
`name` VARCHAR(256) NOT NULL,
`description` text,
`scope` ENUM ('GLOBAL', 'RESOURCES', 'OBSERVATIONS') NOT NULL,
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
CONSTRAINT PK_sparql_query PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE sparql_query_log (
`hash` CHAR(44) NOT NULL,
`query` TEXT NOT NULL,
CONSTRAINT PK_sparql_query_log PRIMARY KEY (hash)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE sparql_query_log ROW_FORMAT=compressed;
-- SHOW VARIABLES LIKE 'innodb_file_format'; -- Barracuda
-- SHOW VARIABLES LIKE 'innodb_file_per_table'; -- ON
CREATE TABLE sparql_query_execution_log (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`query_hash` CHAR(44) NOT NULL,
`exec_time` INT NULL,
`ip_address` BIGINT NOT NULL,
`user` VARCHAR(256),
`user_agent` VARCHAR(256),
`component` VARCHAR(256),
`aborted` BOOLEAN DEFAULT TRUE,
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT PK_sparql_query_execution_log PRIMARY KEY (id),
CONSTRAINT FK_query_hash FOREIGN KEY (query_hash) REFERENCES sparql_query_log(hash)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE sparql_query_execution_log ROW_FORMAT=compressed;
-- Retrieve list of IP addresses in string format
-- SELECT INET_NTOA(ip_address) FROM sparql_query_execution_log;
CREATE TABLE semantic_storage_log (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`entity` ENUM ('RESOURCE', 'OBSERVATION', 'TESTBED') NOT NULL,
`exec_time` INT NULL,
`ip_address` BIGINT NOT NULL,
`user` VARCHAR(256),
`user_agent` VARCHAR(256),
`component` VARCHAR(256),
`aborted` BOOLEAN DEFAULT TRUE,
`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT semantic_storage_log PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE semantic_storage_log ROW_FORMAT=compressed;
CREATE USER IF NOT EXISTS 'USERNAME'@'localhost' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON fiesta_iot . * TO 'USERNAME'@'localhost';
FLUSH PRIVILEGES;