{"circuits": {"columns": [[0, "circuitId", "INTEGER", 0, null, 1], [1, "circuitRef", "TEXT", 0, null, 0], [2, "name", "TEXT", 0, null, 0], [3, "location", "TEXT", 0, null, 0], [4, "country", "TEXT", 0, null, 0], [5, "lat", "REAL", 0, null, 0], [6, "lng", "REAL", 0, null, 0], [7, "alt", "TEXT", 0, null, 0], [8, "url", "TEXT", 0, null, 0]], "primary_keys": ["circuitId"], "foreign_keys": [], "unique_constraints": [], "check_constraints": []}, "races": {"columns": [[0, "raceId", "INTEGER", 0, null, 1], [1, "year", "INTEGER", 0, null, 0], [2, "round", "INTEGER", 0, null, 0], [3, "circuitId", "INTEGER", 0, null, 0], [4, "name", "TEXT", 0, null, 0], [5, "date", "TEXT", 0, null, 0], [6, "time", "TEXT", 0, null, 0], [7, "url", "TEXT", 0, null, 0]], "primary_keys": ["raceId"], "foreign_keys": [[0, 0, "circuits", "circuitId", "circuitId", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [], "check_constraints": []}, "drivers": {"columns": [[0, "driverId", "INTEGER", 0, null, 1], [1, "driverRef", "TEXT", 0, null, 0], [2, "number", "TEXT", 0, null, 0], [3, "code", "TEXT", 0, null, 0], [4, "forename", "TEXT", 0, null, 0], [5, "surname", "TEXT", 0, null, 0], [6, "dob", "TEXT", 0, null, 0], [7, "nationality", "TEXT", 0, null, 0], [8, "url", "TEXT", 0, null, 0]], "primary_keys": ["driverId"], "foreign_keys": [], "unique_constraints": [], "check_constraints": []}, "status": {"columns": [[0, "statusId", "INTEGER", 0, null, 1], [1, "status", "TEXT", 0, null, 0]], "primary_keys": ["statusId"], "foreign_keys": [], "unique_constraints": [], "check_constraints": []}, "seasons": {"columns": [[0, "year", "INTEGER", 0, null, 1], [1, "url", "TEXT", 0, null, 0]], "primary_keys": ["year"], "foreign_keys": [], "unique_constraints": [], "check_constraints": []}, "constructors": {"columns": [[0, "constructorId", "INTEGER", 0, null, 1], [1, "constructorRef", "TEXT", 0, null, 0], [2, "name", "TEXT", 0, null, 0], [3, "nationality", "TEXT", 0, null, 0], [4, "url", "TEXT", 0, null, 0]], "primary_keys": ["constructorId"], "foreign_keys": [], "unique_constraints": [], "check_constraints": []}, "constructorStandings": {"columns": [[0, "constructorStandingsId", "INTEGER", 0, null, 1], [1, "raceId", "INTEGER", 0, null, 0], [2, "constructorId", "INTEGER", 0, null, 0], [3, "points", "REAL", 0, null, 0], [4, "position", "INTEGER", 0, null, 0], [5, "positionText", "TEXT", 0, null, 0], [6, "wins", "INTEGER", 0, null, 0]], "primary_keys": ["constructorStandingsId"], "foreign_keys": [[0, 0, "races", "raceId", "raceId", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "constructors", "constructorId", "constructorId", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [], "check_constraints": []}, "results": {"columns": [[0, "resultId", "INTEGER", 0, null, 1], [1, "raceId", "INTEGER", 0, null, 0], [2, "driverId", "INTEGER", 0, null, 0], [3, "constructorId", "INTEGER", 0, null, 0], [4, "number", "INTEGER", 0, null, 0], [5, "grid", "INTEGER", 0, null, 0], [6, "position", "TEXT", 0, null, 0], [7, "positionText", "TEXT", 0, null, 0], [8, "positionOrder", "INTEGER", 0, null, 0], [9, "points", "REAL", 0, null, 0], [10, "laps", "TEXT", 0, null, 0], [11, "time", "TEXT", 0, null, 0], [12, "milliseconds", "TEXT", 0, null, 0], [13, "fastestLap", "TEXT", 0, null, 0], [14, "rank", "TEXT", 0, null, 0], [15, "fastestLapTime", "TEXT", 0, null, 0], [16, "fastestLapSpeed", "TEXT", 0, null, 0], [17, "statusId", "INTEGER", 0, null, 0]], "primary_keys": ["resultId"], "foreign_keys": [[0, 0, "drivers", "driverId", "driverId", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "races", "raceId", "raceId", "NO ACTION", "NO ACTION", "NONE"], [2, 0, "constructors", "constructorId", "constructorId", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [], "check_constraints": []}, "driverStandings": {"columns": [[0, "driverStandingsId", "INTEGER", 0, null, 1], [1, "raceId", "INTEGER", 0, null, 0], [2, "driverId", "INTEGER", 0, null, 0], [3, "points", "REAL", 0, null, 0], [4, "position", "INTEGER", 0, null, 0], [5, "positionText", "TEXT", 0, null, 0], [6, "wins", "INTEGER", 0, null, 0]], "primary_keys": ["driverStandingsId"], "foreign_keys": [[0, 0, "drivers", "driverId", "driverId", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "races", "raceId", "raceId", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [], "check_constraints": []}, "constructorResults": {"columns": [[0, "constructorResultsId", "INTEGER", 0, null, 1], [1, "raceId", "INTEGER", 0, null, 0], [2, "constructorId", "INTEGER", 0, null, 0], [3, "points", "REAL", 0, null, 0], [4, "status", "TEXT", 0, null, 0]], "primary_keys": ["constructorResultsId"], "foreign_keys": [[0, 0, "races", "raceId", "raceId", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "constructors", "constructorId", "constructorId", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [], "check_constraints": []}, "qualifying": {"columns": [[0, "qualifyId", "INTEGER", 0, null, 1], [1, "raceId", "INTEGER", 0, null, 0], [2, "driverId", "INTEGER", 0, null, 0], [3, "constructorId", "INTEGER", 0, null, 0], [4, "number", "INTEGER", 0, null, 0], [5, "position", "INTEGER", 0, null, 0], [6, "q1", "TEXT", 0, null, 0], [7, "q2", "TEXT", 0, null, 0], [8, "q3", "TEXT", 0, null, 0]], "primary_keys": ["qualifyId"], "foreign_keys": [[0, 0, "drivers", "driverId", "driverId", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "races", "raceId", "raceId", "NO ACTION", "NO ACTION", "NONE"], [2, 0, "constructors", "constructorId", "constructorId", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [], "check_constraints": []}, "pitStops": {"columns": [[0, "raceId", "INTEGER", 0, null, 1], [1, "driverId", "INTEGER", 0, null, 2], [2, "stop", "INTEGER", 0, null, 3], [3, "lap", "INTEGER", 0, null, 0], [4, "time", "TEXT", 0, null, 0], [5, "duration", "TEXT", 0, null, 0], [6, "milliseconds", "INTEGER", 0, null, 0]], "primary_keys": ["raceId", "driverId", "stop"], "foreign_keys": [[0, 0, "drivers", "driverId", "driverId", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "races", "raceId", "raceId", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "raceId"], [1, 1, "driverId"], [2, 2, "stop"]]], "check_constraints": []}, "lapTimes": {"columns": [[0, "raceId", "INTEGER", 0, null, 1], [1, "driverId", "INTEGER", 0, null, 2], [2, "lap", "INTEGER", 0, null, 3], [3, "position", "INTEGER", 0, null, 0], [4, "time", "TEXT", 0, null, 0], [5, "milliseconds", "INTEGER", 0, null, 0]], "primary_keys": ["raceId", "driverId", "lap"], "foreign_keys": [[0, 0, "drivers", "driverId", "driverId", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "races", "raceId", "raceId", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "raceId"], [1, 1, "driverId"], [2, 2, "lap"]]], "check_constraints": []}}
CREATE TABLE circuits (
    circuitId INTEGER   PRIMARY KEY,
    circuitRef TEXT,
    name TEXT,
    location TEXT,
    country TEXT,
    lat REAL,
    lng REAL,
    alt TEXT,
    url TEXT
);

CREATE TABLE races (
    raceId INTEGER   PRIMARY KEY,
    year INTEGER,
    round INTEGER,
    circuitId INTEGER,
    name TEXT,
    date TEXT,
    time TEXT,
    url TEXT,
    FOREIGN KEY (circuitId) REFERENCES circuits(circuitId)
);

CREATE TABLE drivers (
    driverId INTEGER   PRIMARY KEY,
    driverRef TEXT,
    number TEXT,
    code TEXT,
    forename TEXT,
    surname TEXT,
    dob TEXT,
    nationality TEXT,
    url TEXT
);

CREATE TABLE status (
    statusId INTEGER   PRIMARY KEY,
    status TEXT
);

CREATE TABLE seasons (
    year INTEGER   PRIMARY KEY,
    url TEXT
);

CREATE TABLE constructors (
    constructorId INTEGER   PRIMARY KEY,
    constructorRef TEXT,
    name TEXT,
    nationality TEXT,
    url TEXT
);

CREATE TABLE constructorStandings (
    constructorStandingsId INTEGER   PRIMARY KEY,
    raceId INTEGER,
    constructorId INTEGER,
    points REAL,
    position INTEGER,
    positionText TEXT,
    wins INTEGER,
    FOREIGN KEY (raceId) REFERENCES races(raceId),
    FOREIGN KEY (constructorId) REFERENCES constructors(constructorId)
);

CREATE TABLE results (
    resultId INTEGER   PRIMARY KEY,
    raceId INTEGER,
    driverId INTEGER,
    constructorId INTEGER,
    number INTEGER,
    grid INTEGER,
    position TEXT,
    positionText TEXT,
    positionOrder INTEGER,
    points REAL,
    laps TEXT,
    time TEXT,
    milliseconds TEXT,
    fastestLap TEXT,
    rank TEXT,
    fastestLapTime TEXT,
    fastestLapSpeed TEXT,
    statusId INTEGER,
    FOREIGN KEY (driverId) REFERENCES drivers(driverId),
    FOREIGN KEY (raceId) REFERENCES races(raceId),
    FOREIGN KEY (constructorId) REFERENCES constructors(constructorId)
);

CREATE TABLE driverStandings (
    driverStandingsId INTEGER   PRIMARY KEY,
    raceId INTEGER,
    driverId INTEGER,
    points REAL,
    position INTEGER,
    positionText TEXT,
    wins INTEGER,
    FOREIGN KEY (driverId) REFERENCES drivers(driverId),
    FOREIGN KEY (raceId) REFERENCES races(raceId)
);

CREATE TABLE constructorResults (
    constructorResultsId INTEGER   PRIMARY KEY,
    raceId INTEGER,
    constructorId INTEGER,
    points REAL,
    status TEXT,
    FOREIGN KEY (raceId) REFERENCES races(raceId),
    FOREIGN KEY (constructorId) REFERENCES constructors(constructorId)
);

CREATE TABLE qualifying (
    qualifyId INTEGER   PRIMARY KEY,
    raceId INTEGER,
    driverId INTEGER,
    constructorId INTEGER,
    number INTEGER,
    position INTEGER,
    q1 TEXT,
    q2 TEXT,
    q3 TEXT,
    FOREIGN KEY (driverId) REFERENCES drivers(driverId),
    FOREIGN KEY (raceId) REFERENCES races(raceId),
    FOREIGN KEY (constructorId) REFERENCES constructors(constructorId)
);

CREATE TABLE pitStops (
    raceId INTEGER   PRIMARY KEY,
    driverId INTEGER   PRIMARY KEY,
    stop INTEGER   PRIMARY KEY,
    lap INTEGER,
    time TEXT,
    duration TEXT,
    milliseconds INTEGER,
    PRIMARY KEY (raceId, driverId, stop),
    UNIQUE (raceId, driverId, stop),
    FOREIGN KEY (driverId) REFERENCES drivers(driverId),
    FOREIGN KEY (raceId) REFERENCES races(raceId)
);

CREATE TABLE lapTimes (
    raceId INTEGER   PRIMARY KEY,
    driverId INTEGER   PRIMARY KEY,
    lap INTEGER   PRIMARY KEY,
    position INTEGER,
    time TEXT,
    milliseconds INTEGER,
    PRIMARY KEY (raceId, driverId, lap),
    UNIQUE (raceId, driverId, lap),
    FOREIGN KEY (driverId) REFERENCES drivers(driverId),
    FOREIGN KEY (raceId) REFERENCES races(raceId)
);