summaryrefslogtreecommitdiff
path: root/import/01c_constraints.sql
blob: 08cefc71f1921f8fe197044b4df71ed30e256f4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-- Constraints for table constructorResults
ALTER TABLE constructorResults
   ADD CONSTRAINT constructorResults_ibfk_1 FOREIGN KEY (raceId) REFERENCES races (raceId) ON UPDATE CASCADE,
   ADD CONSTRAINT constructorResults_ibfk_2 FOREIGN KEY (constructorId) REFERENCES constructors (constructorId) ON UPDATE CASCADE;

-- Constraints for table constructorStandings
ALTER TABLE constructorStandings
   ADD CONSTRAINT constructorStandings_ibfk_1 FOREIGN KEY (raceId) REFERENCES races (raceId) ON UPDATE CASCADE,
   ADD CONSTRAINT constructorStandings_ibfk_2 FOREIGN KEY (constructorId) REFERENCES constructors (constructorId) ON UPDATE CASCADE;

-- Constraints for table driverStandings
ALTER TABLE driverStandings
   ADD CONSTRAINT driverStandings_ibfk_1 FOREIGN KEY (raceId) REFERENCES races (raceId) ON UPDATE CASCADE,
   ADD CONSTRAINT driverStandings_ibfk_2 FOREIGN KEY (driverId) REFERENCES drivers (driverId) ON UPDATE CASCADE;

-- Constraints for table lapTimes
ALTER TABLE lapTimes
   ADD CONSTRAINT lapTimes_ibfk_1 FOREIGN KEY (raceId) REFERENCES races (raceId) ON UPDATE CASCADE,
   ADD CONSTRAINT lapTimes_ibfk_2 FOREIGN KEY (driverId) REFERENCES drivers (driverId) ON UPDATE CASCADE;

-- Constraints for table pitStops
ALTER TABLE pitStops
   ADD CONSTRAINT pitStops_ibfk_1 FOREIGN KEY (raceId) REFERENCES races (raceId) ON UPDATE CASCADE,
   ADD CONSTRAINT pitStops_ibfk_2 FOREIGN KEY (driverId) REFERENCES drivers (driverId) ON UPDATE CASCADE;

-- Constraints for table qualifying
ALTER TABLE qualifying
   ADD CONSTRAINT qualifying_ibfk_1 FOREIGN KEY (raceId) REFERENCES races (raceId) ON UPDATE CASCADE,
   ADD CONSTRAINT qualifying_ibfk_2 FOREIGN KEY (driverId) REFERENCES drivers (driverId) ON UPDATE CASCADE,
   ADD CONSTRAINT qualifying_ibfk_3 FOREIGN KEY (constructorId) REFERENCES constructors (constructorId) ON UPDATE CASCADE;

-- Constraints for table races
ALTER TABLE races
   ADD CONSTRAINT races_ibfk_1 FOREIGN KEY (circuitId) REFERENCES circuits (circuitId);

-- Constraints for table results
ALTER TABLE results
   ADD CONSTRAINT results_ibfk_1 FOREIGN KEY (raceId) REFERENCES races (raceId) ON UPDATE CASCADE,
   ADD CONSTRAINT results_ibfk_2 FOREIGN KEY (driverId) REFERENCES drivers (driverId) ON UPDATE CASCADE,
   ADD CONSTRAINT results_ibfk_3 FOREIGN KEY (constructorId) REFERENCES constructors (constructorId) ON UPDATE CASCADE,
   ADD CONSTRAINT results_ibfk_4 FOREIGN KEY (statusId) REFERENCES status (statusId) ON UPDATE CASCADE;