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
ecaf695c
Commit
ecaf695c
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: schema & db
parent
56b6a2f2
No related branches found
No related tags found
1 merge request
!2
App2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/sql_db/icedb
+0
-0
0 additions, 0 deletions
server/sql_db/icedb
server/sql_db/schema.sql
+39
-73
39 additions, 73 deletions
server/sql_db/schema.sql
with
39 additions
and
73 deletions
server/sql_db/icedb
+
0
−
0
View file @
ecaf695c
No preview for this file type
This diff is collapsed.
Click to expand it.
server/sql_db/schema.sql
+
39
−
73
View file @
ecaf695c
CREATE
TABLE
Measurement
(
-- Body of water
MeasurementID
INT
PRIMARY
KEY
,
CREATE
TABLE
BodyOfWater
(
SensorID
INT
,
Name
TEXT
PRIMARY
KEY
TimeMeasured
DATETIME
,
WaterBodyName
TEXT
,
FOREIGN
KEY
(
SensorID
)
REFERENCES
Sensor
(
SensorID
),
FOREIGN
KEY
(
WaterBodyName
)
REFERENCES
BodyOfWater
(
Name
)
);
);
-- Single sensor
CREATE
TABLE
Sensor
(
CREATE
TABLE
Sensor
(
SensorID
INT
EGER
PRIMARY
KEY
,
SensorID
INT
PRIMARY
KEY
,
SensorType
TEXT
CHECK
(
SensorType
IN
(
'LiDar'
,
'Magnetic'
,
'Other'
)),
SensorType
TEXT
CHECK
(
SensorType
IN
(
'LiDar'
,
'Magnetic'
,
'Other'
)),
Active
BOOLEAN
Active
BOOLEAN
);
);
CREATE
TABLE
Data
(
-- Measurement taken at a given time
MeasurementID
INT
,
CREATE
TABLE
Measurement
(
Latitude
FLOAT
,
MeasurementID
INT
PRIMARY
KEY
,
Longitude
FLOAT
,
SensorID
INT
NOT
NULL
,
IceTop
FLOAT
,
TimeMeasured
DATETIME
NOT
NULL
,
IceBottom
FLOAT
,
WaterBodyName
TEXT
NOT
NULL
,
CalculatedThickness
FLOAT
,
WholeAverageThickness
FLOAT
NOT
NULL
,
Accuracy
FLOAT
,
FOREIGN
KEY
(
SensorID
)
REFERENCES
Sensor
(
SensorID
),
PRIMARY
KEY
(
MeasurementID
,
Longitude
,
Latitude
),
FOREIGN
KEY
(
WaterBodyName
)
REFERENCES
BodyOfWater
(
Name
)
FOREIGN
KEY
(
MeasurementID
)
REFERENCES
Measurement
(
MeasurementID
)
);
);
CREATE
TABLE
Corner
(
CREATE
TABLE
SubDivision
(
CornerID
INT
,
MeasurementID
INT
,
MeasurementID
INT
,
CornerLatitude
FLOAT
,
SubDivisionID
INT
,
CornerLongitude
FLOAT
,
GroupID
INT
NOT
NULL
,
PRIMARY
KEY
(
CornerID
,
MeasurementID
),
MinimumThickness
FLOAT
NOT
NULL
,
FOREIGN
KEY
(
MeasurementID
)
REFERENCES
Measurement
(
MeasurementID
)
AverageThickness
FLOAT
NOT
NULL
,
CenterLatitude
FLOAT
NOT
NULL
,
CenterLongitude
FLOAT
NOT
NULL
,
Accuracy
FLOAT
,
FOREIGN
KEY
(
MeasurementID
)
REFERENCES
Measurement
(
MeasurementID
),
PRIMARY
KEY
(
MeasurementID
,
SubDivisionID
)
);
);
CREATE
TABLE
BodyOfWater
(
-- Indexes
Name
TEXT
PRIMARY
KEY
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
INSERT
INTO
Sensor
(
SensorID
,
SensorType
,
Active
)
VALUES
(
1
,
'LiDar'
,
1
),
(
1
,
'LiDar'
,
1
),
(
2
,
'Magnetic'
,
1
),
(
2
,
'Magnetic'
,
1
),
(
3
,
'Other'
,
0
);
(
3
,
'Other'
,
0
);
INSERT
INTO
Measurement
(
MeasurementID
,
SensorID
,
TimeMeasured
,
WaterBodyName
)
VALUES
INSERT
INTO
BodyOfWater
(
Name
)
VALUES
(
1
,
2
,
'2024-01-01 10:00:00'
,
'Mjosa'
),
(
'Mjosa'
);
(
2
,
2
,
'2024-02-04 11:00:00'
,
'Mjosa'
),
(
3
,
1
,
'2024-02-13 12:00:00'
,
'Mjosa'
);
-- Measurement 1
INSERT
INTO
Data
(
MeasurementID
,
Latitude
,
Longitude
,
IceTop
,
IceBottom
,
CalculatedThickness
,
Accuracy
)
VALUES
(
1
,
60
.
7070
,
10
.
9771
,
8
.
0
,
3
.
0
,
5
.
0
,
1
.
0
),
(
1
,
60
.
7066
,
10
.
9772
,
7
.
5
,
2
.
5
,
5
.
0
,
1
.
0
),
(
1
,
60
.
7067
,
10
.
9773
,
7
.
5
,
2
.
5
,
5
.
0
,
1
.
0
),
(
1
,
60
.
7062
,
10
.
9774
,
7
.
5
,
2
.
5
,
5
.
0
,
1
.
0
),
(
1
,
60
.
7067
,
10
.
9775
,
7
.
0
,
2
.
0
,
5
.
0
,
1
.
0
);
INSERT
INTO
Corner
(
CornerID
,
MeasurementID
,
CornerLatitude
,
CornerLongitude
)
VALUES
(
1
,
1
,
60
.
7060
,
10
.
9770
),
(
2
,
1
,
60
.
7061
,
10
.
9771
),
(
3
,
1
,
60
.
7062
,
10
.
9772
),
(
4
,
1
,
60
.
7063
,
10
.
9773
);
-- Measurement 2
INSERT
INTO
Data
(
MeasurementID
,
Latitude
,
Longitude
,
IceTop
,
IceBottom
,
CalculatedThickness
,
Accuracy
)
VALUES
(
2
,
60
.
6366
,
10
.
8171
,
7
.
2
,
2
.
2
,
5
.
0
,
1
.
5
),
(
2
,
60
.
6367
,
10
.
8172
,
7
.
0
,
2
.
0
,
5
.
0
,
1
.
5
),
(
2
,
60
.
6368
,
10
.
8172
,
7
.
1
,
2
.
1
,
5
.
0
,
1
.
5
),
(
2
,
60
.
6369
,
10
.
8172
,
7
.
3
,
2
.
3
,
5
.
0
,
1
.
5
),
(
2
,
60
.
6367
,
10
.
8173
,
7
.
4
,
2
.
4
,
5
.
0
,
1
.
5
),
(
2
,
60
.
6367
,
10
.
8179
,
7
.
5
,
2
.
5
,
5
.
0
,
1
.
5
);
INSERT
INTO
Corner
(
CornerID
,
MeasurementID
,
CornerLatitude
,
CornerLongitude
)
VALUES
INSERT
INTO
Measurement
(
MeasurementID
,
SensorID
,
TimeMeasured
,
WaterBodyName
,
WholeAverageThickness
)
VALUES
(
1
,
2
,
60
.
6360
,
10
.
8170
),
(
1
,
2
,
'2024-01-01 10:00:00'
,
'Mjosa'
,
5
.
8
),
(
2
,
2
,
60
.
6361
,
10
.
8171
),
(
2
,
2
,
'2024-02-04 11:00:00'
,
'Mjosa'
,
7
.
6
),
(
3
,
2
,
60
.
6362
,
10
.
8172
),
(
3
,
1
,
'2024-02-13 12:00:00'
,
'Mjosa'
,
4
.
1
);
(
4
,
2
,
60
.
6363
,
10
.
8173
);
-- Measurement 3
INSERT
INTO
SubDivision
(
MeasurementID
,
SubDivisionID
,
GroupID
,
MinimumThickness
,
AverageThickness
,
CenterLatitude
,
CenterLongitude
,
Accuracy
)
VALUES
INSERT
INTO
Data
(
MeasurementID
,
Latitude
,
Longitude
,
IceTop
,
IceBottom
,
CalculatedThickness
,
Accuracy
)
VALUES
(
1
,
1
,
1
,
3
.
2
,
4
.
5
,
60
.
765
,
10
.
723
,
1
.
2
),
(
3
,
60
.
7366
,
10
.
8471
,
7
.
5
,
2
.
5
,
5
.
0
,
2
.
5
),
(
1
,
2
,
1
,
2
.
8
,
4
.
3
,
60
.
780
,
10
.
776
,
1
.
1
),
(
3
,
60
.
7369
,
10
.
8471
,
7
.
4
,
2
.
4
,
5
.
0
,
2
.
5
),
(
1
,
3
,
2
,
4
.
1
,
5
.
7
,
60
.
768
,
10
.
845
,
1
.
3
),
(
3
,
60
.
7367
,
10
.
8480
,
7
.
3
,
2
.
3
,
5
.
0
,
2
.
5
),
(
1
,
4
,
2
,
3
.
5
,
5
.
0
,
60
.
749
,
10
.
783
,
1
.
4
);
(
3
,
60
.
7368
,
10
.
8481
,
7
.
2
,
2
.
2
,
5
.
0
,
2
.
5
),
(
3
,
60
.
7370
,
10
.
8475
,
7
.
1
,
2
.
1
,
5
.
0
,
2
.
5
);
INSERT
INTO
Corner
(
CornerID
,
MeasurementID
,
CornerLatitude
,
CornerLongitude
)
VALUES
(
1
,
3
,
60
.
7360
,
10
.
8470
),
(
2
,
3
,
60
.
7361
,
10
.
8471
),
(
3
,
3
,
60
.
7362
,
10
.
8472
),
(
4
,
3
,
60
.
7363
,
10
.
8473
);
INSERT
INTO
BodyOfWater
(
Name
)
VALUES
(
'Mjosa'
);
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