Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The database design is made so that every team member knows the structure of the database. It basically shows you the way we organize our data.

draw.io Diagram
bordertrue
diagramNameDatabase design
simpleViewerfalse
width
linksauto
tbstyletop
lboxtrue
diagramWidth1201
revision2

figure 13: database design

This is the database setup we will use for the RegterschotRacing API. A full description of every tables usage and datatypes can be found below. All green boxes will be made by Smalltalk in order to provide a sound foundation to build an API on. The red boxes could be implemented for future expansions, but they are out of our current scope. These have been placed here as an example to provide future developers with a stepping stonesteppingstone.


 Database Glossary

Tablenames and formats are written in italic; Columns that contain the primary key are underlined. 

TableColumnDatatypeNull / Not NullComments
GraphThis table contains all data that is required to show a graph. It contains the sensor it is displaying the data for, and the type of graph it is.
GraphIDintNot nullThis is the unique identifier of the graph.
SensorIDintNot nullThe unique identifier of the sensor that the graph is displaying the data of.
RaceThis table contains all information relevant to a race.
RaceIDintNot null

The unique identifier of the race.

NumberOfLapsintNot nullThe number of rounds that the race possesses.
RaceNamevarchar(255)Not nullThe name of the race.
DateDATETIMENot nullThe date of the start of the race.
SensorThis table functions as a collection of all sensors.
SensorIDintNot nullThe unique identifier of the sensor.
SensorNamevarchar(255)Not nullThe name of the sensor.
Typevarchar(255)Not null

The type of graph, can be anything from the following:

  • linechart
  • barchart
  • piechart
  • scatterchart
  • columnchart
  • areachart
  • donutchart
  • table
  • gaugechart

Tab

This table contains all information that is relevant to a Tab.
TabIDintNot nullThe unique identifier of the tab.
TabNamevarchar(255)Not nullThe name of the tab. The name is set when creating a new tab in the frontend web-application.
RaceIDintNot nullThe unique identifier of the race that the tab belongs to.
UserIDintNot nullThe unique identifier of the user that the tab belongs to.
UserThis table handles all user data and other data relevant to have users that can interact with the application.
UserIDintNot nullThe unique identifier of the user.
Usernamevarchar(255)Not nullThe unique name of a user that will be on display in the frontend web-application.
Passwordvarchar(255)Not nullThe hashed password of the user that is needed when logging in into the web-application.
GaugeSettingsThis table handles all the data needed to draw a gauge chart.
SensorIDintNot nullThe unique identifier of the sensor. Also used here as unique identifier.
MinintNot nullThe minimal value that the gauge chart has.
MaxintNot nullThe maximal value that the gauge chart has.
GreenTointNot nullThe value where the green zone ends.
YellowTointNot nullThe value where the yellow zone ends

table 8: glossary database design

Design decisions related to the database

Decision 1

Description

Problem/Issue

Throwing all of the different sensors and their data into one big table will quickly create a very clumped and hard-to-read table.
DecisionCreate a different table for every sensor and add a new table that contains all sensor IDs.
Alternatives-
ArgumentsBy dividing data over multiple tables, query time can be shortened significantly and keeps all of our tables in line with the normalization principle.

table 9: design decision database

Decision 2Description
Problem/issueA driver is only driving a couple of rounds in a race, which will create quite a confusing table if thrown into a single race tables.
Decision

Divide the different datatypes into multiple tables: a rounds table, a race table and a driver table.

Create a linking table that links all of these three tables together.

Alternatives-
ArgumentsBy dividing the table into a multitude of different tables, there's three distinct tables that are in line with the normalization principle.

table 10: design decision database


Decision 3Description
Problem/issueWhen adding a new graph to a tab, the system must know what type of graph must be drawn for that sensor.
Decision

We decided to add the graph type to the sensor in the sensor table.

Alternatives
  1. Saving the graph type in the graph table and letting a user choose from all options when adding a new graph.
Arguments

Currently every sensor will have one specific type of graph. Later this could be changed to a user having to make a choice. Using the code we currently have currently  and using this database design this change has less impact compared to the alternative. Beisdes Besides the change having less of an impact we can also make the adding process smoother since a user wouldn't have to choose from all the possible graphs but only from the graphs that make sense for this sensor. Lastly, we are able to make some query's faster and more compact this way.

table 11: design decision database


Decision 4Description
Problem/issueWhen adding a gauge graph to the database the settings need to be set as well such as its min and max value.
Decision

Adding the GaugeSettings table to the database.

Alternatives
  1. Using the same settings for all the gauges.
Arguments

We decided to add a specific table for the settings of the gauge since these can be very different. The other option would have been to use all the same settings. These settings would for example have been min: 0 max:100 and every value would probably be calculated to a percentage. Using this system it is fully customizable, there are no additional calculations and the zones (green yellow and red) can be set and customized using this. For example one gauge might need a red zone from 90 - 100 whilst another already starts at 50. It is some extra data to fetch from the database but it is still faster than calculating every value multiple times a second. Besides that the data in the gauge would be more reliable.

table 12: design decision database

Security decisions

Regterschot indicated we do not have to worry too much about security yet, as they want to have a functional web application first. Therefore we are only implementing security measures for very high security risk scenarios.. Because of this we have chosen to hash the password, we . We do this because we are legally obliged to do. In addition to this, we have chosen to use a Json Web Token. We do this to ensure that unwanted people can not cannot make calls to the API and only retrieve the data through the Web application. Further more Furthermore we have choosen to make use of prepared statements. This is done to prevent SQL injections from happening. The prevention of SQL injections is implemented because it is seen as a very high security risk.

...