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


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


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


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


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


CREATE TABLE circuits (
	"circuitId" INTEGER, 
	"circuitRef" TEXT, 
	name TEXT, 
	location TEXT, 
	country TEXT, 
	lat REAL, 
	lng REAL, 
	alt TEXT, 
	url TEXT, 
	PRIMARY KEY ("circuitId")
)


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


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


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


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


CREATE TABLE results (
	"resultId" INTEGER, 
	"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, 
	PRIMARY KEY ("resultId"), 
	FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId"), 
	FOREIGN KEY("raceId") REFERENCES races ("raceId"), 
	FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)


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


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

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

/*
2 rows from constructorResults table:
constructorResultsId	raceId	constructorId	points	status
1	18	1	14.0	NULL
2	18	2	8.0	NULL
*/


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

/*
2 rows from constructorStandings table:
constructorStandingsId	raceId	constructorId	points	position	positionText	wins
1	18	1	14.0	1	1	1
2	18	2	8.0	3	3	0
*/


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

/*
2 rows from driverStandings table:
driverStandingsId	raceId	driverId	points	position	positionText	wins
1	18	1	10.0	1	1	1
2	18	2	8.0	2	2	0
*/


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

/*
2 rows from lapTimes table:
raceId	driverId	lap	position	time	milliseconds

*/


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

/*
2 rows from pitStops table:
raceId	driverId	stop	lap	time	duration	milliseconds

*/


CREATE TABLE circuits (
	"circuitId" INTEGER, 
	"circuitRef" TEXT, 
	name TEXT, 
	location TEXT, 
	country TEXT, 
	lat REAL, 
	lng REAL, 
	alt TEXT, 
	url TEXT, 
	PRIMARY KEY ("circuitId")
)

/*
2 rows from circuits table:
circuitId	circuitRef	name	location	country	lat	lng	alt	url
1	albert_park	Albert Park Grand Prix Circuit	Melbourne	Australia	-37.8497	144.968	10	http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2	sepang	Sepang International Circuit	Kuala Lumpur	Malaysia	2.76083	101.738		http://en.wikipedia.org/wiki/Sepang_International_Circuit
*/


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

/*
2 rows from constructors table:
constructorId	constructorRef	name	nationality	url
1	mclaren	McLaren	British	http://en.wikipedia.org/wiki/McLaren
2	bmw_sauber	BMW Sauber	German	http://en.wikipedia.org/wiki/BMW_Sauber
*/


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

/*
2 rows from drivers table:
driverId	driverRef	number	code	forename	surname	dob	nationality	url
1	hamilton	44	HAM	Lewis	Hamilton	07/01/1985	British	http://en.wikipedia.org/wiki/Lewis_Hamilton
2	heidfeld		HEI	Nick	Heidfeld	10/05/1977	German	http://en.wikipedia.org/wiki/Nick_Heidfeld
*/


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

/*
2 rows from qualifying table:
qualifyId	raceId	driverId	constructorId	number	position	q1	q2	q3
1	18	1	1	22	1	1:26.572	1:25.187	1:26.714
2	18	9	2	4	2	1:26.103	1:25.315	1:26.869
*/


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

/*
2 rows from races table:
raceId	year	round	circuitId	name	date	time	url
1	2009	1	1	Australian Grand Prix	2009-03-29	06:00:00	http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2	2009	2	2	Malaysian Grand Prix	2009-04-05	09:00:00	http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
*/


CREATE TABLE results (
	"resultId" INTEGER, 
	"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, 
	PRIMARY KEY ("resultId"), 
	FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId"), 
	FOREIGN KEY("raceId") REFERENCES races ("raceId"), 
	FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)

/*
2 rows from results table:
resultId	raceId	driverId	constructorId	number	grid	position	positionText	positionOrder	points	laps	time	milliseconds	fastestLap	rank	fastestLapTime	fastestLapSpeed	statusId
1	18	1	1	22	1	1	1	1	10.0	58	34:50.6	5690616	39	2	01:27.5	218.3	1
2	18	2	2	3	5	2	2	2	8.0	58	5.478	5696094	41	3	01:27.7	217.586	1
*/


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

/*
2 rows from seasons table:
year	url
1950	http://en.wikipedia.org/wiki/1950_Formula_One_season
1951	http://en.wikipedia.org/wiki/1951_Formula_One_season
*/


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

/*
2 rows from status table:
statusId	status
1	Finished
2	Disqualified
*/
What is the name of the race that occurred most recently?
SELECT name FROM races ORDER BY date DESC LIMIT 1
[{'name': 'Abu Dhabi Grand Prix'}]