-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.sql
111 lines (93 loc) · 3.79 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
-- --------------------------------------------------------
--
-- Table structure for table `Company`
--
CREATE TABLE `Company` (
`name` char(16) NOT NULL,
`description` char(64) NOT NULL,
`website` char(64) NOT NULL,
`isStation` tinyint(1) NOT NULL DEFAULT '1',
`isSupplier` tinyint(1) NOT NULL DEFAULT '0',
`isNozzle` tinyint(1) NOT NULL DEFAULT '0',
`logo` char(128) DEFAULT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `Nozzle`
--
CREATE TABLE `Nozzle` (
`name` char(32) NOT NULL,
`description` varchar(128) NOT NULL,
`company` char(16) NOT NULL,
`dataInterface` char(32) NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `StationPlanningStatus`
--
CREATE TABLE `StationPlanningStatus` (
`name` char(32) NOT NULL,
`description` varchar(128) NOT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `Station`
--
CREATE TABLE `Station` (
`id` mediumint(9) NOT NULL AUTO_INCREMENT,
`name` char(32) NOT NULL,
`company` char(16) NOT NULL,
`supplier` char(16) DEFAULT NULL,
`location` point NOT NULL,
`address` char(128) NOT NULL,
`city` char(32) NOT NULL,
`state` char(2) NOT NULL DEFAULT 'CA',
`zipCode` char(9) NOT NULL,
`num35MPa` tinyint(1) NOT NULL DEFAULT '1',
`num70MPa` tinyint(1) NOT NULL DEFAULT '1',
`numHiMPa` tinyint(1) NOT NULL DEFAULT '0',
`nozzle` char(32) COLLATE utf8mb4_unicode_ci DEFAULT 'Generic',
`dateOpened` date NOT NULL,
`planningStatus` char(32) DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `name` (`name`),
CONSTRAINT `fk_Station_company_Company` FOREIGN KEY (`company`) REFERENCES `Company` (`name`),
CONSTRAINT `fk_Station_nozzle_Nozzle` FOREIGN KEY (`nozzle`) REFERENCES `Nozzle` (`name`),
CONSTRAINT `fk_Station_supplier_Company` FOREIGN KEY (`supplier`) REFERENCES `Company` (`name`),
CONSTRAINT `fk_Station_planningStatus_StationPlanningStatus` FOREIGN KEY (`planningStatus`) REFERENCES `StationPlanningStatus` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `StationStatus`
--
CREATE TABLE `StationStatus` (
`stationID` mediumint(9) NOT NULL,
`recordedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`capacity35MPa` smallint(6) NOT NULL,
`capacity70MPa` smallint(6) NOT NULL,
`capacityHiMPa` smallint(6) NOT NULL DEFAULT '0',
`status35MPa` tinyint(1) NOT NULL,
`status70MPa` tinyint(1) NOT NULL,
`statusHiMPa` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`stationID`, `recordedAt`),
CONSTRAINT `fk_StationStatus_stationID_Station` FOREIGN KEY (`stationID`) REFERENCES `Station` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------------------------
--
-- Table structure for table `StationOpenPeriods`
--
CREATE TABLE `StationOpenPeriods` (
`stationID` mediumint(9) NOT NULL,
`day` enum('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday') NOT NULL,
`start` char(4) NOT NULL DEFAULT '000',
`end` char(4) NOT NULL DEFAULT '2359',
`comments` varchar(32) DEFAULT NULL,
PRIMARY KEY (`stationID`, `day`),
CONSTRAINT `fk_StationOpenPeriods_stationID_Station` FOREIGN KEY (`stationID`) REFERENCES `Station`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;