
CREATE TABLE "Movie" (
	"mID" INTEGER, 
	title TEXT, 
	year INTEGER, 
	director TEXT, 
	PRIMARY KEY ("mID")
)


CREATE TABLE "Rating" (
	"rID" INTEGER, 
	"mID" INTEGER, 
	stars INTEGER, 
	"ratingDate" DATE, 
	FOREIGN KEY("mID") REFERENCES "Movie" ("mID"), 
	FOREIGN KEY("rID") REFERENCES "Reviewer" ("rID")
)


CREATE TABLE "Reviewer" (
	"rID" INTEGER, 
	name TEXT, 
	PRIMARY KEY ("rID")
)

CREATE TABLE "Movie" (
	"mID" INTEGER, 
	title TEXT, 
	year INTEGER, 
	director TEXT, 
	PRIMARY KEY ("mID")
)

/*
2 rows from Movie table:
mID	title	year	director
101	Gone with the Wind	1939	Victor Fleming
102	Star Wars	1977	George Lucas
*/


CREATE TABLE "Rating" (
	"rID" INTEGER, 
	"mID" INTEGER, 
	stars INTEGER, 
	"ratingDate" DATE, 
	FOREIGN KEY("mID") REFERENCES "Movie" ("mID"), 
	FOREIGN KEY("rID") REFERENCES "Reviewer" ("rID")
)

/*
2 rows from Rating table:
rID	mID	stars	ratingDate
201	101	2	2011-01-22
201	101	4	2011-01-27
*/


CREATE TABLE "Reviewer" (
	"rID" INTEGER, 
	name TEXT, 
	PRIMARY KEY ("rID")
)

/*
2 rows from Reviewer table:
rID	name
201	Sarah Martinez
202	Daniel Lewis
*/
For each director, return the director's name together with the title of the movie they directed that received the highest rating among all of their movies, and the value of that rating. Ignore movies whose director is NULL.
SELECT T2.title ,  T1.stars ,  T2.director ,  max(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID  =  T2.mID WHERE director != "null" GROUP BY director
[{'title': 'Avatar', 'stars': 5, 'director': 'James Cameron', 'max(T1.stars)': 5}, {'title': 'The Sound of Music', 'stars': 3, 'director': 'Robert Wise', 'max(T1.stars)': 3}, {'title': 'Raiders of the Lost Ark', 'stars': 4, 'director': 'Steven Spielberg', 'max(T1.stars)': 4}, {'title': 'Gone with the Wind', 'stars': 4, 'director': 'Victor Fleming', 'max(T1.stars)': 4}]