Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG2900
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sara Savanovic Djordjevic
PROG2900
Commits
e54cb396
Commit
e54cb396
authored
11 months ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: db schema and data
parent
97d95fa4
No related branches found
Branches containing commit
No related tags found
1 merge request
!13
Clhp map
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/database/icedb
+0
-0
0 additions, 0 deletions
server/database/icedb
server/database/schema.sql
+39
-30
39 additions, 30 deletions
server/database/schema.sql
with
39 additions
and
30 deletions
server/database/icedb
+
0
−
0
View file @
e54cb396
No preview for this file type
This diff is collapsed.
Click to expand it.
server/database/schema.sql
+
39
−
30
View file @
e54cb396
...
...
@@ -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
,
'
Othe
r'
,
0
);
(
3
,
'
LiDa
r'
,
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
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment