
CREATE TABLE "Restaurant" (
	"ResID" INTEGER, 
	"ResName" VARCHAR(100), 
	"Address" VARCHAR(100), 
	"Rating" INTEGER, 
	PRIMARY KEY ("ResID")
)


CREATE TABLE "Restaurant_Type" (
	"ResTypeID" INTEGER, 
	"ResTypeName" VARCHAR(40), 
	"ResTypeDescription" VARCHAR(100), 
	PRIMARY KEY ("ResTypeID")
)


CREATE TABLE "Student" (
	"StuID" INTEGER, 
	"LName" VARCHAR(12), 
	"Fname" VARCHAR(12), 
	"Age" INTEGER, 
	"Sex" VARCHAR(1), 
	"Major" INTEGER, 
	"Advisor" INTEGER, 
	city_code VARCHAR(3), 
	PRIMARY KEY ("StuID")
)


CREATE TABLE "Type_Of_Restaurant" (
	"ResID" INTEGER, 
	"ResTypeID" INTEGER, 
	FOREIGN KEY("ResID") REFERENCES "Restaurant" ("ResID"), 
	FOREIGN KEY("ResTypeID") REFERENCES "Restaurant_Type" ("ResTypeID")
)


CREATE TABLE "Visits_Restaurant" (
	"StuID" INTEGER, 
	"ResID" INTEGER, 
	"Time" TIMESTAMP, 
	"Spent" FLOAT, 
	FOREIGN KEY("StuID") REFERENCES "Student" ("StuID"), 
	FOREIGN KEY("ResID") REFERENCES "Restaurant" ("ResID")
)

CREATE TABLE "Restaurant" (
	"ResID" INTEGER, 
	"ResName" VARCHAR(100), 
	"Address" VARCHAR(100), 
	"Rating" INTEGER, 
	PRIMARY KEY ("ResID")
)

/*
2 rows from Restaurant table:
ResID	ResName	Address	Rating
1	Subway	3233 St Paul St, Baltimore, MD 21218	3
2	Honeygrow	3212 St Paul St, Baltimore, MD 21218	4
*/


CREATE TABLE "Restaurant_Type" (
	"ResTypeID" INTEGER, 
	"ResTypeName" VARCHAR(40), 
	"ResTypeDescription" VARCHAR(100), 
	PRIMARY KEY ("ResTypeID")
)

/*
2 rows from Restaurant_Type table:
ResTypeID	ResTypeName	ResTypeDescription
1	Sandwich	Simplest there is.
2	Stir-fry	Classic Chinese cooking.
*/


CREATE TABLE "Student" (
	"StuID" INTEGER, 
	"LName" VARCHAR(12), 
	"Fname" VARCHAR(12), 
	"Age" INTEGER, 
	"Sex" VARCHAR(1), 
	"Major" INTEGER, 
	"Advisor" INTEGER, 
	city_code VARCHAR(3), 
	PRIMARY KEY ("StuID")
)

/*
2 rows from Student table:
StuID	LName	Fname	Age	Sex	Major	Advisor	city_code
1001	Smith	Linda	18	F	600	1121	BAL
1002	Kim	Tracy	19	F	600	7712	HKG
*/


CREATE TABLE "Type_Of_Restaurant" (
	"ResID" INTEGER, 
	"ResTypeID" INTEGER, 
	FOREIGN KEY("ResID") REFERENCES "Restaurant" ("ResID"), 
	FOREIGN KEY("ResTypeID") REFERENCES "Restaurant_Type" ("ResTypeID")
)

/*
2 rows from Type_Of_Restaurant table:
ResID	ResTypeID
1	1
2	2
*/


CREATE TABLE "Visits_Restaurant" (
	"StuID" INTEGER, 
	"ResID" INTEGER, 
	"Time" TIMESTAMP, 
	"Spent" FLOAT, 
	FOREIGN KEY("StuID") REFERENCES "Student" ("StuID"), 
	FOREIGN KEY("ResID") REFERENCES "Restaurant" ("ResID")
)

/*
2 rows from Visits_Restaurant table:
StuID	ResID	Time	Spent
1001	1	2017-10-09 18:15:00	6.53
1032	2	2017-10-08 13:00:30	13.2
*/
What is the description of the restaurant type Sandwich?
SELECT ResTypeDescription FROM Restaurant_Type WHERE ResTypeName = "Sandwich";
[{'ResTypeDescription': 'Simplest there is.'}]