-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathschema.sql
56 lines (51 loc) · 1.73 KB
/
schema.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
CREATE TABLE `sharpefolio`.`prices` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`stock_id` INT NOT NULL ,
`date` date NOT NULL ,
`closing_price` double(10,4) UNSIGNED NOT NULL ,
`change` double(14,8) NOT NULL DEFAULT 0 ,
PRIMARY KEY (`id`, `stock_id`, `date`),
UNIQUE KEY `unique_price` (`stock_id`, `date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `stocks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`symbol` varchar(50) NOT NULL,
`company` varchar(200) DEFAULT NULL,
PRIMARY KEY (`id`,`symbol`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `reports` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`duration` int(11) NOT NULL,
`formula` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_report` (`date`, `duration`, `formula`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `ratios` (
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT,
`stock_id` int(11) NOT NULL,
`report_id` int(11) NOT NULL,
`ratio` double(10,6),
PRIMARY KEY (`id`),
UNIQUE KEY (`stock_id`, `report_id`),
KEY `ratio` (`ratio`),
KEY `report_id` (`report_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `picks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`recipe_id` int(11) NOT NULL,
`report_id` int(11) NOT NULL,
`stock_id` int(11) NOT NULL,
`gain` double(10,6),
`weight` double(10,6),
PRIMARY KEY (`id`, `recipe_id`, `stock_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `recipes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`n_stocks` int(11) NOT NULL,
`check_correlation` tinyint(1) UNSIGNED NOT NULL,
`distribution` varchar(10),
`report_duration` int(11) NOT NULL,
`report_formula` varchar(30) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;