Skip to content
Snippets Groups Projects
Commit e54cb396 authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

update: db schema and data

parent 97d95fa4
No related branches found
No related tags found
1 merge request!13Clhp map
No preview for this file type
......@@ -12,54 +12,63 @@ CREATE TABLE Sensor (
-- Measurement taken at a given time
CREATE TABLE Measurement (
MeasurementID INT PRIMARY KEY,
MeasurementID INT NOT NULL,
SensorID INT NOT NULL,
TimeMeasured DATETIME NOT NULL,
WaterBodyName TEXT NOT NULL,
CenterLat FLOAT NOT NULL,
CenterLon FLOAT NOT NULL,
WholeAverageThickness FLOAT NOT NULL,
FOREIGN KEY (SensorID) REFERENCES Sensor(SensorID),
FOREIGN KEY (WaterBodyName) REFERENCES BodyOfWater(Name)
FOREIGN KEY (WaterBodyName) REFERENCES BodyOfWater(Name),
PRIMARY KEY (MeasurementID, WaterBodyName, TimeMeasured)
);
CREATE TABLE SubDivision (
MeasurementID INT,
SubDivisionID INT,
GroupID INT NOT NULL,
CREATE TABLE SubdivisionMeasurementData (
MeasurementID INT NOT NULL,
TimeMeasured DATETIME NOT NULL,
SubdivID INT NOT NULL,
WaterBodyName TEXT NOT NULL,
MinimumThickness FLOAT NOT NULL,
AverageThickness FLOAT NOT NULL,
CenterLatitude FLOAT NOT NULL,
CenterLongitude FLOAT NOT NULL,
CalculatedSafety FLOAT NOT NULL,
Accuracy FLOAT,
FOREIGN KEY (MeasurementID) REFERENCES Measurement(MeasurementID),
PRIMARY KEY (MeasurementID, SubDivisionID)
FOREIGN KEY (MeasurementID, TimeMeasured, WaterBodyName) REFERENCES Measurement(MeasurementID, TimeMeasured, WaterBodyName),
PRIMARY KEY (SubdivID, WaterBodyName, TimeMeasured)
);
-- Indexes
CREATE INDEX idx_measurement_waterbodyname ON Measurement(WaterBodyName);
CREATE INDEX idx_measurement_timemeasured ON Measurement(TimeMeasured);
-- Test data
INSERT INTO Sensor (SensorID, SensorType, Active) VALUES
(1, 'LiDar', 1),
(2, 'Magnetic', 1),
(3, 'Other', 0);
(3, 'LiDar', 0);
INSERT INTO BodyOfWater(Name) VALUES
('Mjosa');
('Mjøsa'),
('Skumsjøen');
INSERT INTO Measurement (MeasurementID, SensorID, TimeMeasured, WaterBodyName, CenterLon, CenterLat) VALUES
(1, 2, '2024-01-01 10:00:00', 'Mjøsa', 10.1234, 60.4567),
(2, 2, '2024-02-04 11:00:00', 'Mjøsa', 10.2345, 60.5678),
(3, 1, '2024-02-13 12:00:00', 'Mjøsa', 10.3456, 60.6789),
(1, 3, '2024-02-13 12:00:00', 'Skumsjøen', 10.4567, 60.7890),
(2, 3, '2024-02-13 12:00:00', 'Skumsjøen', 10.5678, 60.8901),
(3, 3, '2024-02-13 12:00:00', 'Skumsjøen', 10.6789, 60.9012);
INSERT INTO Measurement (MeasurementID, SensorID, TimeMeasured, WaterBodyName, WholeAverageThickness) VALUES
(1, 2, '2024-01-01 10:00:00', 'Mjosa', 5.8),
(2, 2, '2024-02-04 11:00:00', 'Mjosa', 7.6),
(3, 1, '2024-02-13 12:00:00', 'Mjosa', 4.1);
INSERT INTO SubDivision (MeasurementID, SubDivisionID, GroupID, MinimumThickness, AverageThickness, CenterLatitude, CenterLongitude, Accuracy) VALUES
(1, 1, 1, 3.2, 4.5, 60.765, 10.723, 1.2),
(1, 2, 1, 2.8, 4.3, 60.780, 10.776, 1.1),
(1, 3, 2, 4.1, 5.7, 60.768, 10.845, 1.3),
(1, 4, 2, 3.5, 5.0, 60.749, 10.783, 1.4),
(2, 1, 1, 4.1, 5.7, 60.768, 10.845, 1.3),
(2, 2, 2, 3.5, 5.0, 60.749, 10.783, 1.4),
(3, 1, 1, 4.1, 5.7, 60.768, 10.845, 1.3),
(3, 2, 2, 3.5, 5.0, 60.749, 10.783, 1.4);
INSERT INTO SubdivisionMeasurementData (MeasurementID, SubdivID, TimeMeasured, WaterBodyName, MinimumThickness,
AverageThickness, CalculatedSafety, Accuracy) VALUES
(1, 1, '2024-01-01 10:00:00', 'Mjøsa', 3.2, 4.5, 2.1, 1.2),
(1, 2, '2024-01-01 10:00:00', 'Mjøsa', 2.8, 4.3, 2.5, 1.1),
(1, 3, '2024-01-01 10:00:00', 'Mjøsa', 4.1, 5.7, 2.3, 1.3),
(1, 4, '2024-01-01 10:00:00', 'Mjøsa', 3.5, 5.0, 2.2, 1.4),
(2, 1, '2024-02-04 11:00:00', 'Mjøsa', 4.1, 5.7, 2.3, 1.3),
(2, 2, '2024-02-04 11:00:00', 'Mjøsa', 3.5, 5.0, 2.2, 1.4),
(3, 1, '2024-02-13 12:00:00', 'Mjøsa', 4.1, 5.7, 2.3, 1.3),
(3, 2, '2024-02-13 12:00:00', 'Mjøsa', 3.5, 5.0, 2.2, 1.4),
(1, 1, '2024-01-01 10:00:00', 'Skumsjøen', 3.8, 5.3, 2.2, 1.2),
(1, 2, '2024-01-01 10:00:00', 'Skumsjøen', 2.4, 4.8, 2.3, 1.1),
(1, 3, '2024-01-01 10:00:00', 'Skumsjøen', 4.5, 6.1, 2.5, 1.3),
(2, 1, '2024-02-04 11:00:00', 'Skumsjøen', 4.5, 6.1, 2.5, 1.3),
(2, 2, '2024-02-04 11:00:00', 'Skumsjøen', 3.9, 5.6, 2.3, 1.4),
(3, 1, '2024-02-13 12:00:00', 'Skumsjøen', 3.8, 5.3, 2.2, 1.2),
(3, 2, '2024-02-13 12:00:00', 'Skumsjøen', 2.4, 4.8, 2.3, 1.1);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment