Versions Compared

Key

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

Create scripts

User table

 CREATE TABLE User(
  UserID INT NOT NULL,
  Username varchar(255) NOT NULL,
  Password varchar(255) NOT NULL,
  Role varchar(255) NULL,
  PRIMARY KEY (UserID));

UserTabs table

CREATE TABLE UserTabs (
  UserID INT NOT NULL,
  TabID INT NOT NULL,
  PRIMARY KEY (UserID));

...

CREATE TABLE DriverRaces (
  RaceID INT NOT NULL,
  DriverID INT NOT NULL,
  RoundID INT NOT NULL,
  PRIMARY KEY (RaceID, DriverID, RoundID)
);

Driver table

CREATE TABLE Driver (
  DriverID INT NOT NULL,
  Drivername varchar(255) NOT NULL,
  PRIMARY KEY (DriverID));

Rounds table

CREATE TABLE Rounds (
  RoundNumber INT NOT NULL,
  RaceID INT NOT NULL,
  TimestampBegin DATETIME,
  TimestampEnd DATETIME,
  PRIMARY KEY (RoundNumber, RaceID)
  );

TabGraphs table

CREATE TABLE TabGraphs (
  TabID INT NOT NULL,
  GraphID INT NOT NULL,
  PRIMARY KEY (TabID)
  );

Tabs table

  CREATE TABLE Tabs (
  TabID INT NOT NULL,
  TabName varchar(255) NOT NULL,
  RaceID INT NOT NULL,
  PRIMARY KEY (TabID)
  );

Graphs table

CREATE TABLE Graphs(
  GraphID INT NOT NULL,
  Type varchar(255) NOT NULL,
  SensorID INT NOT NULL,
  PRIMARY KEY (GraphID));

Sensors table

CREATE TABLE Sensors(
  SensorID INT NOT NULL,
  SensorName varchar(255) NOT NULL,
  PRIMARY KEY (SensorID));

WheelspeedSensor table

CREATE TABLE WheelspeedSensor(
  WheelspeedSensorID INT NOT NULL,
  Timestamp DATETIME NULL,
  RPM float NULL,
  PRIMARY KEY (WheelspeedSensorID));

Foreign key scripts

DriverRaces DriverID to DiverID 

  Alter TABLE DriverRaces
  ADD CONSTRAINT FK_DriversRacesID FOREIGN KEY (DriverID) REFERENCES Driver(DriverID);

DriverRaces RoundID to RoundNumber

Alter TABLE DriverRaces
  ADD CONSTRAINT FK_RoundDriverRaces FOREIGN KEY (RoundID) REFERENCES Rounds(RoundNumber);

DriverRaces RaceID to RaceID

Alter TABLE DriverRaces
ADD CONSTRAINT FK_RaceDriversID FOREIGN KEY (RaceID) REFERENCES Race(RaceID);