-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
36 lines (34 loc) · 964 Bytes
/
init.sql
File metadata and controls
36 lines (34 loc) · 964 Bytes
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
-- Tabelle für Zugfahrten
CREATE TABLE IF NOT EXISTS trips (
id VARCHAR(36) PRIMARY KEY,
latitude DOUBLE,
longitude DOUBLE,
timestamp DATETIME,
train_name VARCHAR(50),
fahrt_nr VARCHAR(20),
trip_id VARCHAR(255),
planned_timestamp DATETIME,
delay INT,
destination VARCHAR(255),
INDEX idx_fahrt_nr_timestamp (fahrt_nr, timestamp)
);
-- Tabelle für tägliche Verspätungsstatistiken
CREATE TABLE IF NOT EXISTS today_delay_stats (
id VARCHAR(36) PRIMARY KEY,
fahrt_nr VARCHAR(255),
train_name VARCHAR(255),
delay INT,
timestamp DATETIME,
UNIQUE KEY uk_fahrt_nr_date (fahrt_nr, timestamp)
);
-- Tabelle für aggregierte Verspätungsstatistiken
CREATE TABLE IF NOT EXISTS delay_stats (
id VARCHAR(36) PRIMARY KEY,
fahrt_nr VARCHAR(255),
total_trips INT,
delayed_trips INT,
avg_delay FLOAT,
median_delay FLOAT,
last_updated DATETIME,
INDEX idx_fahrt_nr (fahrt_nr)
);