forked from luctrott/phy_Project2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.sql
52 lines (45 loc) · 1.28 KB
/
create.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
PRAGMA writable_schema = 1;
DELETE FROM sqlite_master WHERE TRUE ;
PRAGMA writable_schema = 0;
VACUUM;
PRAGMA integrity_check;
-- Create direction table
CREATE TABLE direction (
direction_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name VARCHAR(255)
);
-- Create robot table
CREATE TABLE robot (
robot_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name VARCHAR(255)
);
-- Create json table
CREATE TABLE json (
json_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
data TEXT
);
-- Create motor table
CREATE TABLE motor (
motor_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name VARCHAR(255)
);
-- Create command table
CREATE TABLE command (
command_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
tstamp FLOAT,
robot_id INTEGER,
json_id INTEGER,
FOREIGN KEY (robot_id) REFERENCES robot(robot_id),
FOREIGN KEY (json_id) REFERENCES json(json_id)
);
-- Create motor_command table
CREATE TABLE motor_command (
motor_command_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
command_id INTEGER,
motor_id INTEGER,
direction_id INTEGER,
speed INT,
FOREIGN KEY (command_id) REFERENCES command(command_id),
FOREIGN KEY (motor_id) REFERENCES motor(motor_id),
FOREIGN KEY (direction_id) REFERENCES direction(direction_id)
);