aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2018-05-01 22:36:49 +0200
committerTharre <tharre3@gmail.com>2018-05-01 22:57:57 +0200
commit708ed158c41ee2ee5dfce64fdecf89aed4c17685 (patch)
treeb847983979c3e30cda82feaf9b8e60e89b531fa6 /src
parentbfb7f0ebd2c19b0fdd729de526e36794812c35cd (diff)
downloadsepm-groupproject-708ed158c41ee2ee5dfce64fdecf89aed4c17685.tar.gz
sepm-groupproject-708ed158c41ee2ee5dfce64fdecf89aed4c17685.tar.xz
sepm-groupproject-708ed158c41ee2ee5dfce64fdecf89aed4c17685.zip
Add sql database schema
Diffstat (limited to 'src')
-rw-r--r--src/main/resources/sql/database.sql57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/main/resources/sql/database.sql b/src/main/resources/sql/database.sql
new file mode 100644
index 0000000..9d1b0e1
--- /dev/null
+++ b/src/main/resources/sql/database.sql
@@ -0,0 +1,57 @@
+CREATE TABLE IF NOT EXISTS VehicleVersion (
+ id BIGINT AUTO_INCREMENT PRIMARY KEY,
+ name VARCHAR(100) NOT NULL,
+ constructionType ENUM('Normal', 'Hochdach', 'Mittelhochdach') NOT NULL,
+ type ENUM('BKTW', 'KTW-B', 'KTW', 'RTW', 'NEF', 'NAH') NOT NULL,
+);
+
+CREATE TABLE IF NOT EXISTS Vehicle (
+ id BIGINT AUTO_INCREMENT PRIMARY KEY,
+ version BIGINT NOT NULL,
+ status ENUM('abgemeldet', 'frei_wache', 'zum_berufungsort', 'am_berufungsort', 'zum_zielort',
+ 'am_zielort', 'frei_funk', 'deleted') NOT NULL,
+ FOREIGN KEY (version) REFERENCES VehicleVersion(id),
+);
+
+CREATE TABLE IF NOT EXISTS EmployeeVersion (
+ id BIGINT AUTO_INCREMENT PRIMARY KEY,
+ name VARCHAR(100) NOT NULL,
+ birthday DATE NOT NULL,
+ educationLevel ENUM('RS', 'NFS', 'NKV', 'NKA', 'NKI', 'NA') NOT NULL,
+ isDriver BOOLEAN NOT NULL,
+ isPilot BOOLEAN NOT NULL,
+);
+
+CREATE TABLE IF NOT EXISTS Employee (
+ id BIGINT AUTO_INCREMENT PRIMARY KEY,
+ version BIGINT NOT NULL,
+ FOREIGN KEY (version) REFERENCES EmployeeVersion(id),
+);
+
+CREATE TABLE IF NOT EXISTS Registration (
+ id BIGINT AUTO_INCREMENT PRIMARY KEY,
+ vehicleId BIGINT NOT NULL,
+ employeeId BIGINT NOT NULL,
+ start TIMESTAMP NOT NULL,
+ end TIMESTAMP NOT NULL,
+ active BOOLEAN NOT NULL,
+ FOREIGN KEY (vehicleId) REFERENCES VehicleVersion(id),
+ FOREIGN KEY (employeeId) REFERENCES EmployeeVersion(id),
+);
+
+CREATE TABLE IF NOT EXISTS Operation (
+ id BIGINT AUTO_INCREMENT PRIMARY KEY,
+ opCode VARCHAR(20) NOT NULL,
+ severity ENUM('A', 'B', 'C', 'D', 'E', 'O') NOT NULL,
+ created TIMESTAMP NOT NULL,
+ destination VARCHAR(100) NOT NULL,
+ additionalInfo VARCHAR(100),
+);
+
+CREATE TABLE IF NOT EXISTS VehicleOperation (
+ vehicleId BIGINT NOT NULL,
+ operationId BIGINT NOT NULL,
+ FOREIGN KEY (vehicleId) REFERENCES VehicleVersion(id),
+ FOREIGN KEY (operationId) REFERENCES Operation(id),
+ PRIMARY KEY (vehicleId, operationId),
+);