Dludora/DAIL-BIRD huggingface dataset:
/* Given the following database schema: */
CREATE TABLE `businesses` (
  `business_id` INTEGER NOT NULL,
  `name` TEXT NOT NULL,
  `address` TEXT DEFAULT NULL,
  `city` TEXT DEFAULT NULL,
  `postal_code` TEXT DEFAULT NULL,
  `latitude` REAL DEFAULT NULL,
  `longitude` REAL DEFAULT NULL,
  `phone_number` INTEGER DEFAULT NULL,
  `tax_code` TEXT DEFAULT NULL,
  `business_certificate` INTEGER NOT NULL,
  `application_date` DATE DEFAULT NULL,
  `owner_name` TEXT NOT NULL,
  `owner_address` TEXT DEFAULT NULL,
  `owner_city` TEXT DEFAULT NULL,
  `owner_state` TEXT DEFAULT NULL,
  `owner_zip` TEXT DEFAULT NULL,
  PRIMARY KEY (`business_id`)
)

CREATE TABLE `inspections` (
  `business_id` INTEGER NOT NULL,
  `score` INTEGER DEFAULT NULL,
  `date` DATE NOT NULL,
  `type` TEXT NOT NULL,
  FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`)
)

CREATE TABLE `violations` (
  `business_id` INTEGER NOT NULL,
  `date` DATE NOT NULL,
  `violation_type_id` TEXT NOT NULL,
  `risk_category` TEXT NOT NULL,
  `description` TEXT NOT NULL,
  FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`)
)

/* Answer the following: What is the owner's name of the of the business that violates 103156 on June 12, 2014? business that violates 103156 on June 12, 2014 refers to business_id where violation_type_id = 103156 and date = '2014-06-12'; */
SELECT 
SELECT DISTINCT T2.owner_name FROM violations AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.violation_type_id = 103156 AND T1.`date` = '2014-06-12'
/* Given the following database schema: */
CREATE TABLE `businesses` (
  `business_id` INTEGER NOT NULL,
  `name` TEXT NOT NULL,
  `address` TEXT DEFAULT NULL,
  `city` TEXT DEFAULT NULL,
  `postal_code` TEXT DEFAULT NULL,
  `latitude` REAL DEFAULT NULL,
  `longitude` REAL DEFAULT NULL,
  `phone_number` INTEGER DEFAULT NULL,
  `tax_code` TEXT DEFAULT NULL,
  `business_certificate` INTEGER NOT NULL,
  `application_date` DATE DEFAULT NULL,
  `owner_name` TEXT NOT NULL,
  `owner_address` TEXT DEFAULT NULL,
  `owner_city` TEXT DEFAULT NULL,
  `owner_state` TEXT DEFAULT NULL,
  `owner_zip` TEXT DEFAULT NULL,
  PRIMARY KEY (`business_id`)
)

CREATE TABLE `inspections` (
  `business_id` INTEGER NOT NULL,
  `score` INTEGER DEFAULT NULL,
  `date` DATE NOT NULL,
  `type` TEXT NOT NULL,
  FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`)
)

CREATE TABLE `violations` (
  `business_id` INTEGER NOT NULL,
  `date` DATE NOT NULL,
  `violation_type_id` TEXT NOT NULL,
  `risk_category` TEXT NOT NULL,
  `description` TEXT NOT NULL,
  FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`)
)

/* Answer the following: In businesses with an owner address 500 California St, 2nd Floor of Silicon Valley, list the type of inspection of the business with the highest score. the highest score MAX(score); Silicon Valley is located in 'SAN FRANCISCO'; */
SELECT 
SELECT T1.type FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T2.owner_address = '500 California St, 2nd Floor' AND T2.owner_city = 'SAN FRANCISCO' ORDER BY T1.score DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE `businesses` (
  `business_id` INTEGER NOT NULL,
  `name` TEXT NOT NULL,
  `address` TEXT DEFAULT NULL,
  `city` TEXT DEFAULT NULL,
  `postal_code` TEXT DEFAULT NULL,
  `latitude` REAL DEFAULT NULL,
  `longitude` REAL DEFAULT NULL,
  `phone_number` INTEGER DEFAULT NULL,
  `tax_code` TEXT DEFAULT NULL,
  `business_certificate` INTEGER NOT NULL,
  `application_date` DATE DEFAULT NULL,
  `owner_name` TEXT NOT NULL,
  `owner_address` TEXT DEFAULT NULL,
  `owner_city` TEXT DEFAULT NULL,
  `owner_state` TEXT DEFAULT NULL,
  `owner_zip` TEXT DEFAULT NULL,
  PRIMARY KEY (`business_id`)
)

CREATE TABLE `inspections` (
  `business_id` INTEGER NOT NULL,
  `score` INTEGER DEFAULT NULL,
  `date` DATE NOT NULL,
  `type` TEXT NOT NULL,
  FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`)
)

CREATE TABLE `violations` (
  `business_id` INTEGER NOT NULL,
  `date` DATE NOT NULL,
  `violation_type_id` TEXT NOT NULL,
  `risk_category` TEXT NOT NULL,
  `description` TEXT NOT NULL,
  FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`)
)

/* Answer the following: Among the violations in 2016, how many of them have unscheduled inspections? unscheduled inspections refer to type = 'Routine - Unschedule'; year(date) = 2016; */
SELECT 
SELECT COUNT(T2.business_id) FROM violations AS T1 INNER JOIN inspections AS T2 ON T1.business_id = T2.business_id WHERE STRFTIME('%Y', T1.`date`) = '2016' AND T2.type = 'Routine - Unscheduled'
/* Given the following database schema: */
CREATE TABLE `businesses` (
  `business_id` INTEGER NOT NULL,
  `name` TEXT NOT NULL,
  `address` TEXT DEFAULT NULL,
  `city` TEXT DEFAULT NULL,
  `postal_code` TEXT DEFAULT NULL,
  `latitude` REAL DEFAULT NULL,
  `longitude` REAL DEFAULT NULL,
  `phone_number` INTEGER DEFAULT NULL,
  `tax_code` TEXT DEFAULT NULL,
  `business_certificate` INTEGER NOT NULL,
  `application_date` DATE DEFAULT NULL,
  `owner_name` TEXT NOT NULL,
  `owner_address` TEXT DEFAULT NULL,
  `owner_city` TEXT DEFAULT NULL,
  `owner_state` TEXT DEFAULT NULL,
  `owner_zip` TEXT DEFAULT NULL,
  PRIMARY KEY (`business_id`)
)

CREATE TABLE `inspections` (
  `business_id` INTEGER NOT NULL,
  `score` INTEGER DEFAULT NULL,
  `date` DATE NOT NULL,
  `type` TEXT NOT NULL,
  FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`)
)

CREATE TABLE `violations` (
  `business_id` INTEGER NOT NULL,
  `date` DATE NOT NULL,
  `violation_type_id` TEXT NOT NULL,
  `risk_category` TEXT NOT NULL,
  `description` TEXT NOT NULL,
  FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`)
)

/* Answer the following: List the business' name and risk category of businesses with a score greater than the 80% of average score of all businesses. score greater than the 80% of average score of all businesses refers to score > MULTIPLY(0.8, avg(score) from inspections); */
SELECT 
SELECT DISTINCT T1.name, T3.risk_category FROM businesses AS T1 INNER JOIN inspections AS T2 ON T1.business_id = T2.business_id INNER JOIN violations AS T3 ON T1.business_id = T3.business_id WHERE T2.score > 0.8 * ( SELECT AVG(score) FROM inspections )
/* Given the following database schema: */
CREATE TABLE `businesses` (
  `business_id` INTEGER NOT NULL,
  `name` TEXT NOT NULL,
  `address` TEXT DEFAULT NULL,
  `city` TEXT DEFAULT NULL,
  `postal_code` TEXT DEFAULT NULL,
  `latitude` REAL DEFAULT NULL,
  `longitude` REAL DEFAULT NULL,
  `phone_number` INTEGER DEFAULT NULL,
  `tax_code` TEXT DEFAULT NULL,
  `business_certificate` INTEGER NOT NULL,
  `application_date` DATE DEFAULT NULL,
  `owner_name` TEXT NOT NULL,
  `owner_address` TEXT DEFAULT NULL,
  `owner_city` TEXT DEFAULT NULL,
  `owner_state` TEXT DEFAULT NULL,
  `owner_zip` TEXT DEFAULT NULL,
  PRIMARY KEY (`business_id`)
)

CREATE TABLE `inspections` (
  `business_id` INTEGER NOT NULL,
  `score` INTEGER DEFAULT NULL,
  `date` DATE NOT NULL,
  `type` TEXT NOT NULL,
  FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`)
)

CREATE TABLE `violations` (
  `business_id` INTEGER NOT NULL,
  `date` DATE NOT NULL,
  `violation_type_id` TEXT NOT NULL,
  `risk_category` TEXT NOT NULL,
  `description` TEXT NOT NULL,
  FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`)
)

/* Answer the following: In businesses with a score lower than 95 and located around the postal code of 94110, what is the percentage of businesses with a risk category of low risk? DIVIDE(COUNT(business_id where risk_category = 'Low Risk', score < 95 and postal_code = 94110), COUNT(business_id where score < 95 and postal_code = 94110)) as percentage; */
SELECT 
SELECT CAST(SUM(CASE WHEN T1.risk_category = 'Low Risk' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.risk_category) FROM violations AS T1 INNER JOIN inspections AS T2 ON T1.business_id = T2.business_id INNER JOIN businesses AS T3 ON T2.business_id = T3.business_id WHERE T2.score < 95 AND T3.postal_code = 94110
/* Given the following database schema: */
CREATE TABLE breweries
(
    id    INTEGER          not null
        primary key,
    name  TEXT null,
    city  TEXT null,
    state TEXT null
)

CREATE TABLE "beers"
(
    id         INTEGER not null
        primary key,
    brewery_id INTEGER not null
        constraint beers_ibfk_1
            references breweries,
    abv        REAL,
    ibu        REAL,
    name       TEXT    not null,
    style      TEXT,
    ounces     REAL    not null
)

/* Answer the following: Which distinct state makes beer that has the least amount of bitterness? */
SELECT 
SELECT DISTINCT T2.state, T1.ibu FROM beers AS T1 INNER JOIN breweries AS T2 ON T1.brewery_id = T2.id WHERE T1.ibu IS NOT NULL AND T1.ibu = ( SELECT MIN(ibu) FROM beers )
/* Given the following database schema: */
CREATE TABLE breweries
(
    id    INTEGER          not null
        primary key,
    name  TEXT null,
    city  TEXT null,
    state TEXT null
)

CREATE TABLE "beers"
(
    id         INTEGER not null
        primary key,
    brewery_id INTEGER not null
        constraint beers_ibfk_1
            references breweries,
    abv        REAL,
    ibu        REAL,
    name       TEXT    not null,
    style      TEXT,
    ounces     REAL    not null
)

/* Answer the following: Where in New York can you locate the brewery that makes the bitterest beer? List both the brewery's name and the name of the city. The more IBU, the more bitter the beer is, bitterest means highest IBU. */
SELECT 
SELECT T2.name, T2.city FROM beers AS T1 INNER JOIN breweries AS T2 ON T1.brewery_id = T2.id WHERE T2.state = 'NY' ORDER BY T1.ibu DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE breweries
(
    id    INTEGER          not null
        primary key,
    name  TEXT null,
    city  TEXT null,
    state TEXT null
)

CREATE TABLE "beers"
(
    id         INTEGER not null
        primary key,
    brewery_id INTEGER not null
        constraint beers_ibfk_1
            references breweries,
    abv        REAL,
    ibu        REAL,
    name       TEXT    not null,
    style      TEXT,
    ounces     REAL    not null
)

/* Answer the following: What is the average alcohol content per 12-ounce beer bottle produced by Boston Beer Company? */
SELECT 
SELECT AVG(T1.abv) FROM beers AS T1 INNER JOIN breweries AS T2 ON T1.brewery_id = T2.id WHERE T2.name = 'Boston Beer Company' AND T1.ounces = 12
/* Given the following database schema: */
CREATE TABLE breweries
(
    id    INTEGER          not null
        primary key,
    name  TEXT null,
    city  TEXT null,
    state TEXT null
)

CREATE TABLE "beers"
(
    id         INTEGER not null
        primary key,
    brewery_id INTEGER not null
        constraint beers_ibfk_1
            references breweries,
    abv        REAL,
    ibu        REAL,
    name       TEXT    not null,
    style      TEXT,
    ounces     REAL    not null
)

/* Answer the following: Of all the beer styles produced by Stevens Point Brewery, how many percent do they allot for American Adjunct Lager? Percent allotted = count(American Adjunct Lager beer styles) / count(styles) * 100% */
SELECT 
SELECT CAST(SUM(IIF(T1.style = 'American Adjunct Lager', 1, 0)) AS REAL) * 100 / COUNT(T1.brewery_id) FROM beers AS T1 INNER JOIN breweries AS T2 ON T1.brewery_id = T2.id WHERE T2.name = 'Stevens Point Brewery'
/* Given the following database schema: */
CREATE TABLE breweries
(
    id    INTEGER          not null
        primary key,
    name  TEXT null,
    city  TEXT null,
    state TEXT null
)

CREATE TABLE "beers"
(
    id         INTEGER not null
        primary key,
    brewery_id INTEGER not null
        constraint beers_ibfk_1
            references breweries,
    abv        REAL,
    ibu        REAL,
    name       TEXT    not null,
    style      TEXT,
    ounces     REAL    not null
)

/* Answer the following: Which city and state produces the most and least bitter beer, and what is the difference in bitterness between the two? List also the names of the beer. The more IBU, the more bitter the beer is, most bitter means highest IBU; The less IBU, the less bitter the beer is, least bitter means lowest IBU */
SELECT 
SELECT T1.state, T1.city, T2.name, T2.ibu FROM breweries AS T1 INNER JOIN beers AS T2 ON T1.id = T2.brewery_id GROUP BY T1.state, T1.city, T2.name, T2.ibu HAVING MAX(ibu) AND MIN(ibu) LIMIT 2
/* Given the following database schema: */
CREATE TABLE breweries
(
    id    INTEGER          not null
        primary key,
    name  TEXT null,
    city  TEXT null,
    state TEXT null
)

CREATE TABLE "beers"
(
    id         INTEGER not null
        primary key,
    brewery_id INTEGER not null
        constraint beers_ibfk_1
            references breweries,
    abv        REAL,
    ibu        REAL,
    name       TEXT    not null,
    style      TEXT,
    ounces     REAL    not null
)

/* Answer the following: When compared to the total number of breweries in the US producing American Blonde Ale, how many in the state of Wisconsin produces American Blonde Ale? Indicate your answer in percentage (%). Percentage of the state of Wisconsin produces American Blonde Ale could be computed by count(breweries in Wisconsin producing American Blonde Ale) / count(all breweries) */
SELECT 
SELECT CAST(SUM(IIF(T2.state = 'WI', 1, 0)) AS REAL) * 100 / COUNT(T1.id) FROM beers AS T1 INNER JOIN breweries AS T2 ON T1.brewery_id = T2.id WHERE T1.style = 'American Blonde Ale'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: What is the title of the recipe that is most likely to gain weight? most likely to gain weight refers to MAX(total_fat) */
SELECT 
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id ORDER BY T2.total_fat DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: What is the unsaturated fat content in the recipe "Raspberry Chiffon Pie"? Raspberry Chiffon Pie refers to title; unsaturated fat refers to SUBTRACT(total_fat, sat_fat) */
SELECT 
SELECT T2.total_fat - T2.sat_fat FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Raspberry Chiffon Pie'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Please list the titles of all the recipes that are salt/sodium-free. salt/sodium-free refers to sodium < 5 */
SELECT 
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T2.sodium < 5
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Please list the titles of all the recipes that may lead to constipation, feeling sick or stomach pain. may lead to constipation, feeling sick or stomach pain refers to iron > 20 */
SELECT 
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T2.iron > 20
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Which recipe is more beneficial in wound healing, "Raspberry Chiffon Pie" or "Fresh Apricot Bavarian"? Raspberry Chiffon Pie and Fresh Apricot Bavarian are title; vitamin_c is higher refers to MAX(vitamin_c) */
SELECT 
SELECT DISTINCT CASE WHEN CASE WHEN T2.title = 'Raspberry Chiffon Pie' THEN T1.vitamin_c END > CASE WHEN T2.title = 'Fresh Apricot Bavarian' THEN T1.vitamin_c END THEN 'Raspberry Chiffon Pie' ELSE 'Fresh Apricot Bavarian' END AS "vitamin_c is higher" FROM Nutrition T1 INNER JOIN Recipe T2 ON T2.recipe_id = T1.recipe_id
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Among the recipes that take more than 10 minutes to prepare, what is the title of the one with the most calories? more than 10 minutes to prepare refers to prep_min > 10; the most calories refers to MAX(calories) */
SELECT 
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.prep_min > 10 ORDER BY T2.calories DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How many calories does the recipe "Raspberry Chiffon Pie" contain? Raspberry Chiffon Pie refers to title */
SELECT 
SELECT T2.calories FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Raspberry Chiffon Pie'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Is the ingredient "graham cracker crumbs" optional in the recipe "Raspberry Chiffon Pie"? 'graham cracker crumbs' is a name of an ingredient; 'Raspberry Chiffon Pie' refers to title */
SELECT 
SELECT T2.optional FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T1.title = 'Raspberry Chiffon Pie' AND T3.name = 'graham cracker crumbs'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How many ingredients must be rationed in the recipe "Raspberry Chiffon Pie"? Raspberry Chiffon Pie refers to title; ingredient must be rationed refers to max_qty = min_qty */
SELECT 
SELECT COUNT(*) FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Raspberry Chiffon Pie' AND T2.max_qty = T2.min_qty
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Please list the names of all the ingredients needed for the recipe "Raspberry Chiffon Pie" that do not need preprocessing. Raspberry Chiffon Pie refers to title; do not need preprocessing refers to preparation IS NULL */
SELECT 
SELECT T3.name FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T1.title = 'Raspberry Chiffon Pie' AND T2.preparation IS NULL
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How many recipes include the ingredient "graham cracker crumbs"? 'graham cracker crumbs' is a name of an ingredient */
SELECT 
SELECT COUNT(*) FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id WHERE T1.name = 'graham cracker crumbs'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: At least how many cups of graham cracker crumbs does the recipe "Raspberry Chiffon Pie" need? 'graham cracker crumbs' is a name of an ingredient; 'Raspberry Chiffon Pie' refers to title */
SELECT 
SELECT T2.min_qty FROM Recipe AS T1 INNER JOIN Quantity AS T2 ON T1.recipe_id = T2.recipe_id INNER JOIN Ingredient AS T3 ON T3.ingredient_id = T2.ingredient_id WHERE T1.title = 'Raspberry Chiffon Pie' AND T3.name = 'graham cracker crumbs'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How many calories from fat are there in the recipe "Raspberry Chiffon Pie"? calories from fat refers to MULTIPLY(calories, pcnt_cal_fat)||'%; Raspberry Chiffon Pie refers to title */
SELECT 
SELECT T2.calories * T2.pcnt_cal_fat FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Raspberry Chiffon Pie'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How many calories on average does a recipe that comes from "Produce for Better Health Foundation and 5 a Day" contain? Produce for Better Health Foundation and 5 a Day is a source of recipe; calculation = DIVIDE(SUM(calories), COUNT(recipe_id)) */
SELECT 
SELECT AVG(T2.calories) FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.source = 'Produce for Better Health Foundation and 5 a Day'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How many calories does the turkey tenderloin bundles recipe have? turkey tenderloin refers to title */
SELECT 
SELECT T2.calories FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id WHERE T1.title = 'Turkey Tenderloin Bundles'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How many cups of 1% lowfat milk should be added to no.1436 recipe? 1% lowfat milk is a name of an ingredient; no.1436 recipe refers to recipe_id = 1436; max_qty = min_qty */
SELECT 
SELECT COUNT(*) FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id WHERE T1.name = '1% lowfat milk' AND T2.unit = 'cup(s)' AND T2.recipe_id = 1436
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: Which recipe in the database contains the most total fat? Give its title. the most total fat refers to MAX(total_fat) */
SELECT 
SELECT T1.title FROM Recipe AS T1 INNER JOIN Nutrition AS T2 ON T1.recipe_id = T2.recipe_id ORDER BY T2.total_fat DESC LIMIT 1
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: How many times do seedless red grapes appear in the recipes? seedless red grapes is a name of an ingredient */
SELECT 
SELECT COUNT(*) FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id WHERE T1.name = 'seedless red grapes'
/* Given the following database schema: */
CREATE TABLE Ingredient
(
    ingredient_id INTEGER
            primary key,
    category      TEXT,
    name          TEXT,
    plural        TEXT
)

CREATE TABLE Recipe
(
    recipe_id  INTEGER
            primary key,
    title      TEXT,
    subtitle   TEXT,
    servings   INTEGER,
    yield_unit TEXT,
    prep_min   INTEGER,
    cook_min   INTEGER,
    stnd_min   INTEGER,
    source     TEXT,
    intro      TEXT,
    directions TEXT
)

CREATE TABLE Nutrition
(
    recipe_id     INTEGER
            primary key,
    protein       REAL,
    carbo         REAL,
    alcohol       REAL,
    total_fat     REAL,
    sat_fat       REAL,
    cholestrl     REAL,
    sodium        REAL,
    iron          REAL,
    vitamin_c     REAL,
    vitamin_a     REAL,
    fiber         REAL,
    pcnt_cal_carb REAL,
    pcnt_cal_fat  REAL,
    pcnt_cal_prot REAL,
    calories      REAL,
    foreign key (recipe_id) references Recipe(recipe_id)
)

CREATE TABLE Quantity
(
    quantity_id   INTEGER
            primary key,
    recipe_id     INTEGER,
    ingredient_id INTEGER,
    max_qty       REAL,
    min_qty       REAL,
    unit          TEXT,
    preparation   TEXT,
    optional      TEXT,
    foreign key (recipe_id) references Recipe(recipe_id),
    foreign key (ingredient_id) references Ingredient(ingredient_id),
    foreign key (recipe_id) references Nutrition(recipe_id)
)

/* Answer the following: State the name of the optional ingredient of no.1397 recipe. no.1397 recipe refers to recipe_id = 1397; optional ingredient refers to optional = 'TRUE' */
SELECT 
SELECT T1.name FROM Ingredient AS T1 INNER JOIN Quantity AS T2 ON T1.ingredient_id = T2.ingredient_id WHERE T2.recipe_id = 1397 AND T2.optional = 'TRUE'