| db_id
				 stringlengths 4 28 | question
				 stringlengths 34 304 | evidence
				 stringlengths 0 265 | SQL
				 stringlengths 39 449 | schema
				 stringlengths 352 37.3k | 
|---|---|---|---|---|
| 
	video_games | 
	List down at least five publishers of the games with number of sales less than 10000. | 
	publishers refers to publisher_name; number of sales less than 10000 refers to num_sales < 0.1; | 
	SELECT T.publisher_name FROM ( SELECT DISTINCT T5.publisher_name FROM region AS T1 INNER JOIN region_sales AS T2 ON T1.id = T2.region_id INNER JOIN game_platform AS T3 ON T2.game_platform_id = T3.id INNER JOIN game_publisher AS T4 ON T3.game_publisher_id = T4.id INNER JOIN publisher AS T5 ON T4.publisher_id = T5.id WHERE T1.region_name = 'North America' AND T2.num_sales * 100000 < 10000 LIMIT 5 ) t | 
	CREATE TABLE genre
(
    id         INTEGER not null
            primary key,
    genre_name TEXT default NULL
);
CREATE TABLE game
(
    id        INTEGER not null
            primary key,
    genre_id  INTEGER          default NULL,
    game_name TEXT default NULL,
    foreign key (genre_id) references genre(id)
);
CREATE TABLE platform
(
    id            INTEGER not null
            primary key,
    platform_name TEXT default NULL
);
CREATE TABLE publisher
(
    id             INTEGER not null
            primary key,
    publisher_name TEXT default NULL
);
CREATE TABLE game_publisher
(
    id           INTEGER not null
            primary key,
    game_id      INTEGER default NULL,
    publisher_id INTEGER default NULL,
    foreign key (game_id) references game(id),
    foreign key (publisher_id) references publisher(id)
);
CREATE TABLE game_platform
(
    id                INTEGER not null
            primary key,
    game_publisher_id INTEGER default NULL,
    platform_id       INTEGER default NULL,
    release_year      INTEGER default NULL,
    foreign key (game_publisher_id) references game_publisher(id),
    foreign key (platform_id) references platform(id)
);
CREATE TABLE region
(
    id          INTEGER not null
            primary key,
    region_name TEXT default NULL
);
CREATE TABLE region_sales
(
    region_id        INTEGER           default NULL,
    game_platform_id INTEGER           default NULL,
    num_sales        REAL default NULL,
    foreign key (game_platform_id) references game_platform(id),
    foreign key (region_id) references region(id)
);
 | 
| 
	retail_complains | 
	What is the full address of the customers who, having received a timely response from the company, have dispute about that response? | 
	full address = address_1, address_2; received a timely response refers to Timely response? = 'Yes'; have dispute refers to "Consumer disputed?" = 'Yes'; | 
	SELECT T1.address_1, T1.address_2 FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.`Timely response?` = 'Yes' AND T2.`Consumer disputed?` = 'Yes' | 
	CREATE TABLE state
(
    StateCode TEXT
        constraint state_pk
            primary key,
    State     TEXT,
    Region    TEXT
);
CREATE TABLE callcenterlogs
(
    "Date received" DATE,
    "Complaint ID"  TEXT,
    "rand client"   TEXT,
    phonefinal      TEXT,
    "vru+line"      TEXT,
    call_id         INTEGER,
    priority        INTEGER,
    type            TEXT,
    outcome         TEXT,
    server          TEXT,
    ser_start       TEXT,
    ser_exit        TEXT,
    ser_time        TEXT,
    primary key ("Complaint ID"),
    foreign key ("rand client") references client(client_id)
);
CREATE TABLE client
(
    client_id   TEXT
            primary key,
    sex         TEXT,
    day         INTEGER,
    month       INTEGER,
    year        INTEGER,
    age         INTEGER,
    social      TEXT,
    first       TEXT,
    middle      TEXT,
    last        TEXT,
    phone       TEXT,
    email       TEXT,
    address_1   TEXT,
    address_2   TEXT,
    city        TEXT,
    state       TEXT,
    zipcode     INTEGER,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
);
CREATE TABLE district
(
    district_id  INTEGER
            primary key,
    city         TEXT,
    state_abbrev TEXT,
    division     TEXT,
    foreign key (state_abbrev) references state(StateCode)
);
CREATE TABLE events
(
    "Date received"                DATE,
    Product                        TEXT,
    "Sub-product"                  TEXT,
    Issue                          TEXT,
    "Sub-issue"                    TEXT,
    "Consumer complaint narrative" TEXT,
    Tags                           TEXT,
    "Consumer consent provided?"   TEXT,
    "Submitted via"                TEXT,
    "Date sent to company"         TEXT,
    "Company response to consumer" TEXT,
    "Timely response?"             TEXT,
    "Consumer disputed?"           TEXT,
    "Complaint ID"                 TEXT,
    Client_ID                      TEXT,
    primary key ("Complaint ID", Client_ID),
    foreign key ("Complaint ID") references callcenterlogs("Complaint ID"),
    foreign key (Client_ID) references client(client_id)
);
CREATE TABLE reviews
(
    "Date"        DATE
            primary key,
    Stars       INTEGER,
    Reviews     TEXT,
    Product     TEXT,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
);
 | 
| 
	disney | 
	How many movies did Wolfgang Reitherman direct? | 
	Wolfgang Reitherman refers director = 'Wolfgang Reitherman'; | 
	SELECT COUNT(name) FROM director WHERE director = 'Wolfgang Reitherman' | 
	CREATE TABLE characters
(
    movie_title  TEXT
            primary key,
    release_date TEXT,
    hero         TEXT,
    villian      TEXT,
    song         TEXT,
    foreign key (hero) references "voice-actors"(character)
);
CREATE TABLE director
(
    name     TEXT
            primary key,
    director TEXT,
    foreign key (name) references characters(movie_title)
);
CREATE TABLE movies_total_gross
(
    movie_title              TEXT,
    release_date             TEXT,
    genre                    TEXT,
    MPAA_rating              TEXT,
    total_gross              TEXT,
    inflation_adjusted_gross TEXT,
    primary key (movie_title, release_date),
    foreign key (movie_title) references characters(movie_title)
);
CREATE TABLE revenue
(
    Year                              INTEGER
            primary key,
    "Studio Entertainment[NI 1]"      REAL,
    "Disney Consumer Products[NI 2]"  REAL,
    "Disney Interactive[NI 3][Rev 1]" INTEGER,
    "Walt Disney Parks and Resorts"   REAL,
    "Disney Media Networks"           TEXT,
    Total                             INTEGER
);
CREATE TABLE IF NOT EXISTS "voice-actors"
(
    character     TEXT
            primary key,
    "voice-actor" TEXT,
    movie         TEXT,
    foreign key (movie) references characters(movie_title)
);
 | 
| 
	legislator | 
	How many legislators are not senator? | 
	not senator refers to class is null; | 
	SELECT COUNT(bioguide) FROM `current-terms` WHERE class IS NULL | 
	CREATE TABLE current
(
    ballotpedia_id      TEXT,
    bioguide_id         TEXT,
    birthday_bio        DATE,
    cspan_id            REAL,
    fec_id              TEXT,
    first_name          TEXT,
    gender_bio          TEXT,
    google_entity_id_id TEXT,
    govtrack_id         INTEGER,
    house_history_id    REAL,
    icpsr_id            REAL,
    last_name           TEXT,
    lis_id              TEXT,
    maplight_id         REAL,
    middle_name         TEXT,
    nickname_name       TEXT,
    official_full_name  TEXT,
    opensecrets_id      TEXT,
    religion_bio        TEXT,
    suffix_name         TEXT,
    thomas_id           INTEGER,
    votesmart_id        REAL,
    wikidata_id         TEXT,
    wikipedia_id        TEXT,
        primary key (bioguide_id, cspan_id)
);
CREATE TABLE IF NOT EXISTS "current-terms"
(
    address            TEXT,
    bioguide           TEXT,
    caucus             TEXT,
    chamber            TEXT,
    class              REAL,
    contact_form       TEXT,
    district           REAL,
    end                TEXT,
    fax                TEXT,
    last               TEXT,
    name               TEXT,
    office             TEXT,
    party              TEXT,
    party_affiliations TEXT,
    phone              TEXT,
    relation           TEXT,
    rss_url            TEXT,
    start              TEXT,
    state              TEXT,
    state_rank         TEXT,
    title              TEXT,
    type               TEXT,
    url                TEXT,
    primary key (bioguide, end),
    foreign key (bioguide) references current(bioguide_id)
);
CREATE TABLE historical
(
    ballotpedia_id             TEXT,
    bioguide_id                TEXT
            primary key,
    bioguide_previous_id       TEXT,
    birthday_bio               TEXT,
    cspan_id                   TEXT,
    fec_id                     TEXT,
    first_name                 TEXT,
    gender_bio                 TEXT,
    google_entity_id_id        TEXT,
    govtrack_id                INTEGER,
    house_history_alternate_id TEXT,
    house_history_id           REAL,
    icpsr_id                   REAL,
    last_name                  TEXT,
    lis_id                     TEXT,
    maplight_id                TEXT,
    middle_name                TEXT,
    nickname_name              TEXT,
    official_full_name         TEXT,
    opensecrets_id             TEXT,
    religion_bio               TEXT,
    suffix_name                TEXT,
    thomas_id                  TEXT,
    votesmart_id               TEXT,
    wikidata_id                TEXT,
    wikipedia_id               TEXT
);
CREATE TABLE IF NOT EXISTS "historical-terms"
(
    address            TEXT,
    bioguide           TEXT
            primary key,
    chamber            TEXT,
    class              REAL,
    contact_form       TEXT,
    district           REAL,
    end                TEXT,
    fax                TEXT,
    last               TEXT,
    middle             TEXT,
    name               TEXT,
    office             TEXT,
    party              TEXT,
    party_affiliations TEXT,
    phone              TEXT,
    relation           TEXT,
    rss_url            TEXT,
    start              TEXT,
    state              TEXT,
    state_rank         TEXT,
    title              TEXT,
    type               TEXT,
    url                TEXT,
    foreign key (bioguide) references historical(bioguide_id)
);
CREATE TABLE IF NOT EXISTS "social-media"
(
    bioguide     TEXT
            primary key,
    facebook     TEXT,
    facebook_id  REAL,
    govtrack     REAL,
    instagram    TEXT,
    instagram_id REAL,
    thomas       INTEGER,
    twitter      TEXT,
    twitter_id   REAL,
    youtube      TEXT,
    youtube_id   TEXT,
    foreign key (bioguide) references current(bioguide_id)
);
 | 
| 
	food_inspection_2 | 
	How many inspections done by Lisa Tillman ended up with the result of "Out of Business"? | 
	the result of "Out of Business" refers to results = 'Out of Business' | 
	SELECT COUNT(T1.inspection_id) FROM inspection AS T1 INNER JOIN employee AS T2 ON T1.employee_id = T2.employee_id WHERE T2.first_name = 'Lisa' AND T2.last_name = 'Tillman' AND T1.results = 'Out of Business' | 
	CREATE TABLE employee
(
    employee_id INTEGER
            primary key,
    first_name  TEXT,
    last_name   TEXT,
    address     TEXT,
    city        TEXT,
    state       TEXT,
    zip         INTEGER,
    phone       TEXT,
    title       TEXT,
    salary      INTEGER,
    supervisor  INTEGER,
    foreign key (supervisor) references employee(employee_id)
);
CREATE TABLE establishment
(
    license_no    INTEGER
            primary key,
    dba_name      TEXT,
    aka_name      TEXT,
    facility_type TEXT,
    risk_level    INTEGER,
    address       TEXT,
    city          TEXT,
    state         TEXT,
    zip           INTEGER,
    latitude      REAL,
    longitude     REAL,
    ward          INTEGER
);
CREATE TABLE inspection
(
    inspection_id   INTEGER
            primary key,
    inspection_date DATE,
    inspection_type TEXT,
    results         TEXT,
    employee_id     INTEGER,
    license_no      INTEGER,
    followup_to     INTEGER,
    foreign key (employee_id) references employee(employee_id),
    foreign key (license_no) references establishment(license_no),
    foreign key (followup_to) references inspection(inspection_id)
);
CREATE TABLE inspection_point
(
    point_id    INTEGER
            primary key,
    Description TEXT,
    category    TEXT,
    code        TEXT,
    fine        INTEGER,
    point_level TEXT
);
CREATE TABLE violation
(
    inspection_id     INTEGER,
    point_id          INTEGER,
    fine              INTEGER,
    inspector_comment TEXT,
    primary key (inspection_id, point_id),
    foreign key (inspection_id) references inspection(inspection_id),
    foreign key (point_id) references inspection_point(point_id)
);
 | 
| 
	mondial_geo | 
	In which group of islands is Rinjani Mountain located? | 
	SELECT T1.Islands FROM island AS T1 INNER JOIN mountainOnIsland AS T2 ON T1.Name = T2.Island INNER JOIN mountain AS T3 ON T3.Name = T2.Mountain WHERE T3.Name = 'Rinjani' | 
	CREATE TABLE IF NOT EXISTS "borders"
(
    Country1 TEXT default '' not null
        constraint borders_ibfk_1
            references country,
    Country2 TEXT default '' not null
        constraint borders_ibfk_2
            references country,
    Length   REAL,
    primary key (Country1, Country2)
);
CREATE TABLE IF NOT EXISTS "city"
(
    Name       TEXT default '' not null,
    Country    TEXT default '' not null
        constraint city_ibfk_1
            references country
            on update cascade on delete cascade,
    Province   TEXT default '' not null,
    Population INTEGER,
    Longitude  REAL,
    Latitude   REAL,
    primary key (Name, Province),
    constraint city_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "continent"
(
    Name TEXT default '' not null
        primary key,
    Area REAL
);
CREATE TABLE IF NOT EXISTS "country"
(
    Name       TEXT            not null
        constraint ix_county_Name
            unique,
    Code       TEXT default '' not null
        primary key,
    Capital    TEXT,
    Province   TEXT,
    Area       REAL,
    Population INTEGER
);
CREATE TABLE IF NOT EXISTS "desert"
(
    Name      TEXT default '' not null
        primary key,
    Area      REAL,
    Longitude REAL,
    Latitude  REAL
);
CREATE TABLE IF NOT EXISTS "economy"
(
    Country     TEXT default '' not null
        primary key
        constraint economy_ibfk_1
            references country
            on update cascade on delete cascade,
    GDP         REAL,
    Agriculture REAL,
    Service     REAL,
    Industry    REAL,
    Inflation   REAL
);
CREATE TABLE IF NOT EXISTS "encompasses"
(
    Country    TEXT not null
        constraint encompasses_ibfk_1
            references country
            on update cascade on delete cascade,
    Continent  TEXT not null
        constraint encompasses_ibfk_2
            references continent
            on update cascade on delete cascade,
    Percentage REAL,
    primary key (Country, Continent)
);
CREATE TABLE IF NOT EXISTS "ethnicGroup"
(
    Country    TEXT default '' not null
        constraint ethnicGroup_ibfk_1
            references country
            on update cascade on delete cascade,
    Name       TEXT default '' not null,
    Percentage REAL,
    primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "geo_desert"
(
    Desert   TEXT default '' not null
        constraint geo_desert_ibfk_3
            references desert
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_desert_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Desert),
    constraint geo_desert_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_estuary"
(
    River    TEXT default '' not null
        constraint geo_estuary_ibfk_3
            references river
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_estuary_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, River),
    constraint geo_estuary_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_island"
(
    Island   TEXT default '' not null
        constraint geo_island_ibfk_3
            references island
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_island_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Island),
    constraint geo_island_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_lake"
(
    Lake     TEXT default '' not null
        constraint geo_lake_ibfk_3
            references lake
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_lake_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Lake),
    constraint geo_lake_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_mountain"
(
    Mountain TEXT default '' not null
        constraint geo_mountain_ibfk_3
            references mountain
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_mountain_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Mountain),
    constraint geo_mountain_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_river"
(
    River    TEXT default '' not null
        constraint geo_river_ibfk_3
            references river
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_river_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, River),
    constraint geo_river_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_sea"
(
    Sea      TEXT default '' not null
        constraint geo_sea_ibfk_3
            references sea
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_sea_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Sea),
    constraint geo_sea_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_source"
(
    River    TEXT default '' not null
        constraint geo_source_ibfk_3
            references river
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_source_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, River),
    constraint geo_source_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "island"
(
    Name      TEXT default '' not null
        primary key,
    Islands   TEXT,
    Area      REAL,
    Height    REAL,
    Type      TEXT,
    Longitude REAL,
    Latitude  REAL
);
CREATE TABLE IF NOT EXISTS "islandIn"
(
    Island TEXT
        constraint islandIn_ibfk_4
            references island
            on update cascade on delete cascade,
    Sea    TEXT
        constraint islandIn_ibfk_3
            references sea
            on update cascade on delete cascade,
    Lake   TEXT
        constraint islandIn_ibfk_1
            references lake
            on update cascade on delete cascade,
    River  TEXT
        constraint islandIn_ibfk_2
            references river
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "isMember"
(
    Country      TEXT default '' not null
        constraint isMember_ibfk_1
            references country
            on update cascade on delete cascade,
    Organization TEXT default '' not null
        constraint isMember_ibfk_2
            references organization
            on update cascade on delete cascade,
    Type         TEXT default 'member',
    primary key (Country, Organization)
);
CREATE TABLE IF NOT EXISTS "lake"
(
    Name      TEXT default '' not null
        primary key,
    Area      REAL,
    Depth     REAL,
    Altitude  REAL,
    Type      TEXT,
    River     TEXT,
    Longitude REAL,
    Latitude  REAL
);
CREATE TABLE IF NOT EXISTS "language"
(
    Country    TEXT default '' not null
        constraint language_ibfk_1
            references country
            on update cascade on delete cascade,
    Name       TEXT default '' not null,
    Percentage REAL,
    primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "located"
(
    City     TEXT,
    Province TEXT,
    Country  TEXT
        constraint located_ibfk_1
            references country
            on update cascade on delete cascade,
    River    TEXT
        constraint located_ibfk_3
            references river
            on update cascade on delete cascade,
    Lake     TEXT
        constraint located_ibfk_4
            references lake
            on update cascade on delete cascade,
    Sea      TEXT
        constraint located_ibfk_5
            references sea
            on update cascade on delete cascade,
    constraint located_ibfk_2
        foreign key (City, Province) references city
            on update cascade on delete cascade,
    constraint located_ibfk_6
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "locatedOn"
(
    City     TEXT default '' not null,
    Province TEXT default '' not null,
    Country  TEXT default '' not null
        constraint locatedOn_ibfk_1
            references country
            on update cascade on delete cascade,
    Island   TEXT default '' not null
        constraint locatedOn_ibfk_2
            references island
            on update cascade on delete cascade,
    primary key (City, Province, Country, Island),
    constraint locatedOn_ibfk_3
        foreign key (City, Province) references city
            on update cascade on delete cascade,
    constraint locatedOn_ibfk_4
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "mergesWith"
(
    Sea1 TEXT default '' not null
        constraint mergesWith_ibfk_1
            references sea
            on update cascade on delete cascade,
    Sea2 TEXT default '' not null
        constraint mergesWith_ibfk_2
            references sea
            on update cascade on delete cascade,
    primary key (Sea1, Sea2)
);
CREATE TABLE IF NOT EXISTS "mountain"
(
    Name      TEXT default '' not null
        primary key,
    Mountains TEXT,
    Height    REAL,
    Type      TEXT,
    Longitude REAL,
    Latitude  REAL
);
CREATE TABLE IF NOT EXISTS "mountainOnIsland"
(
    Mountain TEXT default '' not null
        constraint mountainOnIsland_ibfk_2
            references mountain
            on update cascade on delete cascade,
    Island   TEXT default '' not null
        constraint mountainOnIsland_ibfk_1
            references island
            on update cascade on delete cascade,
    primary key (Mountain, Island)
);
CREATE TABLE IF NOT EXISTS "organization"
(
    Abbreviation TEXT not null
        primary key,
    Name         TEXT not null
        constraint ix_organization_OrgNameUnique
            unique,
    City         TEXT,
    Country      TEXT
        constraint organization_ibfk_1
            references country
            on update cascade on delete cascade,
    Province     TEXT,
    Established  DATE,
    constraint organization_ibfk_2
        foreign key (City, Province) references city
            on update cascade on delete cascade,
    constraint organization_ibfk_3
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "politics"
(
    Country      TEXT default '' not null
        primary key
        constraint politics_ibfk_1
            references country
            on update cascade on delete cascade,
    Independence DATE,
    Dependent    TEXT
        constraint politics_ibfk_2
            references country
            on update cascade on delete cascade,
    Government   TEXT
);
CREATE TABLE IF NOT EXISTS "population"
(
    Country           TEXT default '' not null
        primary key
        constraint population_ibfk_1
            references country
            on update cascade on delete cascade,
    Population_Growth REAL,
    Infant_Mortality  REAL
);
CREATE TABLE IF NOT EXISTS "province"
(
    Name       TEXT not null,
    Country    TEXT not null
        constraint province_ibfk_1
            references country
            on update cascade on delete cascade,
    Population INTEGER,
    Area       REAL,
    Capital    TEXT,
    CapProv    TEXT,
    primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "religion"
(
    Country    TEXT default '' not null
        constraint religion_ibfk_1
            references country
            on update cascade on delete cascade,
    Name       TEXT default '' not null,
    Percentage REAL,
    primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "river"
(
    Name             TEXT default '' not null
        primary key,
    River            TEXT,
    Lake             TEXT
        constraint river_ibfk_1
            references lake
            on update cascade on delete cascade,
    Sea              TEXT,
    Length           REAL,
    SourceLongitude  REAL,
    SourceLatitude   REAL,
    Mountains        TEXT,
    SourceAltitude   REAL,
    EstuaryLongitude REAL,
    EstuaryLatitude  REAL
);
CREATE TABLE IF NOT EXISTS "sea"
(
    Name  TEXT default '' not null
        primary key,
    Depth REAL
);
CREATE TABLE IF NOT EXISTS "target"
(
    Country TEXT not null
        primary key
        constraint target_Country_fkey
            references country
            on update cascade on delete cascade,
    Target  TEXT
);
 | |
| 
	shakespeare | 
	Give the character's ID of the character that said the paragraph "O my poor brother! and so perchance may he be." | 
	"O my poor brother! and so perchance may he be." refers to  PlainText = 'O my poor brother! and so perchance may he be.' | 
	SELECT character_id FROM paragraphs WHERE PlainText = 'O my poor brother! and so perchance may he be.' | 
	CREATE TABLE IF NOT EXISTS "chapters"
(
    id          INTEGER
        primary key autoincrement,
    Act         INTEGER not null,
    Scene       INTEGER not null,
    Description TEXT    not null,
    work_id     INTEGER not null
        references works
);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "characters"
(
    id          INTEGER
        primary key autoincrement,
    CharName    TEXT not null,
    Abbrev      TEXT not null,
    Description TEXT not null
);
CREATE TABLE IF NOT EXISTS "paragraphs"
(
    id           INTEGER
        primary key autoincrement,
    ParagraphNum INTEGER           not null,
    PlainText    TEXT              not null,
    character_id INTEGER           not null
        references characters,
    chapter_id   INTEGER default 0 not null
        references chapters
);
CREATE TABLE IF NOT EXISTS "works"
(
    id        INTEGER
        primary key autoincrement,
    Title     TEXT    not null,
    LongTitle TEXT    not null,
    Date      INTEGER not null,
    GenreType TEXT    not null
);
 | 
| 
	food_inspection_2 | 
	Calculate the average salary for employees who did inspection on License Re-Inspection. | 
	inspection on License Re-Inspection refers to inspection_type = 'License Re-Inspection'; average salary = avg(salary) | 
	SELECT AVG(T2.salary) FROM inspection AS T1 INNER JOIN employee AS T2 ON T1.employee_id = T2.employee_id WHERE T1.inspection_type = 'License Re-Inspection' | 
	CREATE TABLE employee
(
    employee_id INTEGER
            primary key,
    first_name  TEXT,
    last_name   TEXT,
    address     TEXT,
    city        TEXT,
    state       TEXT,
    zip         INTEGER,
    phone       TEXT,
    title       TEXT,
    salary      INTEGER,
    supervisor  INTEGER,
    foreign key (supervisor) references employee(employee_id)
);
CREATE TABLE establishment
(
    license_no    INTEGER
            primary key,
    dba_name      TEXT,
    aka_name      TEXT,
    facility_type TEXT,
    risk_level    INTEGER,
    address       TEXT,
    city          TEXT,
    state         TEXT,
    zip           INTEGER,
    latitude      REAL,
    longitude     REAL,
    ward          INTEGER
);
CREATE TABLE inspection
(
    inspection_id   INTEGER
            primary key,
    inspection_date DATE,
    inspection_type TEXT,
    results         TEXT,
    employee_id     INTEGER,
    license_no      INTEGER,
    followup_to     INTEGER,
    foreign key (employee_id) references employee(employee_id),
    foreign key (license_no) references establishment(license_no),
    foreign key (followup_to) references inspection(inspection_id)
);
CREATE TABLE inspection_point
(
    point_id    INTEGER
            primary key,
    Description TEXT,
    category    TEXT,
    code        TEXT,
    fine        INTEGER,
    point_level TEXT
);
CREATE TABLE violation
(
    inspection_id     INTEGER,
    point_id          INTEGER,
    fine              INTEGER,
    inspector_comment TEXT,
    primary key (inspection_id, point_id),
    foreign key (inspection_id) references inspection(inspection_id),
    foreign key (point_id) references inspection_point(point_id)
);
 | 
| 
	movie_3 | 
	Give the full name of the actor with the highest rental rate. | 
	full name refers to first_name, last_name; the highest rental rate refers to max(rental_rate) | 
	SELECT T1.first_name, T1.last_name FROM actor AS T1 INNER JOIN film_actor AS T2 ON T1.actor_id = T2.actor_id INNER JOIN film AS T3 ON T3.film_id = T2.film_id ORDER BY T3.rental_rate DESC LIMIT 1 | 
	CREATE TABLE film_text
(
    film_id     INTEGER     not null
        primary key,
    title       TEXT not null,
    description TEXT         null
);
CREATE TABLE IF NOT EXISTS "actor"
(
    actor_id    INTEGER
        primary key autoincrement,
    first_name  TEXT                               not null,
    last_name   TEXT                               not null,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "address"
(
    address_id  INTEGER
        primary key autoincrement,
    address     TEXT                               not null,
    address2    TEXT,
    district    TEXT                               not null,
    city_id     INTEGER                            not null
        references city
            on update cascade,
    postal_code TEXT,
    phone       TEXT                               not null,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "category"
(
    category_id INTEGER
        primary key autoincrement,
    name        TEXT                               not null,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "city"
(
    city_id     INTEGER
        primary key autoincrement,
    city        TEXT                               not null,
    country_id  INTEGER                            not null
        references country
            on update cascade,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "country"
(
    country_id  INTEGER
        primary key autoincrement,
    country     TEXT                               not null,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "customer"
(
    customer_id INTEGER
        primary key autoincrement,
    store_id    INTEGER                            not null
        references store
            on update cascade,
    first_name  TEXT                               not null,
    last_name   TEXT                               not null,
    email       TEXT,
    address_id  INTEGER                            not null
        references address
            on update cascade,
    active      INTEGER  default 1                 not null,
    create_date DATETIME                           not null,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "film"
(
    film_id              INTEGER
        primary key autoincrement,
    title                TEXT                               not null,
    description          TEXT,
    release_year         TEXT,
    language_id          INTEGER                            not null
        references language
            on update cascade,
    original_language_id INTEGER
        references language
            on update cascade,
    rental_duration      INTEGER  default 3                 not null,
    rental_rate          REAL     default 4.99              not null,
    length               INTEGER,
    replacement_cost     REAL     default 19.99             not null,
    rating               TEXT     default 'G',
    special_features     TEXT,
    last_update          DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "film_actor"
(
    actor_id    INTEGER                            not null
        references actor
            on update cascade,
    film_id     INTEGER                            not null
        references film
            on update cascade,
    last_update DATETIME default CURRENT_TIMESTAMP not null,
    primary key (actor_id, film_id)
);
CREATE TABLE IF NOT EXISTS "film_category"
(
    film_id     INTEGER                            not null
        references film
            on update cascade,
    category_id INTEGER                            not null
        references category
            on update cascade,
    last_update DATETIME default CURRENT_TIMESTAMP not null,
    primary key (film_id, category_id)
);
CREATE TABLE IF NOT EXISTS "inventory"
(
    inventory_id INTEGER
        primary key autoincrement,
    film_id      INTEGER                            not null
        references film
            on update cascade,
    store_id     INTEGER                            not null
        references store
            on update cascade,
    last_update  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "language"
(
    language_id INTEGER
        primary key autoincrement,
    name        TEXT                               not null,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "payment"
(
    payment_id   INTEGER
        primary key autoincrement,
    customer_id  INTEGER                            not null
        references customer
            on update cascade,
    staff_id     INTEGER                            not null
        references staff
            on update cascade,
    rental_id    INTEGER
                                                    references rental
                                                        on update cascade on delete set null,
    amount       REAL                               not null,
    payment_date DATETIME                           not null,
    last_update  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "rental"
(
    rental_id    INTEGER
        primary key autoincrement,
    rental_date  DATETIME                           not null,
    inventory_id INTEGER                            not null
        references inventory
            on update cascade,
    customer_id  INTEGER                            not null
        references customer
            on update cascade,
    return_date  DATETIME,
    staff_id     INTEGER                            not null
        references staff
            on update cascade,
    last_update  DATETIME default CURRENT_TIMESTAMP not null,
    unique (rental_date, inventory_id, customer_id)
);
CREATE TABLE IF NOT EXISTS "staff"
(
    staff_id    INTEGER
        primary key autoincrement,
    first_name  TEXT                               not null,
    last_name   TEXT                               not null,
    address_id  INTEGER                            not null
        references address
            on update cascade,
    picture     BLOB,
    email       TEXT,
    store_id    INTEGER                            not null
        references store
            on update cascade,
    active      INTEGER  default 1                 not null,
    username    TEXT                               not null,
    password    TEXT,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "store"
(
    store_id         INTEGER
        primary key autoincrement,
    manager_staff_id INTEGER                            not null
        unique
        references staff
            on update cascade,
    address_id       INTEGER                            not null
        references address
            on update cascade,
    last_update      DATETIME default CURRENT_TIMESTAMP not null
);
 | 
| 
	car_retails | 
	From which branch does the sales representative employee who made the most sales in 2005? Please indicates its full address and phone number. | 
	orderDate between '2005-01-01' and '2005-12-31'; full address = addressLine1+addressLine2; | 
	SELECT T3.addressLine1, T3.addressLine2, T3.phone FROM orderdetails AS T1 INNER JOIN orders AS T2 ON T1.orderNumber = T2.orderNumber INNER JOIN customers AS T3 ON T2.customerNumber = T3.customerNumber INNER JOIN employees AS T4 ON T3.salesRepEmployeeNumber = T4.employeeNumber INNER JOIN offices AS T5 ON T4.officeCode = T5.officeCode WHERE STRFTIME('%Y', T2.orderDate) = '2005' AND T4.jobTitle = 'Sales Rep' ORDER BY T1.quantityOrdered DESC LIMIT 1 | 
	CREATE TABLE offices
(
    officeCode   TEXT not null
        primary key,
    city         TEXT not null,
    phone        TEXT not null,
    addressLine1 TEXT not null,
    addressLine2 TEXT,
    state        TEXT,
    country      TEXT not null,
    postalCode  TEXT not null,
    territory    TEXT not null
);
CREATE TABLE employees
(
    employeeNumber INTEGER      not null
        primary key,
    lastName       TEXT  not null,
    firstName      TEXT  not null,
    extension      TEXT  not null,
    email          TEXT not null,
    officeCode     TEXT  not null,
    reportsTo      INTEGER,
    jobTitle       TEXT  not null,
    foreign key (officeCode) references offices(officeCode),
    foreign key (reportsTo) references employees(employeeNumber)
);
CREATE TABLE customers
(
    customerNumber         INTEGER     not null
        primary key,
    customerName           TEXT not null,
    contactLastName        TEXT not null,
    contactFirstName       TEXT not null,
    phone                  TEXT not null,
    addressLine1           TEXT not null,
    addressLine2           TEXT,
    city                   TEXT not null,
    state                  TEXT,
    postalCode             TEXT,
    country                TEXT not null,
    salesRepEmployeeNumber INTEGER,
    creditLimit            REAL,
    foreign key (salesRepEmployeeNumber) references employees(employeeNumber)
);
CREATE TABLE orders
(
    orderNumber    INTEGER     not null
        primary key,
    orderDate      DATE        not null,
    requiredDate   DATE        not null,
    shippedDate    DATE,
    status         TEXT not null,
    comments       TEXT,
    customerNumber INTEGER     not null,
    foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE payments
(
    customerNumber INTEGER     not null,
    checkNumber    TEXT not null,
    paymentDate    DATE        not null,
    amount         REAL        not null,
    primary key (customerNumber, checkNumber),
    foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE productlines
(
    productLine     TEXT not null
        primary key,
    textDescription TEXT,
    htmlDescription TEXT,
    image           BLOB
);
CREATE TABLE products
(
    productCode        TEXT not null
        primary key,
    productName        TEXT not null,
    productLine        TEXT not null,
    productScale      TEXT not null,
    productVendor      TEXT not null,
    productDescription TEXT        not null,
    quantityInStock    INTEGER     not null,
    buyPrice           REAL        not null,
    MSRP               REAL        not null,
    foreign key (productLine) references productlines(productLine)
);
CREATE TABLE IF NOT EXISTS "orderdetails"
(
    orderNumber     INTEGER not null
        references orders,
    productCode     TEXT    not null
        references products,
    quantityOrdered INTEGER not null,
    priceEach       REAL    not null,
    orderLineNumber INTEGER not null,
    primary key (orderNumber, productCode)
);
 | 
| 
	food_inspection | 
	Provide the name of the business which had the most number of inspections because of complaint. | 
	the most number of inspections because of complaint refers to type = 'Complaint' where MAX(business_id); | 
	SELECT T2.name FROM inspections AS T1 INNER JOIN businesses AS T2 ON T1.business_id = T2.business_id WHERE T1.type = 'Complaint' GROUP BY T2.name ORDER BY COUNT(T1.business_id) DESC LIMIT 1 | 
	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`)
);
 | 
| 
	superstore | 
	What are the names of the products that were ordered by Alejandro Grove? | 
	ordered by Alejandro Grove refers to "Customer Name" = 'Alejandro Grove'; names of the products refers to "Product Name" | 
	SELECT DISTINCT T3.`Product Name` FROM west_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` INNER JOIN product AS T3 ON T3.`Product ID` = T1.`Product ID` WHERE T2.`Customer Name` = 'Alejandro Grove' | 
	CREATE TABLE people
(
    "Customer ID"   TEXT,
    "Customer Name" TEXT,
    Segment         TEXT,
    Country         TEXT,
    City            TEXT,
    State           TEXT,
    "Postal Code"   INTEGER,
    Region          TEXT,
    primary key ("Customer ID", Region)
);
CREATE TABLE product
(
    "Product ID"   TEXT,
    "Product Name" TEXT,
    Category       TEXT,
    "Sub-Category" TEXT,
    Region         TEXT,
    primary key ("Product ID", Region)
);
CREATE TABLE central_superstore
(
    "Row ID"      INTEGER
            primary key,
    "Order ID"    TEXT,
    "Order Date"  DATE,
    "Ship Date"   DATE,
    "Ship Mode"   TEXT,
    "Customer ID" TEXT,
    Region        TEXT,
    "Product ID"  TEXT,
    Sales         REAL,
    Quantity      INTEGER,
    Discount      REAL,
    Profit        REAL,
    foreign key ("Customer ID", Region) references people("Customer ID",Region),
    foreign key ("Product ID", Region) references product("Product ID",Region)
);
CREATE TABLE east_superstore
(
    "Row ID"      INTEGER
            primary key,
    "Order ID"    TEXT,
    "Order Date"  DATE,
    "Ship Date"   DATE,
    "Ship Mode"   TEXT,
    "Customer ID" TEXT,
    Region        TEXT,
    "Product ID"  TEXT,
    Sales         REAL,
    Quantity      INTEGER,
    Discount      REAL,
    Profit        REAL,
    foreign key ("Customer ID", Region) references people("Customer ID",Region),
    foreign key ("Product ID", Region) references product("Product ID",Region)
);
CREATE TABLE south_superstore
(
    "Row ID"      INTEGER
            primary key,
    "Order ID"    TEXT,
    "Order Date"  DATE,
    "Ship Date"   DATE,
    "Ship Mode"   TEXT,
    "Customer ID" TEXT,
    Region        TEXT,
    "Product ID"  TEXT,
    Sales         REAL,
    Quantity      INTEGER,
    Discount      REAL,
    Profit        REAL,
    foreign key ("Customer ID", Region) references people("Customer ID",Region),
    foreign key ("Product ID", Region) references product("Product ID",Region)
);
CREATE TABLE west_superstore
(
    "Row ID"      INTEGER
            primary key,
    "Order ID"    TEXT,
    "Order Date"  DATE,
    "Ship Date"   DATE,
    "Ship Mode"   TEXT,
    "Customer ID" TEXT,
    Region        TEXT,
    "Product ID"  TEXT,
    Sales         REAL,
    Quantity      INTEGER,
    Discount      REAL,
    Profit        REAL,
    foreign key ("Customer ID", Region) references people("Customer ID",Region),
    foreign key ("Product ID", Region) references product("Product ID",Region)
);
 | 
| 
	regional_sales | 
	Name the product that was registered in the sales order 'SO - 0005951'. | 
	sales order 'SO - 0005951' refers to OrderNumber = 'SO - 0005951'; product refers to Product Name | 
	SELECT T FROM ( SELECT DISTINCT CASE  WHEN T2.OrderNumber = 'SO - 0005951' THEN T1.`Product Name` ELSE NULL END AS T FROM Products T1 INNER JOIN `Sales Orders` T2 ON T2._ProductID = T1.ProductID ) WHERE T IS NOT NULL | 
	CREATE TABLE Customers
(
    CustomerID       INTEGER
        constraint Customers_pk
            primary key,
    "Customer Names" TEXT
);
CREATE TABLE Products
(
    ProductID      INTEGER
        constraint Products_pk
            primary key,
    "Product Name" TEXT
);
CREATE TABLE Regions
(
    StateCode TEXT
        constraint Regions_pk
            primary key,
    State     TEXT,
    Region    TEXT
);
CREATE TABLE IF NOT EXISTS "Sales Team"
(
    SalesTeamID  INTEGER
        constraint "Sales Team_pk"
            primary key,
    "Sales Team" TEXT,
    Region       TEXT
);
CREATE TABLE IF NOT EXISTS "Store Locations"
(
    StoreID            INTEGER
        constraint "Store Locations_pk"
            primary key,
    "City Name"        TEXT,
    County             TEXT,
    StateCode          TEXT
        constraint "Store Locations_Regions_StateCode_fk"
            references Regions(StateCode),
    State              TEXT,
    Type               TEXT,
    Latitude           REAL,
    Longitude          REAL,
    AreaCode           INTEGER,
    Population         INTEGER,
    "Household Income" INTEGER,
    "Median Income"    INTEGER,
    "Land Area"        INTEGER,
    "Water Area"       INTEGER,
    "Time Zone"        TEXT
);
CREATE TABLE IF NOT EXISTS "Sales Orders"
(
    OrderNumber        TEXT
        constraint "Sales Orders_pk"
            primary key,
    "Sales Channel"    TEXT,
    WarehouseCode      TEXT,
    ProcuredDate       TEXT,
    OrderDate          TEXT,
    ShipDate           TEXT,
    DeliveryDate       TEXT,
    CurrencyCode       TEXT,
    _SalesTeamID       INTEGER
        constraint "Sales Orders_Sales Team_SalesTeamID_fk"
            references "Sales Team"(SalesTeamID),
    _CustomerID        INTEGER
        constraint "Sales Orders_Customers_CustomerID_fk"
            references Customers(CustomerID),
    _StoreID           INTEGER
        constraint "Sales Orders_Store Locations_StoreID_fk"
            references "Store Locations"(StoreID),
    _ProductID         INTEGER
        constraint "Sales Orders_Products_ProductID_fk"
            references Products(ProductID),
    "Order Quantity"   INTEGER,
    "Discount Applied" REAL,
    "Unit Price"       TEXT,
    "Unit Cost"        TEXT
);
 | 
| 
	talkingdata | 
	How many app IDs were included under science fiction category? | 
	SELECT COUNT(T2.app_id) FROM label_categories AS T1 INNER JOIN app_labels AS T2 ON T2.label_id = T1.label_id WHERE T1.category = 'science fiction' | 
	CREATE TABLE `app_all`
(
    `app_id` INTEGER NOT NULL,
    PRIMARY KEY (`app_id`)
);
CREATE TABLE `app_events` (
  `event_id` INTEGER NOT NULL,
  `app_id` INTEGER NOT NULL,
  `is_installed` INTEGER NOT NULL,
  `is_active` INTEGER NOT NULL,
  PRIMARY KEY (`event_id`,`app_id`),
  FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `app_events_relevant` (
  `event_id` INTEGER NOT NULL,
  `app_id` INTEGER NOT NULL,
  `is_installed` INTEGER DEFAULT NULL,
  `is_active` INTEGER DEFAULT NULL,
  PRIMARY KEY (`event_id`,`app_id`),
  FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `app_labels` (
  `app_id` INTEGER NOT NULL,
  `label_id` INTEGER NOT NULL,
  FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `events` (
  `event_id` INTEGER NOT NULL,
  `device_id` INTEGER DEFAULT NULL,
  `timestamp` DATETIME DEFAULT NULL,
  `longitude` REAL DEFAULT NULL,
  `latitude` REAL DEFAULT NULL,
  PRIMARY KEY (`event_id`)
);
CREATE TABLE `events_relevant` (
  `event_id` INTEGER NOT NULL,
  `device_id` INTEGER DEFAULT NULL,
  `timestamp` DATETIME NOT NULL,
  `longitude` REAL NOT NULL,
  `latitude` REAL NOT NULL,
  PRIMARY KEY (`event_id`),
  FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `gender_age` (
  `device_id` INTEGER NOT NULL,
  `gender` TEXT DEFAULT NULL,
  `age` INTEGER DEFAULT NULL,
  `group` TEXT DEFAULT NULL,
  PRIMARY KEY (`device_id`),
  FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `gender_age_test` (
  `device_id` INTEGER NOT NULL,
  PRIMARY KEY (`device_id`)
);
CREATE TABLE `gender_age_train` (
  `device_id` INTEGER NOT NULL,
  `gender` TEXT DEFAULT NULL,
  `age` INTEGER DEFAULT NULL,
  `group` TEXT DEFAULT NULL,
  PRIMARY KEY (`device_id`)
);
CREATE TABLE `label_categories` (
  `label_id` INTEGER NOT NULL,
  `category` TEXT DEFAULT NULL,
  PRIMARY KEY (`label_id`)
);
CREATE TABLE `phone_brand_device_model2` (
  `device_id` INTEGER NOT NULL,
  `phone_brand` TEXT NOT NULL,
  `device_model` TEXT NOT NULL,
  PRIMARY KEY (`device_id`,`phone_brand`,`device_model`)
);
CREATE TABLE `sample_submission` (
  `device_id` INTEGER NOT NULL,
  `F23-` REAL DEFAULT NULL,
  `F24-26` REAL DEFAULT NULL,
  `F27-28` REAL DEFAULT NULL,
  `F29-32` REAL DEFAULT NULL,
  `F33-42` REAL DEFAULT NULL,
  `F43+` REAL DEFAULT NULL,
  `M22-` REAL DEFAULT NULL,
  `M23-26` REAL DEFAULT NULL,
  `M27-28` REAL DEFAULT NULL,
  `M29-31` REAL DEFAULT NULL,
  `M32-38` REAL DEFAULT NULL,
  `M39+` REAL DEFAULT NULL,
  PRIMARY KEY (`device_id`)
);
 | |
| 
	video_games | 
	How many games did BMG Interactive Entertainment release in 2012? | 
	BMG Interactive Entertainment refers to publisher_name = 'BMG Interactive Entertainment'; release in 2012 refers to release_year = 2012; | 
	SELECT COUNT(DISTINCT T2.game_id) FROM publisher AS T1 INNER JOIN game_publisher AS T2 ON T1.id = T2.publisher_id INNER JOIN game_platform AS T3 ON T2.id = T3.game_publisher_id WHERE T3.release_year = 2012 | 
	CREATE TABLE genre
(
    id         INTEGER not null
            primary key,
    genre_name TEXT default NULL
);
CREATE TABLE game
(
    id        INTEGER not null
            primary key,
    genre_id  INTEGER          default NULL,
    game_name TEXT default NULL,
    foreign key (genre_id) references genre(id)
);
CREATE TABLE platform
(
    id            INTEGER not null
            primary key,
    platform_name TEXT default NULL
);
CREATE TABLE publisher
(
    id             INTEGER not null
            primary key,
    publisher_name TEXT default NULL
);
CREATE TABLE game_publisher
(
    id           INTEGER not null
            primary key,
    game_id      INTEGER default NULL,
    publisher_id INTEGER default NULL,
    foreign key (game_id) references game(id),
    foreign key (publisher_id) references publisher(id)
);
CREATE TABLE game_platform
(
    id                INTEGER not null
            primary key,
    game_publisher_id INTEGER default NULL,
    platform_id       INTEGER default NULL,
    release_year      INTEGER default NULL,
    foreign key (game_publisher_id) references game_publisher(id),
    foreign key (platform_id) references platform(id)
);
CREATE TABLE region
(
    id          INTEGER not null
            primary key,
    region_name TEXT default NULL
);
CREATE TABLE region_sales
(
    region_id        INTEGER           default NULL,
    game_platform_id INTEGER           default NULL,
    num_sales        REAL default NULL,
    foreign key (game_platform_id) references game_platform(id),
    foreign key (region_id) references region(id)
);
 | 
| 
	ice_hockey_draft | 
	How many players were born in 1982 and have a height above 182cm? | 
	born in 1982 refers to birthyear = 1982; height above 182cm refers to height_in_cm > 182 ; | 
	SELECT COUNT(T2.ELITEID) FROM height_info AS T1 INNER JOIN PlayerInfo AS T2 ON T1.height_id = T2.height WHERE T1.height_in_cm > 182 AND strftime('%Y', T2.birthdate) = '1982' | 
	CREATE TABLE height_info
(
    height_id      INTEGER
            primary key,
    height_in_cm   INTEGER,
    height_in_inch TEXT
);
CREATE TABLE weight_info
(
    weight_id     INTEGER
            primary key,
    weight_in_kg  INTEGER,
    weight_in_lbs INTEGER
);
CREATE TABLE PlayerInfo
(
    ELITEID           INTEGER
            primary key,
    PlayerName        TEXT,
    birthdate         TEXT,
    birthyear         DATE,
    birthmonth        INTEGER,
    birthday          INTEGER,
    birthplace        TEXT,
    nation            TEXT,
    height            INTEGER,
    weight            INTEGER,
    position_info     TEXT,
    shoots            TEXT,
    draftyear         INTEGER,
    draftround        INTEGER,
    overall           INTEGER,
    overallby         TEXT,
    CSS_rank          INTEGER,
    sum_7yr_GP        INTEGER,
    sum_7yr_TOI       INTEGER,
    GP_greater_than_0 TEXT,
    foreign key (height) references height_info(height_id),
    foreign key (weight) references weight_info(weight_id)
);
CREATE TABLE SeasonStatus
(
    ELITEID   INTEGER,
    SEASON    TEXT,
    TEAM      TEXT,
    LEAGUE    TEXT,
    GAMETYPE  TEXT,
    GP        INTEGER,
    G         INTEGER,
    A         INTEGER,
    P         INTEGER,
    PIM       INTEGER,
    PLUSMINUS INTEGER,
    foreign key (ELITEID) references PlayerInfo(ELITEID)
);
 | 
| 
	works_cycles | 
	What is the highest profit on net for a product? | 
	profit on net = subtract(LastReceiptCost, StandardPrice) | 
	SELECT LastReceiptCost - StandardPrice FROM ProductVendor ORDER BY LastReceiptCost - StandardPrice DESC LIMIT 1 | 
	CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
    CountryRegionCode TEXT                          not null
        primary key,
    Name              TEXT                        not null
            unique,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE Culture
(
    CultureID    TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Currency
(
    CurrencyCode TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE CountryRegionCurrency
(
    CountryRegionCode TEXT                          not null,
    CurrencyCode      TEXT                             not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    primary key (CountryRegionCode, CurrencyCode),
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode),
    foreign key (CurrencyCode) references Currency(CurrencyCode)
);
CREATE TABLE Person
(
    BusinessEntityID      INTEGER                                  not null
        primary key,
    PersonType            TEXT                              not null,
    NameStyle             INTEGER default 0                 not null,
    Title                 TEXT,
    FirstName             TEXT                         not null,
    MiddleName            TEXT,
    LastName              TEXT                         not null,
    Suffix                TEXT,
    EmailPromotion        INTEGER        default 0                 not null,
    AdditionalContactInfo TEXT,
    Demographics          TEXT,
    rowguid               TEXT                          not null
            unique,
    ModifiedDate          DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE BusinessEntityContact
(
    BusinessEntityID INTEGER                                 not null,
    PersonID         INTEGER                                 not null,
    ContactTypeID    INTEGER                                 not null,
    rowguid         TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, PersonID, ContactTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (ContactTypeID) references ContactType(ContactTypeID),
    foreign key (PersonID) references Person(BusinessEntityID)
);
CREATE TABLE EmailAddress
(
    BusinessEntityID INTEGER                                 not null,
    EmailAddressID   INTEGER,
    EmailAddress     TEXT,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (EmailAddressID, BusinessEntityID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Employee
(
    BusinessEntityID  INTEGER                                 not null
        primary key,
    NationalIDNumber  TEXT                          not null
            unique,
    LoginID           TEXT                         not null
            unique,
    OrganizationNode  TEXT,
    OrganizationLevel INTEGER,
    JobTitle          TEXT                          not null,
    BirthDate         DATE                                 not null,
    MaritalStatus     TEXT                                 not null,
    Gender            TEXT                                 not null,
    HireDate          DATE                                 not null,
    SalariedFlag      INTEGER default 1                 not null,
    VacationHours     INTEGER   default 0                 not null,
    SickLeaveHours    INTEGER   default 0                 not null,
    CurrentFlag       INTEGER default 1                 not null,
    rowguid           TEXT                          not null
            unique,
    ModifiedDate      DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Password
(
    BusinessEntityID INTEGER                                 not null
        primary key,
    PasswordHash     TEXT                        not null,
    PasswordSalt     TEXT                         not null,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE PersonCreditCard
(
    BusinessEntityID INTEGER                                 not null,
    CreditCardID     INTEGER                                 not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, CreditCardID),
    foreign key (CreditCardID) references CreditCard(CreditCardID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE ProductCategory
(
    ProductCategoryID INTEGER
        primary key autoincrement,
    Name              TEXT                        not null
        unique,
    rowguid           TEXT                         not null
        unique,
    ModifiedDate      DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductDescription
(
    ProductDescriptionID INTEGER
        primary key autoincrement,
    Description          TEXT                        not null,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModel
(
    ProductModelID     INTEGER
        primary key autoincrement,
    Name               TEXT                        not null
        unique,
    CatalogDescription TEXT,
    Instructions       TEXT,
    rowguid            TEXT                         not null
        unique,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModelProductDescriptionCulture
(
    ProductModelID       INTEGER                             not null,
    ProductDescriptionID INTEGER                             not null,
    CultureID            TEXT                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductModelID, ProductDescriptionID, CultureID),
    foreign key (ProductModelID) references ProductModel(ProductModelID),
    foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID),
    foreign key (CultureID) references Culture(CultureID)
);
CREATE TABLE ProductPhoto
(
    ProductPhotoID         INTEGER
        primary key autoincrement,
    ThumbNailPhoto         BLOB,
    ThumbnailPhotoFileName TEXT,
    LargePhoto             BLOB,
    LargePhotoFileName     TEXT,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductSubcategory
(
    ProductSubcategoryID INTEGER
        primary key autoincrement,
    ProductCategoryID    INTEGER                             not null,
    Name                 TEXT                        not null
        unique,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate        DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID)
);
CREATE TABLE SalesReason
(
    SalesReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null,
    ReasonType    TEXT                        not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE SalesTerritory
(
    TerritoryID       INTEGER
        primary key autoincrement,
    Name              TEXT                             not null
        unique,
    CountryRegionCode TEXT                               not null,
    "Group"           TEXT                              not null,
    SalesYTD          REAL default 0.0000            not null,
    SalesLastYear     REAL default 0.0000            not null,
    CostYTD           REAL default 0.0000            not null,
    CostLastYear      REAL default 0.0000            not null,
    rowguid           TEXT                              not null
        unique,
    ModifiedDate      DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode)
);
CREATE TABLE SalesPerson
(
    BusinessEntityID INTEGER                                  not null
        primary key,
    TerritoryID      INTEGER,
    SalesQuota       REAL,
    Bonus            REAL default 0.0000            not null,
    CommissionPct    REAL default 0.0000            not null,
    SalesYTD         REAL default 0.0000            not null,
    SalesLastYear    REAL default 0.0000            not null,
    rowguid          TEXT                              not null
        unique,
    ModifiedDate     DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references Employee(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE SalesPersonQuotaHistory
(
    BusinessEntityID INTEGER                             not null,
    QuotaDate        DATETIME                            not null,
    SalesQuota       REAL                      not null,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, QuotaDate),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesTerritoryHistory
(
    BusinessEntityID INTEGER                             not null,
    TerritoryID      INTEGER                             not null,
    StartDate        DATETIME                            not null,
    EndDate          DATETIME,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, StartDate, TerritoryID),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE ScrapReason
(
    ScrapReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null
        unique,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE Shift
(
    ShiftID      INTEGER
        primary key autoincrement,
    Name         TEXT                        not null
        unique,
    StartTime    TEXT                                not null,
    EndTime      TEXT                                not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    unique (StartTime, EndTime)
);
CREATE TABLE ShipMethod
(
    ShipMethodID INTEGER
        primary key autoincrement,
    Name         TEXT                             not null
        unique,
    ShipBase     REAL default 0.0000            not null,
    ShipRate    REAL default 0.0000            not null,
    rowguid      TEXT                              not null
        unique,
    ModifiedDate DATETIME      default CURRENT_TIMESTAMP not null
);
CREATE TABLE SpecialOffer
(
    SpecialOfferID INTEGER
        primary key autoincrement,
    Description    TEXT                             not null,
    DiscountPct    REAL   default 0.0000            not null,
    Type           TEXT                             not null,
    Category       TEXT                             not null,
    StartDate      DATETIME                            not null,
    EndDate        DATETIME                            not null,
    MinQty         INTEGER   default 0                 not null,
    MaxQty         INTEGER,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE BusinessEntityAddress
(
    BusinessEntityID INTEGER                                 not null,
    AddressID        INTEGER                                 not null,
    AddressTypeID    INTEGER                                 not null,
    rowguid          TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, AddressID, AddressTypeID),
    foreign key (AddressID) references Address(AddressID),
    foreign key (AddressTypeID) references AddressType(AddressTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE SalesTaxRate
(
    SalesTaxRateID  INTEGER
        primary key autoincrement,
    StateProvinceID INTEGER                                  not null,
    TaxType         INTEGER                                  not null,
    TaxRate         REAL default 0.0000            not null,
    Name            TEXT                             not null,
    rowguid         TEXT                              not null
        unique,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    unique (StateProvinceID, TaxType),
    foreign key (StateProvinceID) references StateProvince(StateProvinceID)
);
CREATE TABLE Store
(
    BusinessEntityID INTEGER                             not null
        primary key,
    Name             TEXT                        not null,
    SalesPersonID    INTEGER,
    Demographics     TEXT,
    rowguid          TEXT                             not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (SalesPersonID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesOrderHeaderSalesReason
(
    SalesOrderID  INTEGER                             not null,
    SalesReasonID INTEGER                             not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SalesOrderID, SalesReasonID),
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SalesReasonID) references SalesReason(SalesReasonID)
);
CREATE TABLE TransactionHistoryArchive
(
    TransactionID        INTEGER                             not null
        primary key,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE UnitMeasure
(
    UnitMeasureCode TEXT                             not null
        primary key,
    Name            TEXT                        not null
        unique,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductCostHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    StandardCost REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ProductDocument
(
    ProductID    INTEGER                             not null,
    DocumentNode TEXT                        not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, DocumentNode),
    foreign key (ProductID) references Product(ProductID),
    foreign key (DocumentNode) references Document(DocumentNode)
);
CREATE TABLE ProductInventory
(
    ProductID    INTEGER                             not null,
    LocationID   INTEGER                            not null,
    Shelf        TEXT                         not null,
    Bin          INTEGER                             not null,
    Quantity     INTEGER  default 0                 not null,
    rowguid      TEXT                         not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, LocationID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE ProductProductPhoto
(
    ProductID      INTEGER                             not null,
    ProductPhotoID INTEGER                             not null,
    "Primary"      INTEGER   default 0                 not null,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, ProductPhotoID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID)
);
CREATE TABLE ProductReview
(
    ProductReviewID INTEGER
        primary key autoincrement,
    ProductID       INTEGER                             not null,
    ReviewerName   TEXT                        not null,
    ReviewDate      DATETIME default CURRENT_TIMESTAMP not null,
    EmailAddress    TEXT                         not null,
    Rating          INTEGER                             not null,
    Comments        TEXT,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ShoppingCartItem
(
    ShoppingCartItemID INTEGER
        primary key autoincrement,
    ShoppingCartID     TEXT                         not null,
    Quantity           INTEGER   default 1                 not null,
    ProductID          INTEGER                             not null,
    DateCreated        DATETIME default CURRENT_TIMESTAMP not null,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SpecialOfferProduct
(
    SpecialOfferID INTEGER                             not null,
    ProductID      INTEGER                             not null,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SpecialOfferID, ProductID),
    foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SalesOrderDetail
(
    SalesOrderID          INTEGER                             not null,
    SalesOrderDetailID    INTEGER
        primary key autoincrement,
    CarrierTrackingNumber TEXT,
    OrderQty              INTEGER                             not null,
    ProductID             INTEGER                             not null,
    SpecialOfferID        INTEGER                             not null,
    UnitPrice             REAL                             not null,
    UnitPriceDiscount     REAL   default 0.0000            not null,
    LineTotal             REAL                             not null,
    rowguid               TEXT                             not null
        unique,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID)
);
CREATE TABLE TransactionHistory
(
    TransactionID        INTEGER
        primary key autoincrement,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE Vendor
(
    BusinessEntityID        INTEGER                             not null
        primary key,
    AccountNumber           TEXT                         not null
        unique,
    Name                    TEXT                        not null,
    CreditRating            INTEGER                             not null,
    PreferredVendorStatus   INTEGER   default 1                 not null,
    ActiveFlag              INTEGER   default 1                 not null,
    PurchasingWebServiceURL TEXT,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE ProductVendor
(
    ProductID        INTEGER                             not null,
    BusinessEntityID INTEGER                             not null,
    AverageLeadTime  INTEGER                             not null,
    StandardPrice    REAL                      not null,
    LastReceiptCost  REAL,
    LastReceiptDate  DATETIME,
    MinOrderQty      INTEGER                             not null,
    MaxOrderQty      INTEGER                             not null,
    OnOrderQty       INTEGER,
    UnitMeasureCode  TEXT                             not null,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, BusinessEntityID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (BusinessEntityID) references Vendor(BusinessEntityID),
    foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode)
);
CREATE TABLE PurchaseOrderHeader
(
    PurchaseOrderID INTEGER
        primary key autoincrement,
    RevisionNumber  INTEGER        default 0                 not null,
    Status          INTEGER        default 1                 not null,
    EmployeeID      INTEGER                                  not null,
    VendorID        INTEGER                                  not null,
    ShipMethodID    INTEGER                                  not null,
    OrderDate       DATETIME      default CURRENT_TIMESTAMP not null,
    ShipDate        DATETIME,
    SubTotal        REAL default 0.0000            not null,
    TaxAmt          REAL default 0.0000            not null,
    Freight         REAL default 0.0000            not null,
    TotalDue        REAL                          not null,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (EmployeeID) references Employee(BusinessEntityID),
    foreign key (VendorID) references Vendor(BusinessEntityID),
    foreign key (ShipMethodID) references ShipMethod(ShipMethodID)
);
CREATE TABLE PurchaseOrderDetail
(
    PurchaseOrderID       INTEGER                            not null,
    PurchaseOrderDetailID INTEGER
        primary key autoincrement,
    DueDate               DATETIME                           not null,
    OrderQty              INTEGER                           not null,
    ProductID             INTEGER                            not null,
    UnitPrice             REAL                            not null,
    LineTotal             REAL                            not null,
    ReceivedQty           REAL                            not null,
    RejectedQty           REAL                            not null,
    StockedQty            REAL                            not null,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE WorkOrder
(
    WorkOrderID   INTEGER
        primary key autoincrement,
    ProductID     INTEGER                             not null,
    OrderQty      INTEGER                             not null,
    StockedQty    INTEGER                             not null,
    ScrappedQty   INTEGER                           not null,
    StartDate     DATETIME                            not null,
    EndDate       DATETIME,
    DueDate       DATETIME                            not null,
    ScrapReasonID INTEGER,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID),
    foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID)
);
CREATE TABLE WorkOrderRouting
(
    WorkOrderID        INTEGER                             not null,
    ProductID          INTEGER                             not null,
    OperationSequence  INTEGER                             not null,
    LocationID         INTEGER                             not null,
    ScheduledStartDate DATETIME                            not null,
    ScheduledEndDate   DATETIME                            not null,
    ActualStartDate    DATETIME,
    ActualEndDate      DATETIME,
    ActualResourceHrs  REAL,
    PlannedCost        REAL                      not null,
    ActualCost         REAL,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    primary key (WorkOrderID, ProductID, OperationSequence),
    foreign key (WorkOrderID) references WorkOrder(WorkOrderID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE Customer
(
    CustomerID    INTEGER
        primary key,
    PersonID      INTEGER,
    StoreID       INTEGER,
    TerritoryID   INTEGER,
    AccountNumber TEXT                         not null
            unique,
    rowguid       TEXT                         not null
            unique,
    ModifiedDate  DATETIME default current_timestamp not null,
    foreign key (PersonID) references Person(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID),
    foreign key (StoreID) references Store(BusinessEntityID)
);
CREATE TABLE ProductListPriceHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    ListPrice    REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE IF NOT EXISTS "Address"
(
    AddressID       INTEGER
        primary key autoincrement,
    AddressLine1    TEXT                               not null,
    AddressLine2    TEXT,
    City            TEXT                               not null,
    StateProvinceID INTEGER                            not null
        references StateProvince,
    PostalCode      TEXT                               not null,
    SpatialLocation TEXT,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode)
);
CREATE TABLE IF NOT EXISTS "AddressType"
(
    AddressTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    rowguid       TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "BillOfMaterials"
(
    BillOfMaterialsID INTEGER
        primary key autoincrement,
    ProductAssemblyID INTEGER
        references Product,
    ComponentID       INTEGER                            not null
        references Product,
    StartDate         DATETIME default current_timestamp not null,
    EndDate           DATETIME,
    UnitMeasureCode   TEXT                               not null
        references UnitMeasure,
    BOMLevel          INTEGER                            not null,
    PerAssemblyQty    REAL     default 1.00              not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    unique (ProductAssemblyID, ComponentID, StartDate)
);
CREATE TABLE IF NOT EXISTS "BusinessEntity"
(
    BusinessEntityID INTEGER
        primary key autoincrement,
    rowguid          TEXT                               not null
        unique,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "ContactType"
(
    ContactTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "CurrencyRate"
(
    CurrencyRateID   INTEGER
        primary key autoincrement,
    CurrencyRateDate DATETIME                           not null,
    FromCurrencyCode TEXT                               not null
        references Currency,
    ToCurrencyCode   TEXT                               not null
        references Currency,
    AverageRate      REAL                               not null,
    EndOfDayRate     REAL                               not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode)
);
CREATE TABLE IF NOT EXISTS "Department"
(
    DepartmentID INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    GroupName    TEXT                               not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    DepartmentID     INTEGER                            not null
        references Department,
    ShiftID          INTEGER                            not null
        references Shift,
    StartDate        DATE                               not null,
    EndDate          DATE,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID)
);
CREATE TABLE IF NOT EXISTS "EmployeePayHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    RateChangeDate   DATETIME                           not null,
    Rate             REAL                               not null,
    PayFrequency     INTEGER                            not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, RateChangeDate)
);
CREATE TABLE IF NOT EXISTS "JobCandidate"
(
    JobCandidateID   INTEGER
        primary key autoincrement,
    BusinessEntityID INTEGER
        references Employee,
    Resume           TEXT,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Location"
(
    LocationID   INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    CostRate     REAL     default 0.0000            not null,
    Availability REAL     default 0.00              not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "PhoneNumberType"
(
    PhoneNumberTypeID INTEGER
        primary key autoincrement,
    Name              TEXT                               not null,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Product"
(
    ProductID             INTEGER
        primary key autoincrement,
    Name                  TEXT                               not null
        unique,
    ProductNumber         TEXT                               not null
        unique,
    MakeFlag              INTEGER  default 1                 not null,
    FinishedGoodsFlag     INTEGER  default 1                 not null,
    Color                 TEXT,
    SafetyStockLevel      INTEGER                            not null,
    ReorderPoint          INTEGER                            not null,
    StandardCost          REAL                               not null,
    ListPrice             REAL                               not null,
    Size                  TEXT,
    SizeUnitMeasureCode   TEXT
        references UnitMeasure,
    WeightUnitMeasureCode TEXT
        references UnitMeasure,
    Weight                REAL,
    DaysToManufacture     INTEGER                            not null,
    ProductLine           TEXT,
    Class                 TEXT,
    Style                 TEXT,
    ProductSubcategoryID  INTEGER
        references ProductSubcategory,
    ProductModelID        INTEGER
        references ProductModel,
    SellStartDate         DATETIME                           not null,
    SellEndDate           DATETIME,
    DiscontinuedDate      DATETIME,
    rowguid               TEXT                               not null
        unique,
    ModifiedDate          DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Document"
(
    DocumentNode    TEXT                               not null
        primary key,
    DocumentLevel   INTEGER,
    Title           TEXT                               not null,
    Owner           INTEGER                            not null
        references Employee,
    FolderFlag      INTEGER  default 0                 not null,
    FileName        TEXT                               not null,
    FileExtension   TEXT                               not null,
    Revision        TEXT                               not null,
    ChangeNumber    INTEGER  default 0                 not null,
    Status          INTEGER                            not null,
    DocumentSummary TEXT,
    Document        BLOB,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (DocumentLevel, DocumentNode)
);
CREATE TABLE IF NOT EXISTS "StateProvince"
(
    StateProvinceID         INTEGER
        primary key autoincrement,
    StateProvinceCode       TEXT                               not null,
    CountryRegionCode       TEXT                               not null
        references CountryRegion,
    IsOnlyStateProvinceFlag INTEGER  default 1                 not null,
    Name                    TEXT                               not null
        unique,
    TerritoryID             INTEGER                            not null
        references SalesTerritory,
    rowguid                 TEXT                               not null
        unique,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    unique (StateProvinceCode, CountryRegionCode)
);
CREATE TABLE IF NOT EXISTS "CreditCard"
(
    CreditCardID INTEGER
        primary key autoincrement,
    CardType     TEXT                               not null,
    CardNumber   TEXT                               not null
        unique,
    ExpMonth     INTEGER                            not null,
    ExpYear      INTEGER                            not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "SalesOrderHeader"
(
    SalesOrderID           INTEGER
        primary key autoincrement,
    RevisionNumber         INTEGER  default 0                 not null,
    OrderDate              DATETIME default CURRENT_TIMESTAMP not null,
    DueDate                DATETIME                           not null,
    ShipDate               DATETIME,
    Status                 INTEGER  default 1                 not null,
    OnlineOrderFlag        INTEGER  default 1                 not null,
    SalesOrderNumber       TEXT                               not null
        unique,
    PurchaseOrderNumber    TEXT,
    AccountNumber          TEXT,
    CustomerID             INTEGER                            not null
        references Customer,
    SalesPersonID          INTEGER
        references SalesPerson,
    TerritoryID            INTEGER
        references SalesTerritory,
    BillToAddressID        INTEGER                            not null
        references Address,
    ShipToAddressID        INTEGER                            not null
        references Address,
    ShipMethodID           INTEGER                            not null
        references Address,
    CreditCardID           INTEGER
        references CreditCard,
    CreditCardApprovalCode TEXT,
    CurrencyRateID         INTEGER
        references CurrencyRate,
    SubTotal               REAL     default 0.0000            not null,
    TaxAmt                 REAL     default 0.0000            not null,
    Freight                REAL     default 0.0000            not null,
    TotalDue               REAL                               not null,
    Comment                TEXT,
    rowguid                TEXT                               not null
        unique,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
 | 
| 
	simpson_episodes | 
	State the name of director for the 'Treehouse of Horror XIX' episode. | 
	"Treehouse of Horror XIX" is the title of episode; 'director' is the role of person; name refers to person | 
	SELECT T2.person FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Treehouse of Horror XIX' AND T2.role = 'director'; | 
	CREATE TABLE IF NOT EXISTS "Episode"
(
    episode_id       TEXT
        constraint Episode_pk
            primary key,
    season           INTEGER,
    episode          INTEGER,
    number_in_series INTEGER,
    title            TEXT,
    summary          TEXT,
    air_date         TEXT,
    episode_image    TEXT,
    rating           REAL,
    votes            INTEGER
);
CREATE TABLE Person
(
    name          TEXT
        constraint Person_pk
            primary key,
    birthdate     TEXT,
    birth_name    TEXT,
    birth_place   TEXT,
    birth_region  TEXT,
    birth_country TEXT,
    height_meters REAL,
    nickname      TEXT
);
CREATE TABLE Award
(
    award_id       INTEGER
            primary key,
    organization   TEXT,
    year           INTEGER,
    award_category TEXT,
    award          TEXT,
    person         TEXT,
    role           TEXT,
    episode_id     TEXT,
    season         TEXT,
    song           TEXT,
    result         TEXT,
    foreign key (person) references Person(name),
    foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Character_Award
(
    award_id  INTEGER,
    character TEXT,
    foreign key (award_id) references Award(award_id)
);
CREATE TABLE Credit
(
    episode_id TEXT,
    category   TEXT,
    person     TEXT,
    role       TEXT,
    credited   TEXT,
    foreign key (episode_id) references Episode(episode_id),
    foreign key (person) references Person(name)
);
CREATE TABLE Keyword
(
    episode_id TEXT,
    keyword    TEXT,
    primary key (episode_id, keyword),
    foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Vote
(
    episode_id TEXT,
    stars      INTEGER,
    votes      INTEGER,
    percent    REAL,
    foreign key (episode_id) references Episode(episode_id)
);
 | 
| 
	movies_4 | 
	How many female characters are there in the movie "Spider-Man 3"? | 
	female characters refer to gender = 'Female'; "Spider-Man 3" refers to title = 'Spider-Man 3' | 
	SELECT COUNT(*) FROM movie AS T1 INNER JOIN movie_cast AS T2 ON T1.movie_id = T2.movie_id INNER JOIN gender AS T3 ON T2.gender_id = T3.gender_id WHERE T1.title = 'Spider-Man 3' AND T3.gender = 'Female' | 
	CREATE TABLE country
(
    country_id       INTEGER not null
            primary key,
    country_iso_code TEXT  default NULL,
    country_name     TEXT default NULL
);
CREATE TABLE department
(
    department_id   INTEGER not null
            primary key,
    department_name TEXT default NULL
);
CREATE TABLE gender
(
    gender_id INTEGER not null
            primary key,
    gender    TEXT default NULL
);
CREATE TABLE genre
(
    genre_id   INTEGER not null
            primary key,
    genre_name TEXT default NULL
);
CREATE TABLE keyword
(
    keyword_id   INTEGER not null
            primary key,
    keyword_name TEXT default NULL
);
CREATE TABLE language
(
    language_id   INTEGER not null
            primary key,
    language_code TEXT  default NULL,
    language_name TEXT default NULL
);
CREATE TABLE language_role
(
    role_id       INTEGER not null
            primary key,
    language_role TEXT default NULL
);
CREATE TABLE movie
(
    movie_id    INTEGER not null
            primary key,
    title        TEXT  default NULL,
    budget       INTEGER            default NULL,
    homepage     TEXT  default NULL,
    overview     TEXT  default NULL,
    popularity   REAL default NULL,
    release_date DATE           default NULL,
    revenue      INTEGER     default NULL,
    runtime      INTEGER           default NULL,
    movie_status TEXT    default NULL,
    tagline      TEXT  default NULL,
    vote_average REAL  default NULL,
    vote_count   INTEGER            default NULL
);
CREATE TABLE movie_genres
(
    movie_id INTEGER default NULL,
    genre_id INTEGER default NULL,
    foreign key (genre_id) references genre(genre_id),
    foreign key (movie_id) references movie(movie_id)
);
CREATE TABLE movie_languages
(
    movie_id         INTEGER default NULL,
    language_id      INTEGER default NULL,
    language_role_id INTEGER default NULL,
    foreign key (language_id) references language(language_id),
    foreign key (movie_id) references movie(movie_id),
    foreign key (language_role_id) references language_role(role_id)
);
CREATE TABLE person
(
    person_id   INTEGER not null
            primary key,
    person_name TEXT default NULL
);
CREATE TABLE movie_crew
(
    movie_id      INTEGER          default NULL,
    person_id     INTEGER          default NULL,
    department_id INTEGER          default NULL,
    job           TEXT default NULL,
    foreign key (department_id) references department(department_id),
    foreign key (movie_id) references movie(movie_id),
    foreign key (person_id) references person(person_id)
);
CREATE TABLE production_company
(
    company_id   INTEGER not null
            primary key,
    company_name TEXT default NULL
);
CREATE TABLE production_country
(
    movie_id   INTEGER default NULL,
    country_id INTEGER default NULL,
    foreign key (country_id) references country(country_id),
    foreign key (movie_id) references movie(movie_id)
);
CREATE TABLE movie_cast
(
    movie_id       INTEGER          default NULL,
    person_id      INTEGER          default NULL,
    character_name TEXT default NULL,
    gender_id      INTEGER          default NULL,
    cast_order     INTEGER       default NULL,
    foreign key (gender_id) references gender(gender_id),
    foreign key (movie_id) references movie(movie_id),
    foreign key (person_id) references person(person_id)
);
CREATE TABLE IF NOT EXISTS "movie_keywords"
(
    movie_id   INTEGER default NULL
        references movie,
    keyword_id INTEGER default NULL
        references keyword
);
CREATE TABLE IF NOT EXISTS "movie_company"
(
    movie_id   INTEGER default NULL
        references movie,
    company_id INTEGER default NULL
        references production_company
);
 | 
| 
	food_inspection_2 | 
	List down the dba name of restaurants that were inspected due to license. | 
	inspected due to license refers to inspection_type = 'License' | 
	SELECT T1.dba_name FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no WHERE T2.inspection_type = 'License' | 
	CREATE TABLE employee
(
    employee_id INTEGER
            primary key,
    first_name  TEXT,
    last_name   TEXT,
    address     TEXT,
    city        TEXT,
    state       TEXT,
    zip         INTEGER,
    phone       TEXT,
    title       TEXT,
    salary      INTEGER,
    supervisor  INTEGER,
    foreign key (supervisor) references employee(employee_id)
);
CREATE TABLE establishment
(
    license_no    INTEGER
            primary key,
    dba_name      TEXT,
    aka_name      TEXT,
    facility_type TEXT,
    risk_level    INTEGER,
    address       TEXT,
    city          TEXT,
    state         TEXT,
    zip           INTEGER,
    latitude      REAL,
    longitude     REAL,
    ward          INTEGER
);
CREATE TABLE inspection
(
    inspection_id   INTEGER
            primary key,
    inspection_date DATE,
    inspection_type TEXT,
    results         TEXT,
    employee_id     INTEGER,
    license_no      INTEGER,
    followup_to     INTEGER,
    foreign key (employee_id) references employee(employee_id),
    foreign key (license_no) references establishment(license_no),
    foreign key (followup_to) references inspection(inspection_id)
);
CREATE TABLE inspection_point
(
    point_id    INTEGER
            primary key,
    Description TEXT,
    category    TEXT,
    code        TEXT,
    fine        INTEGER,
    point_level TEXT
);
CREATE TABLE violation
(
    inspection_id     INTEGER,
    point_id          INTEGER,
    fine              INTEGER,
    inspector_comment TEXT,
    primary key (inspection_id, point_id),
    foreign key (inspection_id) references inspection(inspection_id),
    foreign key (point_id) references inspection_point(point_id)
);
 | 
| 
	cars | 
	Which country produced the car with the lowest price? | 
	the lowest price refers to min(price) | 
	SELECT T3.country FROM price AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID INNER JOIN country AS T3 ON T3.origin = T2.country ORDER BY T1.price ASC LIMIT 1 | 
	CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
);
CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
);
CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
);
CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
);
 | 
| 
	student_loan | 
	Please list the departments the students are absent from school for 9 months are in. | 
	absent from school for 9 months refers to month = 9 | 
	SELECT T2.organ FROM longest_absense_from_school AS T1 INNER JOIN enlist AS T2 ON T1.`name` = T2.`name` WHERE T1.`month` = 9 | 
	CREATE TABLE bool
(
    "name" TEXT default '' not null
        primary key
);
CREATE TABLE person
(
    "name" TEXT default '' not null
        primary key
);
CREATE TABLE disabled
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE enlist
(
    "name"  TEXT not null,
    organ TEXT not null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE filed_for_bankrupcy
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE longest_absense_from_school
(
    "name"  TEXT default '' not null
        primary key,
    "month" INTEGER       default 0  null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE male
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE no_payment_due
(
    "name" TEXT default '' not null
        primary key,
    bool TEXT             null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade,
        foreign key (bool) references bool ("name")
            on update cascade on delete cascade
);
CREATE TABLE unemployed
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE `enrolled` (
  `name` TEXT NOT NULL,
  `school` TEXT NOT NULL,
  `month` INTEGER NOT NULL DEFAULT 0,
  PRIMARY KEY (`name`,`school`),
  FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
);
 | 
| 
	legislator | 
	What is the ratio between male and female legislators? | 
	ratio = DIVIDE(SUM(gender_bio = 'M'),  SUM(gender_bio = 'F')); male refers to gender_bio = 'M'; female refers to gender_bio = 'F' | 
	SELECT CAST(SUM(CASE WHEN gender_bio = 'M' THEN 1 ELSE 0 END) AS REAL) / SUM(CASE WHEN gender_bio = 'F' THEN 1 ELSE 0 END) FROM historical | 
	CREATE TABLE current
(
    ballotpedia_id      TEXT,
    bioguide_id         TEXT,
    birthday_bio        DATE,
    cspan_id            REAL,
    fec_id              TEXT,
    first_name          TEXT,
    gender_bio          TEXT,
    google_entity_id_id TEXT,
    govtrack_id         INTEGER,
    house_history_id    REAL,
    icpsr_id            REAL,
    last_name           TEXT,
    lis_id              TEXT,
    maplight_id         REAL,
    middle_name         TEXT,
    nickname_name       TEXT,
    official_full_name  TEXT,
    opensecrets_id      TEXT,
    religion_bio        TEXT,
    suffix_name         TEXT,
    thomas_id           INTEGER,
    votesmart_id        REAL,
    wikidata_id         TEXT,
    wikipedia_id        TEXT,
        primary key (bioguide_id, cspan_id)
);
CREATE TABLE IF NOT EXISTS "current-terms"
(
    address            TEXT,
    bioguide           TEXT,
    caucus             TEXT,
    chamber            TEXT,
    class              REAL,
    contact_form       TEXT,
    district           REAL,
    end                TEXT,
    fax                TEXT,
    last               TEXT,
    name               TEXT,
    office             TEXT,
    party              TEXT,
    party_affiliations TEXT,
    phone              TEXT,
    relation           TEXT,
    rss_url            TEXT,
    start              TEXT,
    state              TEXT,
    state_rank         TEXT,
    title              TEXT,
    type               TEXT,
    url                TEXT,
    primary key (bioguide, end),
    foreign key (bioguide) references current(bioguide_id)
);
CREATE TABLE historical
(
    ballotpedia_id             TEXT,
    bioguide_id                TEXT
            primary key,
    bioguide_previous_id       TEXT,
    birthday_bio               TEXT,
    cspan_id                   TEXT,
    fec_id                     TEXT,
    first_name                 TEXT,
    gender_bio                 TEXT,
    google_entity_id_id        TEXT,
    govtrack_id                INTEGER,
    house_history_alternate_id TEXT,
    house_history_id           REAL,
    icpsr_id                   REAL,
    last_name                  TEXT,
    lis_id                     TEXT,
    maplight_id                TEXT,
    middle_name                TEXT,
    nickname_name              TEXT,
    official_full_name         TEXT,
    opensecrets_id             TEXT,
    religion_bio               TEXT,
    suffix_name                TEXT,
    thomas_id                  TEXT,
    votesmart_id               TEXT,
    wikidata_id                TEXT,
    wikipedia_id               TEXT
);
CREATE TABLE IF NOT EXISTS "historical-terms"
(
    address            TEXT,
    bioguide           TEXT
            primary key,
    chamber            TEXT,
    class              REAL,
    contact_form       TEXT,
    district           REAL,
    end                TEXT,
    fax                TEXT,
    last               TEXT,
    middle             TEXT,
    name               TEXT,
    office             TEXT,
    party              TEXT,
    party_affiliations TEXT,
    phone              TEXT,
    relation           TEXT,
    rss_url            TEXT,
    start              TEXT,
    state              TEXT,
    state_rank         TEXT,
    title              TEXT,
    type               TEXT,
    url                TEXT,
    foreign key (bioguide) references historical(bioguide_id)
);
CREATE TABLE IF NOT EXISTS "social-media"
(
    bioguide     TEXT
            primary key,
    facebook     TEXT,
    facebook_id  REAL,
    govtrack     REAL,
    instagram    TEXT,
    instagram_id REAL,
    thomas       INTEGER,
    twitter      TEXT,
    twitter_id   REAL,
    youtube      TEXT,
    youtube_id   TEXT,
    foreign key (bioguide) references current(bioguide_id)
);
 | 
| 
	olympics | 
	Calculate the bmi of the competitor id 147420. | 
	DIVIDE(weight), MULTIPLY(height, height) where id = 147420; | 
	SELECT CAST(T1.weight AS REAL) / (T1.height * T1.height) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id WHERE T2.id = 147420 | 
	CREATE TABLE city
(
    id        INTEGER not null
            primary key,
    city_name TEXT default NULL
);
CREATE TABLE games
(
    id         INTEGER not null
            primary key,
    games_year INTEGER          default NULL,
    games_name TEXT default NULL,
    season     TEXT default NULL
);
CREATE TABLE games_city
(
    games_id INTEGER default NULL,
    city_id  INTEGER default NULL,
    foreign key (city_id) references city(id),
    foreign key (games_id) references games(id)
);
CREATE TABLE medal
(
    id         INTEGER not null
            primary key,
    medal_name TEXT default NULL
);
CREATE TABLE noc_region
(
    id          INTEGER not null
            primary key,
    noc         TEXT   default NULL,
    region_name TEXT default NULL
);
CREATE TABLE person
(
    id        INTEGER not null
        primary key,
    full_name TEXT default NULL,
    gender    TEXT  default NULL,
    height    INTEGER          default NULL,
    weight    INTEGER          default NULL
);
CREATE TABLE games_competitor
(
    id        INTEGER not null
            primary key,
    games_id  INTEGER default NULL,
    person_id INTEGER default NULL,
    age       INTEGER default NULL,
    foreign key (games_id) references games(id),
    foreign key (person_id) references person(id)
);
CREATE TABLE person_region
(
    person_id INTEGER default NULL,
    region_id INTEGER default NULL,
    foreign key (person_id) references person(id),
    foreign key (region_id) references noc_region(id)
);
CREATE TABLE sport
(
    id         INTEGER not null
            primary key,
    sport_name TEXT default NULL
);
CREATE TABLE event
(
    id         INTEGER not null
            primary key,
    sport_id   INTEGER          default NULL,
    event_name TEXT default NULL,
    foreign key (sport_id) references sport(id)
);
CREATE TABLE competitor_event
(
    event_id      INTEGER default NULL,
    competitor_id INTEGER default NULL,
    medal_id      INTEGER default NULL,
    foreign key (competitor_id) references games_competitor(id),
    foreign key (event_id) references event(id),
    foreign key (medal_id) references medal(id)
);
 | 
| 
	hockey | 
	For the goalie who had the most shutouts in 2010, what's his catching hand? | 
	the most shutouts refer to MAX(SHO); catching hand refers to shootCatch; year = 2010; | 
	SELECT T2.shootCatch FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID WHERE T1.year = 2010 GROUP BY T2.shootCatch ORDER BY SUM(T1.SHO) DESC LIMIT 1 | 
	CREATE TABLE AwardsMisc
(
    name  TEXT not null
        primary key,
    ID    TEXT,
    award TEXT,
    year  INTEGER,
    lgID  TEXT,
    note  TEXT
);
CREATE TABLE HOF
(
    year     INTEGER,
    hofID    TEXT not null
        primary key,
    name     TEXT,
    category TEXT
);
CREATE TABLE Teams
(
    year       INTEGER          not null,
    lgID       TEXT,
    tmID       TEXT not null,
    franchID   TEXT,
    confID     TEXT,
    divID      TEXT,
    rank       INTEGER,
    playoff    TEXT,
    G          INTEGER,
    W          INTEGER,
    L          INTEGER,
    T          INTEGER,
    OTL        TEXT,
    Pts        INTEGER,
    SoW        TEXT,
    SoL        TEXT,
    GF         INTEGER,
    GA         INTEGER,
    name       TEXT,
    PIM        TEXT,
    BenchMinor TEXT,
    PPG        TEXT,
    PPC       TEXT,
    SHA        TEXT,
    PKG       TEXT,
    PKC        TEXT,
    SHF        TEXT,
    primary key (year, tmID)
);
CREATE TABLE Coaches
(
    coachID TEXT    not null,
    year    INTEGER not null,
    tmID    TEXT    not null,
    lgID    TEXT,
    stint   INTEGER not null,
    notes   TEXT,
    g       INTEGER,
    w       INTEGER,
    l       INTEGER,
    t       INTEGER,
    postg   TEXT,
    postw   TEXT,
    postl   TEXT,
    postt   TEXT,
    primary key (coachID, year, tmID, stint),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade
);
CREATE TABLE AwardsCoaches
(
    coachID TEXT,
    award   TEXT,
    year    INTEGER,
    lgID    TEXT,
    note    TEXT,
    foreign key (coachID) references Coaches (coachID)
);
CREATE TABLE Master
(
    playerID     TEXT,
    coachID      TEXT,
    hofID        TEXT,
    firstName    TEXT,
    lastName     TEXT not null,
    nameNote     TEXT,
    nameGiven    TEXT,
    nameNick     TEXT,
    height       TEXT,
    weight       TEXT,
    shootCatch   TEXT,
    legendsID    TEXT,
    ihdbID       TEXT,
    hrefID       TEXT,
    firstNHL     TEXT,
    lastNHL      TEXT,
    firstWHA     TEXT,
    lastWHA     TEXT,
    pos          TEXT,
    birthYear    TEXT,
    birthMon     TEXT,
    birthDay     TEXT,
    birthCountry TEXT,
    birthState   TEXT,
    birthCity    TEXT,
    deathYear    TEXT,
    deathMon     TEXT,
    deathDay     TEXT,
    deathCountry TEXT,
    deathState   TEXT,
    deathCity    TEXT,
    foreign key (coachID) references Coaches (coachID)
            on update cascade on delete cascade
);
CREATE TABLE AwardsPlayers
(
    playerID TEXT    not null,
    award    TEXT    not null,
    year     INTEGER not null,
    lgID     TEXT,
    note     TEXT,
    pos      TEXT,
    primary key (playerID, award, year),
    foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE CombinedShutouts
(
    year      INTEGER,
    month     INTEGER,
    date      INTEGER,
    tmID      TEXT,
    oppID     TEXT,
    "R/P"     TEXT,
    IDgoalie1 TEXT,
    IDgoalie2 TEXT,
    foreign key (IDgoalie1) references Master (playerID)
            on update cascade on delete cascade,
    foreign key (IDgoalie2) references  Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE Goalies
(
    playerID TEXT    not null,
    year     INTEGER not null,
    stint    INTEGER not null,
    tmID     TEXT,
    lgID     TEXT,
    GP       TEXT,
    Min      TEXT,
    W        TEXT,
    L        TEXT,
    "T/OL"   TEXT,
    ENG      TEXT,
    SHO      TEXT,
    GA       TEXT,
    SA       TEXT,
    PostGP   TEXT,
    PostMin  TEXT,
    PostW    TEXT,
    PostL    TEXT,
    PostT    TEXT,
    PostENG  TEXT,
    PostSHO  TEXT,
    PostGA   TEXT,
    PostSA   TEXT,
    primary key (playerID, year, stint),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE GoaliesSC
(
    playerID TEXT    not null,
    year     INTEGER not null,
    tmID     TEXT,
    lgID     TEXT,
    GP       INTEGER,
    Min      INTEGER,
    W        INTEGER,
    L        INTEGER,
    T        INTEGER,
    SHO      INTEGER,
    GA       INTEGER,
    primary key (playerID, year),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE GoaliesShootout
(
    playerID TEXT,
    year     INTEGER,
    stint    INTEGER,
    tmID     TEXT,
    W        INTEGER,
    L        INTEGER,
    SA       INTEGER,
    GA       INTEGER,
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (playerID)  references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE Scoring
(
    playerID  TEXT,
    year      INTEGER,
    stint     INTEGER,
    tmID      TEXT,
    lgID      TEXT,
    pos       TEXT,
    GP        INTEGER,
    G         INTEGER,
    A         INTEGER,
    Pts       INTEGER,
    PIM       INTEGER,
    "+/-"     TEXT,
    PPG       TEXT,
    PPA       TEXT,
    SHG       TEXT,
    SHA       TEXT,
    GWG       TEXT,
    GTG       TEXT,
    SOG       TEXT,
    PostGP    TEXT,
    PostG     TEXT,
    PostA     TEXT,
    PostPts   TEXT,
    PostPIM   TEXT,
    "Post+/-" TEXT,
    PostPPG   TEXT,
    PostPPA   TEXT,
    PostSHG   TEXT,
    PostSHA   TEXT,
    PostGWG  TEXT,
    PostSOG   TEXT,
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE ScoringSC
(
    playerID TEXT,
    year     INTEGER,
    tmID     TEXT,
    lgID     TEXT,
    pos      TEXT,
    GP       INTEGER,
    G        INTEGER,
    A        INTEGER,
    Pts      INTEGER,
    PIM      INTEGER,
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE ScoringShootout
(
    playerID TEXT,
    year     INTEGER,
    stint    INTEGER,
    tmID     TEXT,
    S        INTEGER,
    G        INTEGER,
    GDG      INTEGER,
     foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE ScoringSup
(
    playerID TEXT,
    year     INTEGER,
    PPA      TEXT,
    SHA      TEXT,
     foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE SeriesPost
(
    year        INTEGER,
    round       TEXT,
    series      TEXT,
    tmIDWinner  TEXT,
    lgIDWinner  TEXT,
    tmIDLoser   TEXT,
    lgIDLoser   TEXT,
    W           INTEGER,
    L           INTEGER,
    T           INTEGER,
    GoalsWinner INTEGER,
    GoalsLoser  INTEGER,
    note        TEXT,
    foreign key (year, tmIDWinner) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (year, tmIDLoser) references Teams (year, tmID)
        on update cascade on delete cascade
);
CREATE TABLE TeamSplits
(
    year  INTEGER          not null,
    lgID  TEXT,
    tmID  TEXT not null,
    hW    INTEGER,
    hL    INTEGER,
    hT    INTEGER,
    hOTL  TEXT,
    rW    INTEGER,
    rL    INTEGER,
    rT    INTEGER,
    rOTL  TEXT,
    SepW  TEXT,
    SepL  TEXT,
    SepT  TEXT,
    SepOL TEXT,
    OctW TEXT,
    OctL  TEXT,
    OctT  TEXT,
    OctOL TEXT,
    NovW  TEXT,
    NovL  TEXT,
    NovT  TEXT,
    NovOL TEXT,
    DecW  TEXT,
    DecL  TEXT,
    DecT  TEXT,
    DecOL TEXT,
    JanW  INTEGER,
    JanL  INTEGER,
    JanT  INTEGER,
    JanOL TEXT,
    FebW  INTEGER,
    FebL  INTEGER,
    FebT  INTEGER,
    FebOL TEXT,
    MarW  TEXT,
    MarL  TEXT,
    MarT  TEXT,
    MarOL TEXT,
    AprW  TEXT,
    AprL  TEXT,
    AprT  TEXT,
    AprOL TEXT,
    primary key (year, tmID),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade
);
CREATE TABLE TeamVsTeam
(
    year  INTEGER          not null,
    lgID  TEXT,
    tmID  TEXT not null,
    oppID TEXT not null,
    W     INTEGER,
    L     INTEGER,
    T     INTEGER,
    OTL   TEXT,
    primary key (year, tmID, oppID),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (oppID, year) references Teams (tmID, year)
        on update cascade on delete cascade
);
CREATE TABLE TeamsHalf
(
    year INTEGER          not null,
    lgID TEXT,
    tmID TEXT not null,
    half INTEGER          not null,
    rank INTEGER,
    G    INTEGER,
    W    INTEGER,
    L    INTEGER,
    T    INTEGER,
    GF   INTEGER,
    GA   INTEGER,
    primary key (year, tmID, half),
    foreign key (tmID, year) references Teams (tmID, year)
        on update cascade on delete cascade
);
CREATE TABLE TeamsPost
(
    year       INTEGER          not null,
    lgID       TEXT,
    tmID       TEXT not null,
    G          INTEGER,
    W          INTEGER,
    L          INTEGER,
    T          INTEGER,
    GF         INTEGER,
    GA         INTEGER,
    PIM        TEXT,
    BenchMinor TEXT,
    PPG        TEXT,
    PPC        TEXT,
    SHA        TEXT,
    PKG        TEXT,
    PKC        TEXT,
    SHF        TEXT,
    primary key (year, tmID),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade
);
CREATE TABLE TeamsSC
(
    year INTEGER          not null,
    lgID TEXT,
    tmID TEXT not null,
    G    INTEGER,
    W    INTEGER,
    L    INTEGER,
    T    INTEGER,
    GF   INTEGER,
    GA   INTEGER,
    PIM  TEXT,
    primary key (year, tmID),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade
);
CREATE TABLE abbrev
(
    Type     TEXT not null,
    Code     TEXT not null,
    Fullname TEXT,
    primary key (Type, Code)
);
 | 
| 
	public_review_platform | 
	Which city has more Yelp_Business that's more appealing to users, Scottsdale or Anthem? | 
	more appealing to users refers to MAX(review_count); | 
	SELECT city FROM Business ORDER BY review_count DESC LIMIT 1 | 
	CREATE TABLE Attributes
(
    attribute_id   INTEGER
        constraint Attributes_pk
            primary key,
    attribute_name TEXT
);
CREATE TABLE Categories
(
    category_id   INTEGER
        constraint Categories_pk
            primary key,
    category_name TEXT
);
CREATE TABLE Compliments
(
    compliment_id   INTEGER
        constraint Compliments_pk
            primary key,
    compliment_type TEXT
);
CREATE TABLE Days
(
    day_id      INTEGER
        constraint Days_pk
            primary key,
    day_of_week TEXT
);
CREATE TABLE Years
(
    year_id     INTEGER
        constraint Years_pk
            primary key,
    actual_year INTEGER
);
CREATE TABLE IF NOT EXISTS "Business_Attributes"
(
    attribute_id    INTEGER
        constraint Business_Attributes_Attributes_attribute_id_fk
            references Attributes,
    business_id     INTEGER
        constraint Business_Attributes_Business_business_id_fk
            references Business,
    attribute_value TEXT,
    constraint Business_Attributes_pk
        primary key (attribute_id, business_id)
);
CREATE TABLE IF NOT EXISTS "Business_Categories"
(
    business_id INTEGER
        constraint Business_Categories_Business_business_id_fk
            references Business,
    category_id INTEGER
        constraint Business_Categories_Categories_category_id_fk
            references Categories,
    constraint Business_Categories_pk
        primary key (business_id, category_id)
);
CREATE TABLE IF NOT EXISTS "Business_Hours"
(
    business_id  INTEGER
        constraint Business_Hours_Business_business_id_fk
            references Business,
    day_id       INTEGER
        constraint Business_Hours_Days_day_id_fk
            references Days,
    opening_time TEXT,
    closing_time TEXT,
    constraint Business_Hours_pk
        primary key (business_id, day_id)
);
CREATE TABLE IF NOT EXISTS "Checkins"
(
    business_id   INTEGER
        constraint Checkins_Business_business_id_fk
            references Business,
    day_id        INTEGER
        constraint Checkins_Days_day_id_fk
            references Days,
    label_time_0  TEXT,
    label_time_1  TEXT,
    label_time_2  TEXT,
    label_time_3  TEXT,
    label_time_4  TEXT,
    label_time_5  TEXT,
    label_time_6  TEXT,
    label_time_7  TEXT,
    label_time_8  TEXT,
    label_time_9  TEXT,
    label_time_10 TEXT,
    label_time_11 TEXT,
    label_time_12 TEXT,
    label_time_13 TEXT,
    label_time_14 TEXT,
    label_time_15 TEXT,
    label_time_16 TEXT,
    label_time_17 TEXT,
    label_time_18 TEXT,
    label_time_19 TEXT,
    label_time_20 TEXT,
    label_time_21 TEXT,
    label_time_22 TEXT,
    label_time_23 TEXT,
    constraint Checkins_pk
        primary key (business_id, day_id)
);
CREATE TABLE IF NOT EXISTS "Elite"
(
    user_id INTEGER
        constraint Elite_Users_user_id_fk
            references Users,
    year_id INTEGER
        constraint Elite_Years_year_id_fk
            references Years,
    constraint Elite_pk
        primary key (user_id, year_id)
);
CREATE TABLE IF NOT EXISTS "Reviews"
(
    business_id         INTEGER
        constraint Reviews_Business_business_id_fk
            references Business,
    user_id             INTEGER
        constraint Reviews_Users_user_id_fk
            references Users,
    review_stars        INTEGER,
    review_votes_funny  TEXT,
    review_votes_useful TEXT,
    review_votes_cool   TEXT,
    review_length       TEXT,
    constraint Reviews_pk
        primary key (business_id, user_id)
);
CREATE TABLE IF NOT EXISTS "Tips"
(
    business_id INTEGER
        constraint Tips_Business_business_id_fk
            references Business,
    user_id     INTEGER
        constraint Tips_Users_user_id_fk
            references Users,
    likes       INTEGER,
    tip_length  TEXT,
    constraint Tips_pk
        primary key (business_id, user_id)
);
CREATE TABLE IF NOT EXISTS "Users_Compliments"
(
    compliment_id         INTEGER
        constraint Users_Compliments_Compliments_compliment_id_fk
            references Compliments,
    user_id               INTEGER
        constraint Users_Compliments_Users_user_id_fk
            references Users,
    number_of_compliments TEXT,
    constraint Users_Compliments_pk
        primary key (compliment_id, user_id)
);
CREATE TABLE IF NOT EXISTS "Business"
(
    business_id  INTEGER
        constraint Business_pk
            primary key,
    active       TEXT,
    city         TEXT,
    state        TEXT,
    stars        REAL,
    review_count TEXT
);
CREATE TABLE IF NOT EXISTS "Users"
(
    user_id                 INTEGER
        constraint Users_pk
            primary key,
    user_yelping_since_year INTEGER,
    user_average_stars      TEXT,
    user_votes_funny        TEXT,
    user_votes_useful       TEXT,
    user_votes_cool         TEXT,
    user_review_count       TEXT,
    user_fans               TEXT
);
 | 
| 
	works_cycles | 
	What is the thumbnail photo file for the product with the id "979"? | 
	thumbnail photo file refers to ThumbnailPhotoFileName; | 
	SELECT T2.ThumbnailPhotoFileName FROM ProductProductPhoto AS T1 INNER JOIN ProductPhoto AS T2 ON T1.ProductPhotoID = T2.ProductPhotoID WHERE T1.ProductID = 979 | 
	CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
    CountryRegionCode TEXT                          not null
        primary key,
    Name              TEXT                        not null
            unique,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE Culture
(
    CultureID    TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Currency
(
    CurrencyCode TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE CountryRegionCurrency
(
    CountryRegionCode TEXT                          not null,
    CurrencyCode      TEXT                             not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    primary key (CountryRegionCode, CurrencyCode),
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode),
    foreign key (CurrencyCode) references Currency(CurrencyCode)
);
CREATE TABLE Person
(
    BusinessEntityID      INTEGER                                  not null
        primary key,
    PersonType            TEXT                              not null,
    NameStyle             INTEGER default 0                 not null,
    Title                 TEXT,
    FirstName             TEXT                         not null,
    MiddleName            TEXT,
    LastName              TEXT                         not null,
    Suffix                TEXT,
    EmailPromotion        INTEGER        default 0                 not null,
    AdditionalContactInfo TEXT,
    Demographics          TEXT,
    rowguid               TEXT                          not null
            unique,
    ModifiedDate          DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE BusinessEntityContact
(
    BusinessEntityID INTEGER                                 not null,
    PersonID         INTEGER                                 not null,
    ContactTypeID    INTEGER                                 not null,
    rowguid         TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, PersonID, ContactTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (ContactTypeID) references ContactType(ContactTypeID),
    foreign key (PersonID) references Person(BusinessEntityID)
);
CREATE TABLE EmailAddress
(
    BusinessEntityID INTEGER                                 not null,
    EmailAddressID   INTEGER,
    EmailAddress     TEXT,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (EmailAddressID, BusinessEntityID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Employee
(
    BusinessEntityID  INTEGER                                 not null
        primary key,
    NationalIDNumber  TEXT                          not null
            unique,
    LoginID           TEXT                         not null
            unique,
    OrganizationNode  TEXT,
    OrganizationLevel INTEGER,
    JobTitle          TEXT                          not null,
    BirthDate         DATE                                 not null,
    MaritalStatus     TEXT                                 not null,
    Gender            TEXT                                 not null,
    HireDate          DATE                                 not null,
    SalariedFlag      INTEGER default 1                 not null,
    VacationHours     INTEGER   default 0                 not null,
    SickLeaveHours    INTEGER   default 0                 not null,
    CurrentFlag       INTEGER default 1                 not null,
    rowguid           TEXT                          not null
            unique,
    ModifiedDate      DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Password
(
    BusinessEntityID INTEGER                                 not null
        primary key,
    PasswordHash     TEXT                        not null,
    PasswordSalt     TEXT                         not null,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE PersonCreditCard
(
    BusinessEntityID INTEGER                                 not null,
    CreditCardID     INTEGER                                 not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, CreditCardID),
    foreign key (CreditCardID) references CreditCard(CreditCardID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE ProductCategory
(
    ProductCategoryID INTEGER
        primary key autoincrement,
    Name              TEXT                        not null
        unique,
    rowguid           TEXT                         not null
        unique,
    ModifiedDate      DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductDescription
(
    ProductDescriptionID INTEGER
        primary key autoincrement,
    Description          TEXT                        not null,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModel
(
    ProductModelID     INTEGER
        primary key autoincrement,
    Name               TEXT                        not null
        unique,
    CatalogDescription TEXT,
    Instructions       TEXT,
    rowguid            TEXT                         not null
        unique,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModelProductDescriptionCulture
(
    ProductModelID       INTEGER                             not null,
    ProductDescriptionID INTEGER                             not null,
    CultureID            TEXT                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductModelID, ProductDescriptionID, CultureID),
    foreign key (ProductModelID) references ProductModel(ProductModelID),
    foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID),
    foreign key (CultureID) references Culture(CultureID)
);
CREATE TABLE ProductPhoto
(
    ProductPhotoID         INTEGER
        primary key autoincrement,
    ThumbNailPhoto         BLOB,
    ThumbnailPhotoFileName TEXT,
    LargePhoto             BLOB,
    LargePhotoFileName     TEXT,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductSubcategory
(
    ProductSubcategoryID INTEGER
        primary key autoincrement,
    ProductCategoryID    INTEGER                             not null,
    Name                 TEXT                        not null
        unique,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate        DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID)
);
CREATE TABLE SalesReason
(
    SalesReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null,
    ReasonType    TEXT                        not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE SalesTerritory
(
    TerritoryID       INTEGER
        primary key autoincrement,
    Name              TEXT                             not null
        unique,
    CountryRegionCode TEXT                               not null,
    "Group"           TEXT                              not null,
    SalesYTD          REAL default 0.0000            not null,
    SalesLastYear     REAL default 0.0000            not null,
    CostYTD           REAL default 0.0000            not null,
    CostLastYear      REAL default 0.0000            not null,
    rowguid           TEXT                              not null
        unique,
    ModifiedDate      DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode)
);
CREATE TABLE SalesPerson
(
    BusinessEntityID INTEGER                                  not null
        primary key,
    TerritoryID      INTEGER,
    SalesQuota       REAL,
    Bonus            REAL default 0.0000            not null,
    CommissionPct    REAL default 0.0000            not null,
    SalesYTD         REAL default 0.0000            not null,
    SalesLastYear    REAL default 0.0000            not null,
    rowguid          TEXT                              not null
        unique,
    ModifiedDate     DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references Employee(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE SalesPersonQuotaHistory
(
    BusinessEntityID INTEGER                             not null,
    QuotaDate        DATETIME                            not null,
    SalesQuota       REAL                      not null,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, QuotaDate),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesTerritoryHistory
(
    BusinessEntityID INTEGER                             not null,
    TerritoryID      INTEGER                             not null,
    StartDate        DATETIME                            not null,
    EndDate          DATETIME,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, StartDate, TerritoryID),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE ScrapReason
(
    ScrapReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null
        unique,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE Shift
(
    ShiftID      INTEGER
        primary key autoincrement,
    Name         TEXT                        not null
        unique,
    StartTime    TEXT                                not null,
    EndTime      TEXT                                not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    unique (StartTime, EndTime)
);
CREATE TABLE ShipMethod
(
    ShipMethodID INTEGER
        primary key autoincrement,
    Name         TEXT                             not null
        unique,
    ShipBase     REAL default 0.0000            not null,
    ShipRate    REAL default 0.0000            not null,
    rowguid      TEXT                              not null
        unique,
    ModifiedDate DATETIME      default CURRENT_TIMESTAMP not null
);
CREATE TABLE SpecialOffer
(
    SpecialOfferID INTEGER
        primary key autoincrement,
    Description    TEXT                             not null,
    DiscountPct    REAL   default 0.0000            not null,
    Type           TEXT                             not null,
    Category       TEXT                             not null,
    StartDate      DATETIME                            not null,
    EndDate        DATETIME                            not null,
    MinQty         INTEGER   default 0                 not null,
    MaxQty         INTEGER,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE BusinessEntityAddress
(
    BusinessEntityID INTEGER                                 not null,
    AddressID        INTEGER                                 not null,
    AddressTypeID    INTEGER                                 not null,
    rowguid          TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, AddressID, AddressTypeID),
    foreign key (AddressID) references Address(AddressID),
    foreign key (AddressTypeID) references AddressType(AddressTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE SalesTaxRate
(
    SalesTaxRateID  INTEGER
        primary key autoincrement,
    StateProvinceID INTEGER                                  not null,
    TaxType         INTEGER                                  not null,
    TaxRate         REAL default 0.0000            not null,
    Name            TEXT                             not null,
    rowguid         TEXT                              not null
        unique,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    unique (StateProvinceID, TaxType),
    foreign key (StateProvinceID) references StateProvince(StateProvinceID)
);
CREATE TABLE Store
(
    BusinessEntityID INTEGER                             not null
        primary key,
    Name             TEXT                        not null,
    SalesPersonID    INTEGER,
    Demographics     TEXT,
    rowguid          TEXT                             not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (SalesPersonID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesOrderHeaderSalesReason
(
    SalesOrderID  INTEGER                             not null,
    SalesReasonID INTEGER                             not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SalesOrderID, SalesReasonID),
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SalesReasonID) references SalesReason(SalesReasonID)
);
CREATE TABLE TransactionHistoryArchive
(
    TransactionID        INTEGER                             not null
        primary key,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE UnitMeasure
(
    UnitMeasureCode TEXT                             not null
        primary key,
    Name            TEXT                        not null
        unique,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductCostHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    StandardCost REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ProductDocument
(
    ProductID    INTEGER                             not null,
    DocumentNode TEXT                        not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, DocumentNode),
    foreign key (ProductID) references Product(ProductID),
    foreign key (DocumentNode) references Document(DocumentNode)
);
CREATE TABLE ProductInventory
(
    ProductID    INTEGER                             not null,
    LocationID   INTEGER                            not null,
    Shelf        TEXT                         not null,
    Bin          INTEGER                             not null,
    Quantity     INTEGER  default 0                 not null,
    rowguid      TEXT                         not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, LocationID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE ProductProductPhoto
(
    ProductID      INTEGER                             not null,
    ProductPhotoID INTEGER                             not null,
    "Primary"      INTEGER   default 0                 not null,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, ProductPhotoID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID)
);
CREATE TABLE ProductReview
(
    ProductReviewID INTEGER
        primary key autoincrement,
    ProductID       INTEGER                             not null,
    ReviewerName   TEXT                        not null,
    ReviewDate      DATETIME default CURRENT_TIMESTAMP not null,
    EmailAddress    TEXT                         not null,
    Rating          INTEGER                             not null,
    Comments        TEXT,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ShoppingCartItem
(
    ShoppingCartItemID INTEGER
        primary key autoincrement,
    ShoppingCartID     TEXT                         not null,
    Quantity           INTEGER   default 1                 not null,
    ProductID          INTEGER                             not null,
    DateCreated        DATETIME default CURRENT_TIMESTAMP not null,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SpecialOfferProduct
(
    SpecialOfferID INTEGER                             not null,
    ProductID      INTEGER                             not null,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SpecialOfferID, ProductID),
    foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SalesOrderDetail
(
    SalesOrderID          INTEGER                             not null,
    SalesOrderDetailID    INTEGER
        primary key autoincrement,
    CarrierTrackingNumber TEXT,
    OrderQty              INTEGER                             not null,
    ProductID             INTEGER                             not null,
    SpecialOfferID        INTEGER                             not null,
    UnitPrice             REAL                             not null,
    UnitPriceDiscount     REAL   default 0.0000            not null,
    LineTotal             REAL                             not null,
    rowguid               TEXT                             not null
        unique,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID)
);
CREATE TABLE TransactionHistory
(
    TransactionID        INTEGER
        primary key autoincrement,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE Vendor
(
    BusinessEntityID        INTEGER                             not null
        primary key,
    AccountNumber           TEXT                         not null
        unique,
    Name                    TEXT                        not null,
    CreditRating            INTEGER                             not null,
    PreferredVendorStatus   INTEGER   default 1                 not null,
    ActiveFlag              INTEGER   default 1                 not null,
    PurchasingWebServiceURL TEXT,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE ProductVendor
(
    ProductID        INTEGER                             not null,
    BusinessEntityID INTEGER                             not null,
    AverageLeadTime  INTEGER                             not null,
    StandardPrice    REAL                      not null,
    LastReceiptCost  REAL,
    LastReceiptDate  DATETIME,
    MinOrderQty      INTEGER                             not null,
    MaxOrderQty      INTEGER                             not null,
    OnOrderQty       INTEGER,
    UnitMeasureCode  TEXT                             not null,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, BusinessEntityID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (BusinessEntityID) references Vendor(BusinessEntityID),
    foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode)
);
CREATE TABLE PurchaseOrderHeader
(
    PurchaseOrderID INTEGER
        primary key autoincrement,
    RevisionNumber  INTEGER        default 0                 not null,
    Status          INTEGER        default 1                 not null,
    EmployeeID      INTEGER                                  not null,
    VendorID        INTEGER                                  not null,
    ShipMethodID    INTEGER                                  not null,
    OrderDate       DATETIME      default CURRENT_TIMESTAMP not null,
    ShipDate        DATETIME,
    SubTotal        REAL default 0.0000            not null,
    TaxAmt          REAL default 0.0000            not null,
    Freight         REAL default 0.0000            not null,
    TotalDue        REAL                          not null,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (EmployeeID) references Employee(BusinessEntityID),
    foreign key (VendorID) references Vendor(BusinessEntityID),
    foreign key (ShipMethodID) references ShipMethod(ShipMethodID)
);
CREATE TABLE PurchaseOrderDetail
(
    PurchaseOrderID       INTEGER                            not null,
    PurchaseOrderDetailID INTEGER
        primary key autoincrement,
    DueDate               DATETIME                           not null,
    OrderQty              INTEGER                           not null,
    ProductID             INTEGER                            not null,
    UnitPrice             REAL                            not null,
    LineTotal             REAL                            not null,
    ReceivedQty           REAL                            not null,
    RejectedQty           REAL                            not null,
    StockedQty            REAL                            not null,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE WorkOrder
(
    WorkOrderID   INTEGER
        primary key autoincrement,
    ProductID     INTEGER                             not null,
    OrderQty      INTEGER                             not null,
    StockedQty    INTEGER                             not null,
    ScrappedQty   INTEGER                           not null,
    StartDate     DATETIME                            not null,
    EndDate       DATETIME,
    DueDate       DATETIME                            not null,
    ScrapReasonID INTEGER,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID),
    foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID)
);
CREATE TABLE WorkOrderRouting
(
    WorkOrderID        INTEGER                             not null,
    ProductID          INTEGER                             not null,
    OperationSequence  INTEGER                             not null,
    LocationID         INTEGER                             not null,
    ScheduledStartDate DATETIME                            not null,
    ScheduledEndDate   DATETIME                            not null,
    ActualStartDate    DATETIME,
    ActualEndDate      DATETIME,
    ActualResourceHrs  REAL,
    PlannedCost        REAL                      not null,
    ActualCost         REAL,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    primary key (WorkOrderID, ProductID, OperationSequence),
    foreign key (WorkOrderID) references WorkOrder(WorkOrderID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE Customer
(
    CustomerID    INTEGER
        primary key,
    PersonID      INTEGER,
    StoreID       INTEGER,
    TerritoryID   INTEGER,
    AccountNumber TEXT                         not null
            unique,
    rowguid       TEXT                         not null
            unique,
    ModifiedDate  DATETIME default current_timestamp not null,
    foreign key (PersonID) references Person(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID),
    foreign key (StoreID) references Store(BusinessEntityID)
);
CREATE TABLE ProductListPriceHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    ListPrice    REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE IF NOT EXISTS "Address"
(
    AddressID       INTEGER
        primary key autoincrement,
    AddressLine1    TEXT                               not null,
    AddressLine2    TEXT,
    City            TEXT                               not null,
    StateProvinceID INTEGER                            not null
        references StateProvince,
    PostalCode      TEXT                               not null,
    SpatialLocation TEXT,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode)
);
CREATE TABLE IF NOT EXISTS "AddressType"
(
    AddressTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    rowguid       TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "BillOfMaterials"
(
    BillOfMaterialsID INTEGER
        primary key autoincrement,
    ProductAssemblyID INTEGER
        references Product,
    ComponentID       INTEGER                            not null
        references Product,
    StartDate         DATETIME default current_timestamp not null,
    EndDate           DATETIME,
    UnitMeasureCode   TEXT                               not null
        references UnitMeasure,
    BOMLevel          INTEGER                            not null,
    PerAssemblyQty    REAL     default 1.00              not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    unique (ProductAssemblyID, ComponentID, StartDate)
);
CREATE TABLE IF NOT EXISTS "BusinessEntity"
(
    BusinessEntityID INTEGER
        primary key autoincrement,
    rowguid          TEXT                               not null
        unique,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "ContactType"
(
    ContactTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "CurrencyRate"
(
    CurrencyRateID   INTEGER
        primary key autoincrement,
    CurrencyRateDate DATETIME                           not null,
    FromCurrencyCode TEXT                               not null
        references Currency,
    ToCurrencyCode   TEXT                               not null
        references Currency,
    AverageRate      REAL                               not null,
    EndOfDayRate     REAL                               not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode)
);
CREATE TABLE IF NOT EXISTS "Department"
(
    DepartmentID INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    GroupName    TEXT                               not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    DepartmentID     INTEGER                            not null
        references Department,
    ShiftID          INTEGER                            not null
        references Shift,
    StartDate        DATE                               not null,
    EndDate          DATE,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID)
);
CREATE TABLE IF NOT EXISTS "EmployeePayHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    RateChangeDate   DATETIME                           not null,
    Rate             REAL                               not null,
    PayFrequency     INTEGER                            not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, RateChangeDate)
);
CREATE TABLE IF NOT EXISTS "JobCandidate"
(
    JobCandidateID   INTEGER
        primary key autoincrement,
    BusinessEntityID INTEGER
        references Employee,
    Resume           TEXT,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Location"
(
    LocationID   INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    CostRate     REAL     default 0.0000            not null,
    Availability REAL     default 0.00              not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "PhoneNumberType"
(
    PhoneNumberTypeID INTEGER
        primary key autoincrement,
    Name              TEXT                               not null,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Product"
(
    ProductID             INTEGER
        primary key autoincrement,
    Name                  TEXT                               not null
        unique,
    ProductNumber         TEXT                               not null
        unique,
    MakeFlag              INTEGER  default 1                 not null,
    FinishedGoodsFlag     INTEGER  default 1                 not null,
    Color                 TEXT,
    SafetyStockLevel      INTEGER                            not null,
    ReorderPoint          INTEGER                            not null,
    StandardCost          REAL                               not null,
    ListPrice             REAL                               not null,
    Size                  TEXT,
    SizeUnitMeasureCode   TEXT
        references UnitMeasure,
    WeightUnitMeasureCode TEXT
        references UnitMeasure,
    Weight                REAL,
    DaysToManufacture     INTEGER                            not null,
    ProductLine           TEXT,
    Class                 TEXT,
    Style                 TEXT,
    ProductSubcategoryID  INTEGER
        references ProductSubcategory,
    ProductModelID        INTEGER
        references ProductModel,
    SellStartDate         DATETIME                           not null,
    SellEndDate           DATETIME,
    DiscontinuedDate      DATETIME,
    rowguid               TEXT                               not null
        unique,
    ModifiedDate          DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Document"
(
    DocumentNode    TEXT                               not null
        primary key,
    DocumentLevel   INTEGER,
    Title           TEXT                               not null,
    Owner           INTEGER                            not null
        references Employee,
    FolderFlag      INTEGER  default 0                 not null,
    FileName        TEXT                               not null,
    FileExtension   TEXT                               not null,
    Revision        TEXT                               not null,
    ChangeNumber    INTEGER  default 0                 not null,
    Status          INTEGER                            not null,
    DocumentSummary TEXT,
    Document        BLOB,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (DocumentLevel, DocumentNode)
);
CREATE TABLE IF NOT EXISTS "StateProvince"
(
    StateProvinceID         INTEGER
        primary key autoincrement,
    StateProvinceCode       TEXT                               not null,
    CountryRegionCode       TEXT                               not null
        references CountryRegion,
    IsOnlyStateProvinceFlag INTEGER  default 1                 not null,
    Name                    TEXT                               not null
        unique,
    TerritoryID             INTEGER                            not null
        references SalesTerritory,
    rowguid                 TEXT                               not null
        unique,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    unique (StateProvinceCode, CountryRegionCode)
);
CREATE TABLE IF NOT EXISTS "CreditCard"
(
    CreditCardID INTEGER
        primary key autoincrement,
    CardType     TEXT                               not null,
    CardNumber   TEXT                               not null
        unique,
    ExpMonth     INTEGER                            not null,
    ExpYear      INTEGER                            not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "SalesOrderHeader"
(
    SalesOrderID           INTEGER
        primary key autoincrement,
    RevisionNumber         INTEGER  default 0                 not null,
    OrderDate              DATETIME default CURRENT_TIMESTAMP not null,
    DueDate                DATETIME                           not null,
    ShipDate               DATETIME,
    Status                 INTEGER  default 1                 not null,
    OnlineOrderFlag        INTEGER  default 1                 not null,
    SalesOrderNumber       TEXT                               not null
        unique,
    PurchaseOrderNumber    TEXT,
    AccountNumber          TEXT,
    CustomerID             INTEGER                            not null
        references Customer,
    SalesPersonID          INTEGER
        references SalesPerson,
    TerritoryID            INTEGER
        references SalesTerritory,
    BillToAddressID        INTEGER                            not null
        references Address,
    ShipToAddressID        INTEGER                            not null
        references Address,
    ShipMethodID           INTEGER                            not null
        references Address,
    CreditCardID           INTEGER
        references CreditCard,
    CreditCardApprovalCode TEXT,
    CurrencyRateID         INTEGER
        references CurrencyRate,
    SubTotal               REAL     default 0.0000            not null,
    TaxAmt                 REAL     default 0.0000            not null,
    Freight                REAL     default 0.0000            not null,
    TotalDue               REAL                               not null,
    Comment                TEXT,
    rowguid                TEXT                               not null
        unique,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
 | 
| 
	works_cycles | 
	How many Minipumps have been sold? | 
	Minipump is name of a product | 
	SELECT COUNT(OrderQty) FROM SalesOrderDetail WHERE ProductID IN ( SELECT ProductID FROM Product WHERE Name = 'Minipump' ) | 
	CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
    CountryRegionCode TEXT                          not null
        primary key,
    Name              TEXT                        not null
            unique,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE Culture
(
    CultureID    TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Currency
(
    CurrencyCode TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE CountryRegionCurrency
(
    CountryRegionCode TEXT                          not null,
    CurrencyCode      TEXT                             not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    primary key (CountryRegionCode, CurrencyCode),
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode),
    foreign key (CurrencyCode) references Currency(CurrencyCode)
);
CREATE TABLE Person
(
    BusinessEntityID      INTEGER                                  not null
        primary key,
    PersonType            TEXT                              not null,
    NameStyle             INTEGER default 0                 not null,
    Title                 TEXT,
    FirstName             TEXT                         not null,
    MiddleName            TEXT,
    LastName              TEXT                         not null,
    Suffix                TEXT,
    EmailPromotion        INTEGER        default 0                 not null,
    AdditionalContactInfo TEXT,
    Demographics          TEXT,
    rowguid               TEXT                          not null
            unique,
    ModifiedDate          DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE BusinessEntityContact
(
    BusinessEntityID INTEGER                                 not null,
    PersonID         INTEGER                                 not null,
    ContactTypeID    INTEGER                                 not null,
    rowguid         TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, PersonID, ContactTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (ContactTypeID) references ContactType(ContactTypeID),
    foreign key (PersonID) references Person(BusinessEntityID)
);
CREATE TABLE EmailAddress
(
    BusinessEntityID INTEGER                                 not null,
    EmailAddressID   INTEGER,
    EmailAddress     TEXT,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (EmailAddressID, BusinessEntityID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Employee
(
    BusinessEntityID  INTEGER                                 not null
        primary key,
    NationalIDNumber  TEXT                          not null
            unique,
    LoginID           TEXT                         not null
            unique,
    OrganizationNode  TEXT,
    OrganizationLevel INTEGER,
    JobTitle          TEXT                          not null,
    BirthDate         DATE                                 not null,
    MaritalStatus     TEXT                                 not null,
    Gender            TEXT                                 not null,
    HireDate          DATE                                 not null,
    SalariedFlag      INTEGER default 1                 not null,
    VacationHours     INTEGER   default 0                 not null,
    SickLeaveHours    INTEGER   default 0                 not null,
    CurrentFlag       INTEGER default 1                 not null,
    rowguid           TEXT                          not null
            unique,
    ModifiedDate      DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Password
(
    BusinessEntityID INTEGER                                 not null
        primary key,
    PasswordHash     TEXT                        not null,
    PasswordSalt     TEXT                         not null,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE PersonCreditCard
(
    BusinessEntityID INTEGER                                 not null,
    CreditCardID     INTEGER                                 not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, CreditCardID),
    foreign key (CreditCardID) references CreditCard(CreditCardID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE ProductCategory
(
    ProductCategoryID INTEGER
        primary key autoincrement,
    Name              TEXT                        not null
        unique,
    rowguid           TEXT                         not null
        unique,
    ModifiedDate      DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductDescription
(
    ProductDescriptionID INTEGER
        primary key autoincrement,
    Description          TEXT                        not null,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModel
(
    ProductModelID     INTEGER
        primary key autoincrement,
    Name               TEXT                        not null
        unique,
    CatalogDescription TEXT,
    Instructions       TEXT,
    rowguid            TEXT                         not null
        unique,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModelProductDescriptionCulture
(
    ProductModelID       INTEGER                             not null,
    ProductDescriptionID INTEGER                             not null,
    CultureID            TEXT                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductModelID, ProductDescriptionID, CultureID),
    foreign key (ProductModelID) references ProductModel(ProductModelID),
    foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID),
    foreign key (CultureID) references Culture(CultureID)
);
CREATE TABLE ProductPhoto
(
    ProductPhotoID         INTEGER
        primary key autoincrement,
    ThumbNailPhoto         BLOB,
    ThumbnailPhotoFileName TEXT,
    LargePhoto             BLOB,
    LargePhotoFileName     TEXT,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductSubcategory
(
    ProductSubcategoryID INTEGER
        primary key autoincrement,
    ProductCategoryID    INTEGER                             not null,
    Name                 TEXT                        not null
        unique,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate        DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID)
);
CREATE TABLE SalesReason
(
    SalesReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null,
    ReasonType    TEXT                        not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE SalesTerritory
(
    TerritoryID       INTEGER
        primary key autoincrement,
    Name              TEXT                             not null
        unique,
    CountryRegionCode TEXT                               not null,
    "Group"           TEXT                              not null,
    SalesYTD          REAL default 0.0000            not null,
    SalesLastYear     REAL default 0.0000            not null,
    CostYTD           REAL default 0.0000            not null,
    CostLastYear      REAL default 0.0000            not null,
    rowguid           TEXT                              not null
        unique,
    ModifiedDate      DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode)
);
CREATE TABLE SalesPerson
(
    BusinessEntityID INTEGER                                  not null
        primary key,
    TerritoryID      INTEGER,
    SalesQuota       REAL,
    Bonus            REAL default 0.0000            not null,
    CommissionPct    REAL default 0.0000            not null,
    SalesYTD         REAL default 0.0000            not null,
    SalesLastYear    REAL default 0.0000            not null,
    rowguid          TEXT                              not null
        unique,
    ModifiedDate     DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references Employee(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE SalesPersonQuotaHistory
(
    BusinessEntityID INTEGER                             not null,
    QuotaDate        DATETIME                            not null,
    SalesQuota       REAL                      not null,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, QuotaDate),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesTerritoryHistory
(
    BusinessEntityID INTEGER                             not null,
    TerritoryID      INTEGER                             not null,
    StartDate        DATETIME                            not null,
    EndDate          DATETIME,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, StartDate, TerritoryID),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE ScrapReason
(
    ScrapReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null
        unique,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE Shift
(
    ShiftID      INTEGER
        primary key autoincrement,
    Name         TEXT                        not null
        unique,
    StartTime    TEXT                                not null,
    EndTime      TEXT                                not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    unique (StartTime, EndTime)
);
CREATE TABLE ShipMethod
(
    ShipMethodID INTEGER
        primary key autoincrement,
    Name         TEXT                             not null
        unique,
    ShipBase     REAL default 0.0000            not null,
    ShipRate    REAL default 0.0000            not null,
    rowguid      TEXT                              not null
        unique,
    ModifiedDate DATETIME      default CURRENT_TIMESTAMP not null
);
CREATE TABLE SpecialOffer
(
    SpecialOfferID INTEGER
        primary key autoincrement,
    Description    TEXT                             not null,
    DiscountPct    REAL   default 0.0000            not null,
    Type           TEXT                             not null,
    Category       TEXT                             not null,
    StartDate      DATETIME                            not null,
    EndDate        DATETIME                            not null,
    MinQty         INTEGER   default 0                 not null,
    MaxQty         INTEGER,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE BusinessEntityAddress
(
    BusinessEntityID INTEGER                                 not null,
    AddressID        INTEGER                                 not null,
    AddressTypeID    INTEGER                                 not null,
    rowguid          TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, AddressID, AddressTypeID),
    foreign key (AddressID) references Address(AddressID),
    foreign key (AddressTypeID) references AddressType(AddressTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE SalesTaxRate
(
    SalesTaxRateID  INTEGER
        primary key autoincrement,
    StateProvinceID INTEGER                                  not null,
    TaxType         INTEGER                                  not null,
    TaxRate         REAL default 0.0000            not null,
    Name            TEXT                             not null,
    rowguid         TEXT                              not null
        unique,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    unique (StateProvinceID, TaxType),
    foreign key (StateProvinceID) references StateProvince(StateProvinceID)
);
CREATE TABLE Store
(
    BusinessEntityID INTEGER                             not null
        primary key,
    Name             TEXT                        not null,
    SalesPersonID    INTEGER,
    Demographics     TEXT,
    rowguid          TEXT                             not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (SalesPersonID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesOrderHeaderSalesReason
(
    SalesOrderID  INTEGER                             not null,
    SalesReasonID INTEGER                             not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SalesOrderID, SalesReasonID),
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SalesReasonID) references SalesReason(SalesReasonID)
);
CREATE TABLE TransactionHistoryArchive
(
    TransactionID        INTEGER                             not null
        primary key,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE UnitMeasure
(
    UnitMeasureCode TEXT                             not null
        primary key,
    Name            TEXT                        not null
        unique,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductCostHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    StandardCost REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ProductDocument
(
    ProductID    INTEGER                             not null,
    DocumentNode TEXT                        not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, DocumentNode),
    foreign key (ProductID) references Product(ProductID),
    foreign key (DocumentNode) references Document(DocumentNode)
);
CREATE TABLE ProductInventory
(
    ProductID    INTEGER                             not null,
    LocationID   INTEGER                            not null,
    Shelf        TEXT                         not null,
    Bin          INTEGER                             not null,
    Quantity     INTEGER  default 0                 not null,
    rowguid      TEXT                         not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, LocationID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE ProductProductPhoto
(
    ProductID      INTEGER                             not null,
    ProductPhotoID INTEGER                             not null,
    "Primary"      INTEGER   default 0                 not null,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, ProductPhotoID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID)
);
CREATE TABLE ProductReview
(
    ProductReviewID INTEGER
        primary key autoincrement,
    ProductID       INTEGER                             not null,
    ReviewerName   TEXT                        not null,
    ReviewDate      DATETIME default CURRENT_TIMESTAMP not null,
    EmailAddress    TEXT                         not null,
    Rating          INTEGER                             not null,
    Comments        TEXT,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ShoppingCartItem
(
    ShoppingCartItemID INTEGER
        primary key autoincrement,
    ShoppingCartID     TEXT                         not null,
    Quantity           INTEGER   default 1                 not null,
    ProductID          INTEGER                             not null,
    DateCreated        DATETIME default CURRENT_TIMESTAMP not null,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SpecialOfferProduct
(
    SpecialOfferID INTEGER                             not null,
    ProductID      INTEGER                             not null,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SpecialOfferID, ProductID),
    foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SalesOrderDetail
(
    SalesOrderID          INTEGER                             not null,
    SalesOrderDetailID    INTEGER
        primary key autoincrement,
    CarrierTrackingNumber TEXT,
    OrderQty              INTEGER                             not null,
    ProductID             INTEGER                             not null,
    SpecialOfferID        INTEGER                             not null,
    UnitPrice             REAL                             not null,
    UnitPriceDiscount     REAL   default 0.0000            not null,
    LineTotal             REAL                             not null,
    rowguid               TEXT                             not null
        unique,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID)
);
CREATE TABLE TransactionHistory
(
    TransactionID        INTEGER
        primary key autoincrement,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE Vendor
(
    BusinessEntityID        INTEGER                             not null
        primary key,
    AccountNumber           TEXT                         not null
        unique,
    Name                    TEXT                        not null,
    CreditRating            INTEGER                             not null,
    PreferredVendorStatus   INTEGER   default 1                 not null,
    ActiveFlag              INTEGER   default 1                 not null,
    PurchasingWebServiceURL TEXT,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE ProductVendor
(
    ProductID        INTEGER                             not null,
    BusinessEntityID INTEGER                             not null,
    AverageLeadTime  INTEGER                             not null,
    StandardPrice    REAL                      not null,
    LastReceiptCost  REAL,
    LastReceiptDate  DATETIME,
    MinOrderQty      INTEGER                             not null,
    MaxOrderQty      INTEGER                             not null,
    OnOrderQty       INTEGER,
    UnitMeasureCode  TEXT                             not null,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, BusinessEntityID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (BusinessEntityID) references Vendor(BusinessEntityID),
    foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode)
);
CREATE TABLE PurchaseOrderHeader
(
    PurchaseOrderID INTEGER
        primary key autoincrement,
    RevisionNumber  INTEGER        default 0                 not null,
    Status          INTEGER        default 1                 not null,
    EmployeeID      INTEGER                                  not null,
    VendorID        INTEGER                                  not null,
    ShipMethodID    INTEGER                                  not null,
    OrderDate       DATETIME      default CURRENT_TIMESTAMP not null,
    ShipDate        DATETIME,
    SubTotal        REAL default 0.0000            not null,
    TaxAmt          REAL default 0.0000            not null,
    Freight         REAL default 0.0000            not null,
    TotalDue        REAL                          not null,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (EmployeeID) references Employee(BusinessEntityID),
    foreign key (VendorID) references Vendor(BusinessEntityID),
    foreign key (ShipMethodID) references ShipMethod(ShipMethodID)
);
CREATE TABLE PurchaseOrderDetail
(
    PurchaseOrderID       INTEGER                            not null,
    PurchaseOrderDetailID INTEGER
        primary key autoincrement,
    DueDate               DATETIME                           not null,
    OrderQty              INTEGER                           not null,
    ProductID             INTEGER                            not null,
    UnitPrice             REAL                            not null,
    LineTotal             REAL                            not null,
    ReceivedQty           REAL                            not null,
    RejectedQty           REAL                            not null,
    StockedQty            REAL                            not null,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE WorkOrder
(
    WorkOrderID   INTEGER
        primary key autoincrement,
    ProductID     INTEGER                             not null,
    OrderQty      INTEGER                             not null,
    StockedQty    INTEGER                             not null,
    ScrappedQty   INTEGER                           not null,
    StartDate     DATETIME                            not null,
    EndDate       DATETIME,
    DueDate       DATETIME                            not null,
    ScrapReasonID INTEGER,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID),
    foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID)
);
CREATE TABLE WorkOrderRouting
(
    WorkOrderID        INTEGER                             not null,
    ProductID          INTEGER                             not null,
    OperationSequence  INTEGER                             not null,
    LocationID         INTEGER                             not null,
    ScheduledStartDate DATETIME                            not null,
    ScheduledEndDate   DATETIME                            not null,
    ActualStartDate    DATETIME,
    ActualEndDate      DATETIME,
    ActualResourceHrs  REAL,
    PlannedCost        REAL                      not null,
    ActualCost         REAL,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    primary key (WorkOrderID, ProductID, OperationSequence),
    foreign key (WorkOrderID) references WorkOrder(WorkOrderID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE Customer
(
    CustomerID    INTEGER
        primary key,
    PersonID      INTEGER,
    StoreID       INTEGER,
    TerritoryID   INTEGER,
    AccountNumber TEXT                         not null
            unique,
    rowguid       TEXT                         not null
            unique,
    ModifiedDate  DATETIME default current_timestamp not null,
    foreign key (PersonID) references Person(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID),
    foreign key (StoreID) references Store(BusinessEntityID)
);
CREATE TABLE ProductListPriceHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    ListPrice    REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE IF NOT EXISTS "Address"
(
    AddressID       INTEGER
        primary key autoincrement,
    AddressLine1    TEXT                               not null,
    AddressLine2    TEXT,
    City            TEXT                               not null,
    StateProvinceID INTEGER                            not null
        references StateProvince,
    PostalCode      TEXT                               not null,
    SpatialLocation TEXT,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode)
);
CREATE TABLE IF NOT EXISTS "AddressType"
(
    AddressTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    rowguid       TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "BillOfMaterials"
(
    BillOfMaterialsID INTEGER
        primary key autoincrement,
    ProductAssemblyID INTEGER
        references Product,
    ComponentID       INTEGER                            not null
        references Product,
    StartDate         DATETIME default current_timestamp not null,
    EndDate           DATETIME,
    UnitMeasureCode   TEXT                               not null
        references UnitMeasure,
    BOMLevel          INTEGER                            not null,
    PerAssemblyQty    REAL     default 1.00              not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    unique (ProductAssemblyID, ComponentID, StartDate)
);
CREATE TABLE IF NOT EXISTS "BusinessEntity"
(
    BusinessEntityID INTEGER
        primary key autoincrement,
    rowguid          TEXT                               not null
        unique,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "ContactType"
(
    ContactTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "CurrencyRate"
(
    CurrencyRateID   INTEGER
        primary key autoincrement,
    CurrencyRateDate DATETIME                           not null,
    FromCurrencyCode TEXT                               not null
        references Currency,
    ToCurrencyCode   TEXT                               not null
        references Currency,
    AverageRate      REAL                               not null,
    EndOfDayRate     REAL                               not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode)
);
CREATE TABLE IF NOT EXISTS "Department"
(
    DepartmentID INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    GroupName    TEXT                               not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    DepartmentID     INTEGER                            not null
        references Department,
    ShiftID          INTEGER                            not null
        references Shift,
    StartDate        DATE                               not null,
    EndDate          DATE,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID)
);
CREATE TABLE IF NOT EXISTS "EmployeePayHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    RateChangeDate   DATETIME                           not null,
    Rate             REAL                               not null,
    PayFrequency     INTEGER                            not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, RateChangeDate)
);
CREATE TABLE IF NOT EXISTS "JobCandidate"
(
    JobCandidateID   INTEGER
        primary key autoincrement,
    BusinessEntityID INTEGER
        references Employee,
    Resume           TEXT,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Location"
(
    LocationID   INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    CostRate     REAL     default 0.0000            not null,
    Availability REAL     default 0.00              not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "PhoneNumberType"
(
    PhoneNumberTypeID INTEGER
        primary key autoincrement,
    Name              TEXT                               not null,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Product"
(
    ProductID             INTEGER
        primary key autoincrement,
    Name                  TEXT                               not null
        unique,
    ProductNumber         TEXT                               not null
        unique,
    MakeFlag              INTEGER  default 1                 not null,
    FinishedGoodsFlag     INTEGER  default 1                 not null,
    Color                 TEXT,
    SafetyStockLevel      INTEGER                            not null,
    ReorderPoint          INTEGER                            not null,
    StandardCost          REAL                               not null,
    ListPrice             REAL                               not null,
    Size                  TEXT,
    SizeUnitMeasureCode   TEXT
        references UnitMeasure,
    WeightUnitMeasureCode TEXT
        references UnitMeasure,
    Weight                REAL,
    DaysToManufacture     INTEGER                            not null,
    ProductLine           TEXT,
    Class                 TEXT,
    Style                 TEXT,
    ProductSubcategoryID  INTEGER
        references ProductSubcategory,
    ProductModelID        INTEGER
        references ProductModel,
    SellStartDate         DATETIME                           not null,
    SellEndDate           DATETIME,
    DiscontinuedDate      DATETIME,
    rowguid               TEXT                               not null
        unique,
    ModifiedDate          DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Document"
(
    DocumentNode    TEXT                               not null
        primary key,
    DocumentLevel   INTEGER,
    Title           TEXT                               not null,
    Owner           INTEGER                            not null
        references Employee,
    FolderFlag      INTEGER  default 0                 not null,
    FileName        TEXT                               not null,
    FileExtension   TEXT                               not null,
    Revision        TEXT                               not null,
    ChangeNumber    INTEGER  default 0                 not null,
    Status          INTEGER                            not null,
    DocumentSummary TEXT,
    Document        BLOB,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (DocumentLevel, DocumentNode)
);
CREATE TABLE IF NOT EXISTS "StateProvince"
(
    StateProvinceID         INTEGER
        primary key autoincrement,
    StateProvinceCode       TEXT                               not null,
    CountryRegionCode       TEXT                               not null
        references CountryRegion,
    IsOnlyStateProvinceFlag INTEGER  default 1                 not null,
    Name                    TEXT                               not null
        unique,
    TerritoryID             INTEGER                            not null
        references SalesTerritory,
    rowguid                 TEXT                               not null
        unique,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    unique (StateProvinceCode, CountryRegionCode)
);
CREATE TABLE IF NOT EXISTS "CreditCard"
(
    CreditCardID INTEGER
        primary key autoincrement,
    CardType     TEXT                               not null,
    CardNumber   TEXT                               not null
        unique,
    ExpMonth     INTEGER                            not null,
    ExpYear      INTEGER                            not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "SalesOrderHeader"
(
    SalesOrderID           INTEGER
        primary key autoincrement,
    RevisionNumber         INTEGER  default 0                 not null,
    OrderDate              DATETIME default CURRENT_TIMESTAMP not null,
    DueDate                DATETIME                           not null,
    ShipDate               DATETIME,
    Status                 INTEGER  default 1                 not null,
    OnlineOrderFlag        INTEGER  default 1                 not null,
    SalesOrderNumber       TEXT                               not null
        unique,
    PurchaseOrderNumber    TEXT,
    AccountNumber          TEXT,
    CustomerID             INTEGER                            not null
        references Customer,
    SalesPersonID          INTEGER
        references SalesPerson,
    TerritoryID            INTEGER
        references SalesTerritory,
    BillToAddressID        INTEGER                            not null
        references Address,
    ShipToAddressID        INTEGER                            not null
        references Address,
    ShipMethodID           INTEGER                            not null
        references Address,
    CreditCardID           INTEGER
        references CreditCard,
    CreditCardApprovalCode TEXT,
    CurrencyRateID         INTEGER
        references CurrencyRate,
    SubTotal               REAL     default 0.0000            not null,
    TaxAmt                 REAL     default 0.0000            not null,
    Freight                REAL     default 0.0000            not null,
    TotalDue               REAL                               not null,
    Comment                TEXT,
    rowguid                TEXT                               not null
        unique,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
 | 
| 
	movies_4 | 
	How many movies have "vi" as their language code? | 
	"vi" as their language code refers to language_code = 'vi' | 
	SELECT COUNT(T1.movie_id) FROM movie_languages AS T1 INNER JOIN language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_code = 'vi' | 
	CREATE TABLE country
(
    country_id       INTEGER not null
            primary key,
    country_iso_code TEXT  default NULL,
    country_name     TEXT default NULL
);
CREATE TABLE department
(
    department_id   INTEGER not null
            primary key,
    department_name TEXT default NULL
);
CREATE TABLE gender
(
    gender_id INTEGER not null
            primary key,
    gender    TEXT default NULL
);
CREATE TABLE genre
(
    genre_id   INTEGER not null
            primary key,
    genre_name TEXT default NULL
);
CREATE TABLE keyword
(
    keyword_id   INTEGER not null
            primary key,
    keyword_name TEXT default NULL
);
CREATE TABLE language
(
    language_id   INTEGER not null
            primary key,
    language_code TEXT  default NULL,
    language_name TEXT default NULL
);
CREATE TABLE language_role
(
    role_id       INTEGER not null
            primary key,
    language_role TEXT default NULL
);
CREATE TABLE movie
(
    movie_id    INTEGER not null
            primary key,
    title        TEXT  default NULL,
    budget       INTEGER            default NULL,
    homepage     TEXT  default NULL,
    overview     TEXT  default NULL,
    popularity   REAL default NULL,
    release_date DATE           default NULL,
    revenue      INTEGER     default NULL,
    runtime      INTEGER           default NULL,
    movie_status TEXT    default NULL,
    tagline      TEXT  default NULL,
    vote_average REAL  default NULL,
    vote_count   INTEGER            default NULL
);
CREATE TABLE movie_genres
(
    movie_id INTEGER default NULL,
    genre_id INTEGER default NULL,
    foreign key (genre_id) references genre(genre_id),
    foreign key (movie_id) references movie(movie_id)
);
CREATE TABLE movie_languages
(
    movie_id         INTEGER default NULL,
    language_id      INTEGER default NULL,
    language_role_id INTEGER default NULL,
    foreign key (language_id) references language(language_id),
    foreign key (movie_id) references movie(movie_id),
    foreign key (language_role_id) references language_role(role_id)
);
CREATE TABLE person
(
    person_id   INTEGER not null
            primary key,
    person_name TEXT default NULL
);
CREATE TABLE movie_crew
(
    movie_id      INTEGER          default NULL,
    person_id     INTEGER          default NULL,
    department_id INTEGER          default NULL,
    job           TEXT default NULL,
    foreign key (department_id) references department(department_id),
    foreign key (movie_id) references movie(movie_id),
    foreign key (person_id) references person(person_id)
);
CREATE TABLE production_company
(
    company_id   INTEGER not null
            primary key,
    company_name TEXT default NULL
);
CREATE TABLE production_country
(
    movie_id   INTEGER default NULL,
    country_id INTEGER default NULL,
    foreign key (country_id) references country(country_id),
    foreign key (movie_id) references movie(movie_id)
);
CREATE TABLE movie_cast
(
    movie_id       INTEGER          default NULL,
    person_id      INTEGER          default NULL,
    character_name TEXT default NULL,
    gender_id      INTEGER          default NULL,
    cast_order     INTEGER       default NULL,
    foreign key (gender_id) references gender(gender_id),
    foreign key (movie_id) references movie(movie_id),
    foreign key (person_id) references person(person_id)
);
CREATE TABLE IF NOT EXISTS "movie_keywords"
(
    movie_id   INTEGER default NULL
        references movie,
    keyword_id INTEGER default NULL
        references keyword
);
CREATE TABLE IF NOT EXISTS "movie_company"
(
    movie_id   INTEGER default NULL
        references movie,
    company_id INTEGER default NULL
        references production_company
);
 | 
| 
	public_review_platform | 
	Calculate the difference between running business in Glendale City and Mesa City. | 
	running business refers to business where active = 'true'; | 
	SELECT SUM(CASE WHEN city = 'Glendale' THEN 1 ELSE 0 END) - SUM(CASE WHEN city = 'Mesa' THEN 1 ELSE 0 END) AS diff FROM Business WHERE active = 'true' | 
	CREATE TABLE Attributes
(
    attribute_id   INTEGER
        constraint Attributes_pk
            primary key,
    attribute_name TEXT
);
CREATE TABLE Categories
(
    category_id   INTEGER
        constraint Categories_pk
            primary key,
    category_name TEXT
);
CREATE TABLE Compliments
(
    compliment_id   INTEGER
        constraint Compliments_pk
            primary key,
    compliment_type TEXT
);
CREATE TABLE Days
(
    day_id      INTEGER
        constraint Days_pk
            primary key,
    day_of_week TEXT
);
CREATE TABLE Years
(
    year_id     INTEGER
        constraint Years_pk
            primary key,
    actual_year INTEGER
);
CREATE TABLE IF NOT EXISTS "Business_Attributes"
(
    attribute_id    INTEGER
        constraint Business_Attributes_Attributes_attribute_id_fk
            references Attributes,
    business_id     INTEGER
        constraint Business_Attributes_Business_business_id_fk
            references Business,
    attribute_value TEXT,
    constraint Business_Attributes_pk
        primary key (attribute_id, business_id)
);
CREATE TABLE IF NOT EXISTS "Business_Categories"
(
    business_id INTEGER
        constraint Business_Categories_Business_business_id_fk
            references Business,
    category_id INTEGER
        constraint Business_Categories_Categories_category_id_fk
            references Categories,
    constraint Business_Categories_pk
        primary key (business_id, category_id)
);
CREATE TABLE IF NOT EXISTS "Business_Hours"
(
    business_id  INTEGER
        constraint Business_Hours_Business_business_id_fk
            references Business,
    day_id       INTEGER
        constraint Business_Hours_Days_day_id_fk
            references Days,
    opening_time TEXT,
    closing_time TEXT,
    constraint Business_Hours_pk
        primary key (business_id, day_id)
);
CREATE TABLE IF NOT EXISTS "Checkins"
(
    business_id   INTEGER
        constraint Checkins_Business_business_id_fk
            references Business,
    day_id        INTEGER
        constraint Checkins_Days_day_id_fk
            references Days,
    label_time_0  TEXT,
    label_time_1  TEXT,
    label_time_2  TEXT,
    label_time_3  TEXT,
    label_time_4  TEXT,
    label_time_5  TEXT,
    label_time_6  TEXT,
    label_time_7  TEXT,
    label_time_8  TEXT,
    label_time_9  TEXT,
    label_time_10 TEXT,
    label_time_11 TEXT,
    label_time_12 TEXT,
    label_time_13 TEXT,
    label_time_14 TEXT,
    label_time_15 TEXT,
    label_time_16 TEXT,
    label_time_17 TEXT,
    label_time_18 TEXT,
    label_time_19 TEXT,
    label_time_20 TEXT,
    label_time_21 TEXT,
    label_time_22 TEXT,
    label_time_23 TEXT,
    constraint Checkins_pk
        primary key (business_id, day_id)
);
CREATE TABLE IF NOT EXISTS "Elite"
(
    user_id INTEGER
        constraint Elite_Users_user_id_fk
            references Users,
    year_id INTEGER
        constraint Elite_Years_year_id_fk
            references Years,
    constraint Elite_pk
        primary key (user_id, year_id)
);
CREATE TABLE IF NOT EXISTS "Reviews"
(
    business_id         INTEGER
        constraint Reviews_Business_business_id_fk
            references Business,
    user_id             INTEGER
        constraint Reviews_Users_user_id_fk
            references Users,
    review_stars        INTEGER,
    review_votes_funny  TEXT,
    review_votes_useful TEXT,
    review_votes_cool   TEXT,
    review_length       TEXT,
    constraint Reviews_pk
        primary key (business_id, user_id)
);
CREATE TABLE IF NOT EXISTS "Tips"
(
    business_id INTEGER
        constraint Tips_Business_business_id_fk
            references Business,
    user_id     INTEGER
        constraint Tips_Users_user_id_fk
            references Users,
    likes       INTEGER,
    tip_length  TEXT,
    constraint Tips_pk
        primary key (business_id, user_id)
);
CREATE TABLE IF NOT EXISTS "Users_Compliments"
(
    compliment_id         INTEGER
        constraint Users_Compliments_Compliments_compliment_id_fk
            references Compliments,
    user_id               INTEGER
        constraint Users_Compliments_Users_user_id_fk
            references Users,
    number_of_compliments TEXT,
    constraint Users_Compliments_pk
        primary key (compliment_id, user_id)
);
CREATE TABLE IF NOT EXISTS "Business"
(
    business_id  INTEGER
        constraint Business_pk
            primary key,
    active       TEXT,
    city         TEXT,
    state        TEXT,
    stars        REAL,
    review_count TEXT
);
CREATE TABLE IF NOT EXISTS "Users"
(
    user_id                 INTEGER
        constraint Users_pk
            primary key,
    user_yelping_since_year INTEGER,
    user_average_stars      TEXT,
    user_votes_funny        TEXT,
    user_votes_useful       TEXT,
    user_votes_cool         TEXT,
    user_review_count       TEXT,
    user_fans               TEXT
);
 | 
| 
	talkingdata | 
	List all females aged 24 to 26 devices' locations. | 
	females refers to gender = 'F'; aged 24 to 26 refers to `group` = 'F24-26'; | 
	SELECT T2.longitude, T2.latitude FROM gender_age AS T1 INNER JOIN events_relevant AS T2 ON T1.device_id = T2.device_id WHERE T1.`group` = 'F24-26' AND T1.gender = 'F' | 
	CREATE TABLE `app_all`
(
    `app_id` INTEGER NOT NULL,
    PRIMARY KEY (`app_id`)
);
CREATE TABLE `app_events` (
  `event_id` INTEGER NOT NULL,
  `app_id` INTEGER NOT NULL,
  `is_installed` INTEGER NOT NULL,
  `is_active` INTEGER NOT NULL,
  PRIMARY KEY (`event_id`,`app_id`),
  FOREIGN KEY (`event_id`) REFERENCES `events` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `app_events_relevant` (
  `event_id` INTEGER NOT NULL,
  `app_id` INTEGER NOT NULL,
  `is_installed` INTEGER DEFAULT NULL,
  `is_active` INTEGER DEFAULT NULL,
  PRIMARY KEY (`event_id`,`app_id`),
  FOREIGN KEY (`event_id`) REFERENCES `events_relevant` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `app_labels` (
  `app_id` INTEGER NOT NULL,
  `label_id` INTEGER NOT NULL,
  FOREIGN KEY (`label_id`) REFERENCES `label_categories` (`label_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`app_id`) REFERENCES `app_all` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `events` (
  `event_id` INTEGER NOT NULL,
  `device_id` INTEGER DEFAULT NULL,
  `timestamp` DATETIME DEFAULT NULL,
  `longitude` REAL DEFAULT NULL,
  `latitude` REAL DEFAULT NULL,
  PRIMARY KEY (`event_id`)
);
CREATE TABLE `events_relevant` (
  `event_id` INTEGER NOT NULL,
  `device_id` INTEGER DEFAULT NULL,
  `timestamp` DATETIME NOT NULL,
  `longitude` REAL NOT NULL,
  `latitude` REAL NOT NULL,
  PRIMARY KEY (`event_id`),
  FOREIGN KEY (`device_id`) REFERENCES `gender_age` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `gender_age` (
  `device_id` INTEGER NOT NULL,
  `gender` TEXT DEFAULT NULL,
  `age` INTEGER DEFAULT NULL,
  `group` TEXT DEFAULT NULL,
  PRIMARY KEY (`device_id`),
  FOREIGN KEY (`device_id`) REFERENCES `phone_brand_device_model2` (`device_id`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE `gender_age_test` (
  `device_id` INTEGER NOT NULL,
  PRIMARY KEY (`device_id`)
);
CREATE TABLE `gender_age_train` (
  `device_id` INTEGER NOT NULL,
  `gender` TEXT DEFAULT NULL,
  `age` INTEGER DEFAULT NULL,
  `group` TEXT DEFAULT NULL,
  PRIMARY KEY (`device_id`)
);
CREATE TABLE `label_categories` (
  `label_id` INTEGER NOT NULL,
  `category` TEXT DEFAULT NULL,
  PRIMARY KEY (`label_id`)
);
CREATE TABLE `phone_brand_device_model2` (
  `device_id` INTEGER NOT NULL,
  `phone_brand` TEXT NOT NULL,
  `device_model` TEXT NOT NULL,
  PRIMARY KEY (`device_id`,`phone_brand`,`device_model`)
);
CREATE TABLE `sample_submission` (
  `device_id` INTEGER NOT NULL,
  `F23-` REAL DEFAULT NULL,
  `F24-26` REAL DEFAULT NULL,
  `F27-28` REAL DEFAULT NULL,
  `F29-32` REAL DEFAULT NULL,
  `F33-42` REAL DEFAULT NULL,
  `F43+` REAL DEFAULT NULL,
  `M22-` REAL DEFAULT NULL,
  `M23-26` REAL DEFAULT NULL,
  `M27-28` REAL DEFAULT NULL,
  `M29-31` REAL DEFAULT NULL,
  `M32-38` REAL DEFAULT NULL,
  `M39+` REAL DEFAULT NULL,
  PRIMARY KEY (`device_id`)
);
 | 
| 
	retail_complains | 
	In complaints about the credit card product, list the phone number of the oldest client. | 
	oldest refers to max(age) | 
	SELECT T1.phone FROM client AS T1 INNER JOIN events AS T2 ON T1.client_id = T2.Client_ID WHERE T2.Product = 'Credit card' ORDER BY T1.age DESC LIMIT 1 | 
	CREATE TABLE state
(
    StateCode TEXT
        constraint state_pk
            primary key,
    State     TEXT,
    Region    TEXT
);
CREATE TABLE callcenterlogs
(
    "Date received" DATE,
    "Complaint ID"  TEXT,
    "rand client"   TEXT,
    phonefinal      TEXT,
    "vru+line"      TEXT,
    call_id         INTEGER,
    priority        INTEGER,
    type            TEXT,
    outcome         TEXT,
    server          TEXT,
    ser_start       TEXT,
    ser_exit        TEXT,
    ser_time        TEXT,
    primary key ("Complaint ID"),
    foreign key ("rand client") references client(client_id)
);
CREATE TABLE client
(
    client_id   TEXT
            primary key,
    sex         TEXT,
    day         INTEGER,
    month       INTEGER,
    year        INTEGER,
    age         INTEGER,
    social      TEXT,
    first       TEXT,
    middle      TEXT,
    last        TEXT,
    phone       TEXT,
    email       TEXT,
    address_1   TEXT,
    address_2   TEXT,
    city        TEXT,
    state       TEXT,
    zipcode     INTEGER,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
);
CREATE TABLE district
(
    district_id  INTEGER
            primary key,
    city         TEXT,
    state_abbrev TEXT,
    division     TEXT,
    foreign key (state_abbrev) references state(StateCode)
);
CREATE TABLE events
(
    "Date received"                DATE,
    Product                        TEXT,
    "Sub-product"                  TEXT,
    Issue                          TEXT,
    "Sub-issue"                    TEXT,
    "Consumer complaint narrative" TEXT,
    Tags                           TEXT,
    "Consumer consent provided?"   TEXT,
    "Submitted via"                TEXT,
    "Date sent to company"         TEXT,
    "Company response to consumer" TEXT,
    "Timely response?"             TEXT,
    "Consumer disputed?"           TEXT,
    "Complaint ID"                 TEXT,
    Client_ID                      TEXT,
    primary key ("Complaint ID", Client_ID),
    foreign key ("Complaint ID") references callcenterlogs("Complaint ID"),
    foreign key (Client_ID) references client(client_id)
);
CREATE TABLE reviews
(
    "Date"        DATE
            primary key,
    Stars       INTEGER,
    Reviews     TEXT,
    Product     TEXT,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
);
 | 
| 
	car_retails | 
	Which sales representatives in New York city whose leader is Anthony Bow with the employee number is 1143? Indicate their employee numbers. | 
	reportsTO' is the leader of the 'employeeNumber'; | 
	SELECT T1.employeeNumber FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T1.reportsTo = 1143 AND T2.city = 'NYC' | 
	CREATE TABLE offices
(
    officeCode   TEXT not null
        primary key,
    city         TEXT not null,
    phone        TEXT not null,
    addressLine1 TEXT not null,
    addressLine2 TEXT,
    state        TEXT,
    country      TEXT not null,
    postalCode  TEXT not null,
    territory    TEXT not null
);
CREATE TABLE employees
(
    employeeNumber INTEGER      not null
        primary key,
    lastName       TEXT  not null,
    firstName      TEXT  not null,
    extension      TEXT  not null,
    email          TEXT not null,
    officeCode     TEXT  not null,
    reportsTo      INTEGER,
    jobTitle       TEXT  not null,
    foreign key (officeCode) references offices(officeCode),
    foreign key (reportsTo) references employees(employeeNumber)
);
CREATE TABLE customers
(
    customerNumber         INTEGER     not null
        primary key,
    customerName           TEXT not null,
    contactLastName        TEXT not null,
    contactFirstName       TEXT not null,
    phone                  TEXT not null,
    addressLine1           TEXT not null,
    addressLine2           TEXT,
    city                   TEXT not null,
    state                  TEXT,
    postalCode             TEXT,
    country                TEXT not null,
    salesRepEmployeeNumber INTEGER,
    creditLimit            REAL,
    foreign key (salesRepEmployeeNumber) references employees(employeeNumber)
);
CREATE TABLE orders
(
    orderNumber    INTEGER     not null
        primary key,
    orderDate      DATE        not null,
    requiredDate   DATE        not null,
    shippedDate    DATE,
    status         TEXT not null,
    comments       TEXT,
    customerNumber INTEGER     not null,
    foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE payments
(
    customerNumber INTEGER     not null,
    checkNumber    TEXT not null,
    paymentDate    DATE        not null,
    amount         REAL        not null,
    primary key (customerNumber, checkNumber),
    foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE productlines
(
    productLine     TEXT not null
        primary key,
    textDescription TEXT,
    htmlDescription TEXT,
    image           BLOB
);
CREATE TABLE products
(
    productCode        TEXT not null
        primary key,
    productName        TEXT not null,
    productLine        TEXT not null,
    productScale      TEXT not null,
    productVendor      TEXT not null,
    productDescription TEXT        not null,
    quantityInStock    INTEGER     not null,
    buyPrice           REAL        not null,
    MSRP               REAL        not null,
    foreign key (productLine) references productlines(productLine)
);
CREATE TABLE IF NOT EXISTS "orderdetails"
(
    orderNumber     INTEGER not null
        references orders,
    productCode     TEXT    not null
        references products,
    quantityOrdered INTEGER not null,
    priceEach       REAL    not null,
    orderLineNumber INTEGER not null,
    primary key (orderNumber, productCode)
);
 | 
| 
	simpson_episodes | 
	List out the star scores of episode which has title of "How the Test Was Won". | 
	star scores refers to stars | 
	SELECT T2.stars FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T1.title = 'How the Test Was Won'; | 
	CREATE TABLE IF NOT EXISTS "Episode"
(
    episode_id       TEXT
        constraint Episode_pk
            primary key,
    season           INTEGER,
    episode          INTEGER,
    number_in_series INTEGER,
    title            TEXT,
    summary          TEXT,
    air_date         TEXT,
    episode_image    TEXT,
    rating           REAL,
    votes            INTEGER
);
CREATE TABLE Person
(
    name          TEXT
        constraint Person_pk
            primary key,
    birthdate     TEXT,
    birth_name    TEXT,
    birth_place   TEXT,
    birth_region  TEXT,
    birth_country TEXT,
    height_meters REAL,
    nickname      TEXT
);
CREATE TABLE Award
(
    award_id       INTEGER
            primary key,
    organization   TEXT,
    year           INTEGER,
    award_category TEXT,
    award          TEXT,
    person         TEXT,
    role           TEXT,
    episode_id     TEXT,
    season         TEXT,
    song           TEXT,
    result         TEXT,
    foreign key (person) references Person(name),
    foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Character_Award
(
    award_id  INTEGER,
    character TEXT,
    foreign key (award_id) references Award(award_id)
);
CREATE TABLE Credit
(
    episode_id TEXT,
    category   TEXT,
    person     TEXT,
    role       TEXT,
    credited   TEXT,
    foreign key (episode_id) references Episode(episode_id),
    foreign key (person) references Person(name)
);
CREATE TABLE Keyword
(
    episode_id TEXT,
    keyword    TEXT,
    primary key (episode_id, keyword),
    foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Vote
(
    episode_id TEXT,
    stars      INTEGER,
    votes      INTEGER,
    percent    REAL,
    foreign key (episode_id) references Episode(episode_id)
);
 | 
| 
	public_review_platform | 
	List out the category name of business id 5. | 
	SELECT T1.category_name FROM Categories AS T1 INNER JOIN Business_Categories AS T2 ON T1.category_id = T2.category_id WHERE T2.business_id = 5 | 
	CREATE TABLE Attributes
(
    attribute_id   INTEGER
        constraint Attributes_pk
            primary key,
    attribute_name TEXT
);
CREATE TABLE Categories
(
    category_id   INTEGER
        constraint Categories_pk
            primary key,
    category_name TEXT
);
CREATE TABLE Compliments
(
    compliment_id   INTEGER
        constraint Compliments_pk
            primary key,
    compliment_type TEXT
);
CREATE TABLE Days
(
    day_id      INTEGER
        constraint Days_pk
            primary key,
    day_of_week TEXT
);
CREATE TABLE Years
(
    year_id     INTEGER
        constraint Years_pk
            primary key,
    actual_year INTEGER
);
CREATE TABLE IF NOT EXISTS "Business_Attributes"
(
    attribute_id    INTEGER
        constraint Business_Attributes_Attributes_attribute_id_fk
            references Attributes,
    business_id     INTEGER
        constraint Business_Attributes_Business_business_id_fk
            references Business,
    attribute_value TEXT,
    constraint Business_Attributes_pk
        primary key (attribute_id, business_id)
);
CREATE TABLE IF NOT EXISTS "Business_Categories"
(
    business_id INTEGER
        constraint Business_Categories_Business_business_id_fk
            references Business,
    category_id INTEGER
        constraint Business_Categories_Categories_category_id_fk
            references Categories,
    constraint Business_Categories_pk
        primary key (business_id, category_id)
);
CREATE TABLE IF NOT EXISTS "Business_Hours"
(
    business_id  INTEGER
        constraint Business_Hours_Business_business_id_fk
            references Business,
    day_id       INTEGER
        constraint Business_Hours_Days_day_id_fk
            references Days,
    opening_time TEXT,
    closing_time TEXT,
    constraint Business_Hours_pk
        primary key (business_id, day_id)
);
CREATE TABLE IF NOT EXISTS "Checkins"
(
    business_id   INTEGER
        constraint Checkins_Business_business_id_fk
            references Business,
    day_id        INTEGER
        constraint Checkins_Days_day_id_fk
            references Days,
    label_time_0  TEXT,
    label_time_1  TEXT,
    label_time_2  TEXT,
    label_time_3  TEXT,
    label_time_4  TEXT,
    label_time_5  TEXT,
    label_time_6  TEXT,
    label_time_7  TEXT,
    label_time_8  TEXT,
    label_time_9  TEXT,
    label_time_10 TEXT,
    label_time_11 TEXT,
    label_time_12 TEXT,
    label_time_13 TEXT,
    label_time_14 TEXT,
    label_time_15 TEXT,
    label_time_16 TEXT,
    label_time_17 TEXT,
    label_time_18 TEXT,
    label_time_19 TEXT,
    label_time_20 TEXT,
    label_time_21 TEXT,
    label_time_22 TEXT,
    label_time_23 TEXT,
    constraint Checkins_pk
        primary key (business_id, day_id)
);
CREATE TABLE IF NOT EXISTS "Elite"
(
    user_id INTEGER
        constraint Elite_Users_user_id_fk
            references Users,
    year_id INTEGER
        constraint Elite_Years_year_id_fk
            references Years,
    constraint Elite_pk
        primary key (user_id, year_id)
);
CREATE TABLE IF NOT EXISTS "Reviews"
(
    business_id         INTEGER
        constraint Reviews_Business_business_id_fk
            references Business,
    user_id             INTEGER
        constraint Reviews_Users_user_id_fk
            references Users,
    review_stars        INTEGER,
    review_votes_funny  TEXT,
    review_votes_useful TEXT,
    review_votes_cool   TEXT,
    review_length       TEXT,
    constraint Reviews_pk
        primary key (business_id, user_id)
);
CREATE TABLE IF NOT EXISTS "Tips"
(
    business_id INTEGER
        constraint Tips_Business_business_id_fk
            references Business,
    user_id     INTEGER
        constraint Tips_Users_user_id_fk
            references Users,
    likes       INTEGER,
    tip_length  TEXT,
    constraint Tips_pk
        primary key (business_id, user_id)
);
CREATE TABLE IF NOT EXISTS "Users_Compliments"
(
    compliment_id         INTEGER
        constraint Users_Compliments_Compliments_compliment_id_fk
            references Compliments,
    user_id               INTEGER
        constraint Users_Compliments_Users_user_id_fk
            references Users,
    number_of_compliments TEXT,
    constraint Users_Compliments_pk
        primary key (compliment_id, user_id)
);
CREATE TABLE IF NOT EXISTS "Business"
(
    business_id  INTEGER
        constraint Business_pk
            primary key,
    active       TEXT,
    city         TEXT,
    state        TEXT,
    stars        REAL,
    review_count TEXT
);
CREATE TABLE IF NOT EXISTS "Users"
(
    user_id                 INTEGER
        constraint Users_pk
            primary key,
    user_yelping_since_year INTEGER,
    user_average_stars      TEXT,
    user_votes_funny        TEXT,
    user_votes_useful       TEXT,
    user_votes_cool         TEXT,
    user_review_count       TEXT,
    user_fans               TEXT
);
 | |
| 
	bike_share_1 | 
	How many bikes could Evelyn Park and Ride hold and how many users who started on that station are subscribers? | 
	number of bikes a station can hold refers to SUM(dock_count); Evelyn Park and Ride refers to name = 'Evelyn Park and Ride'; started on the station refers to start_station_name; subscribers refers to subscription_type = 'subscriber'; | 
	SELECT SUM(T2.dock_count), COUNT(T1.subscription_type) FROM trip AS T1 INNER JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.name = 'Evelyn Park and Ride' AND T1.start_station_name = T2.name AND T1.subscription_type = 'Subscriber' | 
	CREATE TABLE IF NOT EXISTS "station"
(
    id                INTEGER not null
        primary key,
    name              TEXT,
    lat               REAL,
    long              REAL,
    dock_count        INTEGER,
    city              TEXT,
    installation_date TEXT
);
CREATE TABLE IF NOT EXISTS "status"
(
    station_id      INTEGER,
    bikes_available INTEGER,
    docks_available INTEGER,
    time            TEXT
);
CREATE TABLE IF NOT EXISTS "trip"
(
    id                 INTEGER not null
        primary key,
    duration           INTEGER,
    start_date         TEXT,
    start_station_name TEXT,
    start_station_id   INTEGER,
    end_date           TEXT,
    end_station_name   TEXT,
    end_station_id     INTEGER,
    bike_id            INTEGER,
    subscription_type  TEXT,
    zip_code           INTEGER
);
CREATE TABLE IF NOT EXISTS "weather"
(
    date                           TEXT,
    max_temperature_f              INTEGER,
    mean_temperature_f             INTEGER,
    min_temperature_f              INTEGER,
    max_dew_point_f                INTEGER,
    mean_dew_point_f               INTEGER,
    min_dew_point_f                INTEGER,
    max_humidity                   INTEGER,
    mean_humidity                  INTEGER,
    min_humidity                   INTEGER,
    max_sea_level_pressure_inches  REAL,
    mean_sea_level_pressure_inches REAL,
    min_sea_level_pressure_inches  REAL,
    max_visibility_miles           INTEGER,
    mean_visibility_miles          INTEGER,
    min_visibility_miles           INTEGER,
    max_wind_Speed_mph             INTEGER,
    mean_wind_speed_mph            INTEGER,
    max_gust_speed_mph             INTEGER,
    precipitation_inches           TEXT,
    cloud_cover                    INTEGER,
    events                         TEXT,
    wind_dir_degrees               INTEGER,
    zip_code                       TEXT
);
 | 
| 
	retail_world | 
	What were the products supplied by the company in Spain? | 
	company in Spain refers to Country = 'Spain'; product supplied refers to ProductName | 
	SELECT T1.ProductName FROM Products AS T1 INNER JOIN Suppliers AS T2 ON T1.SupplierID = T2.SupplierID WHERE T2.Country = 'Spain' | 
	CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE Categories
(
    CategoryID INTEGER PRIMARY KEY AUTOINCREMENT,
    CategoryName TEXT,
    Description TEXT
);
CREATE TABLE Customers
(
    CustomerID INTEGER PRIMARY KEY AUTOINCREMENT,
    CustomerName TEXT,
    ContactName TEXT,
    Address TEXT,
    City TEXT,
    PostalCode TEXT,
    Country TEXT
);
CREATE TABLE Employees
(
    EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT,
    LastName TEXT,
    FirstName TEXT,
    BirthDate DATE,
    Photo TEXT,
    Notes TEXT
);
CREATE TABLE Shippers(
    ShipperID INTEGER PRIMARY KEY AUTOINCREMENT,
    ShipperName TEXT,
    Phone TEXT
);
CREATE TABLE Suppliers(
    SupplierID INTEGER PRIMARY KEY AUTOINCREMENT,
    SupplierName TEXT,
    ContactName TEXT,
    Address TEXT,
    City TEXT,
    PostalCode TEXT,
    Country TEXT,
    Phone TEXT
);
CREATE TABLE Products(
    ProductID INTEGER PRIMARY KEY AUTOINCREMENT,
    ProductName TEXT,
    SupplierID INTEGER,
    CategoryID INTEGER,
    Unit TEXT,
    Price REAL DEFAULT 0,
	FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID),
	FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID)
);
CREATE TABLE Orders(
    OrderID INTEGER PRIMARY KEY AUTOINCREMENT,
    CustomerID INTEGER,
    EmployeeID INTEGER,
    OrderDate DATETIME,
    ShipperID INTEGER,
    FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID),
    FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),
    FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID)
);
CREATE TABLE OrderDetails(
    OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT,
    OrderID INTEGER,
    ProductID INTEGER,
    Quantity INTEGER,
	FOREIGN KEY (OrderID) REFERENCES Orders (OrderID),
	FOREIGN KEY (ProductID) REFERENCES Products (ProductID)
);
 | 
| 
	image_and_language | 
	What is the relationship between "feathers" and "onion" in image no.2345528? | 
	relationship refers to PRED_CLASS; "feathers" and "onion" in image no.2345528 refers to IMG_ID = 2345528 and OBJ_CLASS = 'feathers' and OBJ_CLASS = 'onion' | 
	SELECT T1.PRED_CLASS FROM PRED_CLASSES AS T1 INNER JOIN IMG_REL AS T2 ON T1.PRED_CLASS_ID = T2.PRED_CLASS_ID INNER JOIN IMG_OBJ AS T3 ON T2.OBJ1_SAMPLE_ID = T3.OBJ_SAMPLE_ID INNER JOIN OBJ_CLASSES AS T4 ON T3.OBJ_CLASS_ID = T4.OBJ_CLASS_ID WHERE (T4.OBJ_CLASS = 'feathers' OR T4.OBJ_CLASS = 'onion') AND T2.IMG_ID = 2345528 GROUP BY T1.PRED_CLASS | 
	CREATE TABLE ATT_CLASSES
(
    ATT_CLASS_ID INTEGER default 0 not null
        primary key,
    ATT_CLASS    TEXT      not null
);
CREATE TABLE OBJ_CLASSES
(
    OBJ_CLASS_ID INTEGER default 0 not null
        primary key,
    OBJ_CLASS    TEXT      not null
);
CREATE TABLE IMG_OBJ
(
    IMG_ID        INTEGER default 0 not null,
    OBJ_SAMPLE_ID INTEGER    default 0 not null,
    OBJ_CLASS_ID  INTEGER              null,
    X             INTEGER              null,
    Y             INTEGER             null,
    W             INTEGER              null,
    H             INTEGER              null,
    primary key (IMG_ID, OBJ_SAMPLE_ID),
    foreign key (OBJ_CLASS_ID) references OBJ_CLASSES (OBJ_CLASS_ID)
);
CREATE TABLE IMG_OBJ_ATT
(
    IMG_ID        INTEGER default 0 not null,
    ATT_CLASS_ID  INTEGER    default 0 not null,
    OBJ_SAMPLE_ID INTEGER    default 0 not null,
    primary key (IMG_ID, ATT_CLASS_ID, OBJ_SAMPLE_ID),
    foreign key (ATT_CLASS_ID) references ATT_CLASSES (ATT_CLASS_ID),
    foreign key (IMG_ID, OBJ_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID)
);
CREATE TABLE PRED_CLASSES
(
    PRED_CLASS_ID INTEGER default 0 not null
        primary key,
    PRED_CLASS    TEXT     not null
);
CREATE TABLE IMG_REL
(
    IMG_ID         INTEGER default 0 not null,
    PRED_CLASS_ID  INTEGER    default 0 not null,
    OBJ1_SAMPLE_ID INTEGER    default 0 not null,
    OBJ2_SAMPLE_ID INTEGER   default 0 not null,
    primary key (IMG_ID, PRED_CLASS_ID, OBJ1_SAMPLE_ID, OBJ2_SAMPLE_ID),
    foreign key (PRED_CLASS_ID) references PRED_CLASSES (PRED_CLASS_ID),
    foreign key (IMG_ID, OBJ1_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID),
    foreign key (IMG_ID, OBJ2_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID)
);
 | 
| 
	hockey | 
	What's the decrease rate of the game plays did David Aebischer after he got traded in 2005? | 
	DIVIDE(SUBTRACT(SUM(GP(year = 2005), SUM(GP(year = 2006)), SUM(GP(year = 2005)) as percentage; | 
	SELECT CAST((SUM(CASE WHEN T1.year = 2005 THEN T1.GP ELSE 0 END) - SUM(CASE WHEN T1.year = 2006 THEN T1.GP ELSE 0 END)) AS REAL) * 100 / SUM(CASE WHEN T1.year = 2005 THEN T1.GP ELSE 0 END) FROM Goalies AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID WHERE T2.firstName = 'David' AND T2.lastName = 'Aebischer' | 
	CREATE TABLE AwardsMisc
(
    name  TEXT not null
        primary key,
    ID    TEXT,
    award TEXT,
    year  INTEGER,
    lgID  TEXT,
    note  TEXT
);
CREATE TABLE HOF
(
    year     INTEGER,
    hofID    TEXT not null
        primary key,
    name     TEXT,
    category TEXT
);
CREATE TABLE Teams
(
    year       INTEGER          not null,
    lgID       TEXT,
    tmID       TEXT not null,
    franchID   TEXT,
    confID     TEXT,
    divID      TEXT,
    rank       INTEGER,
    playoff    TEXT,
    G          INTEGER,
    W          INTEGER,
    L          INTEGER,
    T          INTEGER,
    OTL        TEXT,
    Pts        INTEGER,
    SoW        TEXT,
    SoL        TEXT,
    GF         INTEGER,
    GA         INTEGER,
    name       TEXT,
    PIM        TEXT,
    BenchMinor TEXT,
    PPG        TEXT,
    PPC       TEXT,
    SHA        TEXT,
    PKG       TEXT,
    PKC        TEXT,
    SHF        TEXT,
    primary key (year, tmID)
);
CREATE TABLE Coaches
(
    coachID TEXT    not null,
    year    INTEGER not null,
    tmID    TEXT    not null,
    lgID    TEXT,
    stint   INTEGER not null,
    notes   TEXT,
    g       INTEGER,
    w       INTEGER,
    l       INTEGER,
    t       INTEGER,
    postg   TEXT,
    postw   TEXT,
    postl   TEXT,
    postt   TEXT,
    primary key (coachID, year, tmID, stint),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade
);
CREATE TABLE AwardsCoaches
(
    coachID TEXT,
    award   TEXT,
    year    INTEGER,
    lgID    TEXT,
    note    TEXT,
    foreign key (coachID) references Coaches (coachID)
);
CREATE TABLE Master
(
    playerID     TEXT,
    coachID      TEXT,
    hofID        TEXT,
    firstName    TEXT,
    lastName     TEXT not null,
    nameNote     TEXT,
    nameGiven    TEXT,
    nameNick     TEXT,
    height       TEXT,
    weight       TEXT,
    shootCatch   TEXT,
    legendsID    TEXT,
    ihdbID       TEXT,
    hrefID       TEXT,
    firstNHL     TEXT,
    lastNHL      TEXT,
    firstWHA     TEXT,
    lastWHA     TEXT,
    pos          TEXT,
    birthYear    TEXT,
    birthMon     TEXT,
    birthDay     TEXT,
    birthCountry TEXT,
    birthState   TEXT,
    birthCity    TEXT,
    deathYear    TEXT,
    deathMon     TEXT,
    deathDay     TEXT,
    deathCountry TEXT,
    deathState   TEXT,
    deathCity    TEXT,
    foreign key (coachID) references Coaches (coachID)
            on update cascade on delete cascade
);
CREATE TABLE AwardsPlayers
(
    playerID TEXT    not null,
    award    TEXT    not null,
    year     INTEGER not null,
    lgID     TEXT,
    note     TEXT,
    pos      TEXT,
    primary key (playerID, award, year),
    foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE CombinedShutouts
(
    year      INTEGER,
    month     INTEGER,
    date      INTEGER,
    tmID      TEXT,
    oppID     TEXT,
    "R/P"     TEXT,
    IDgoalie1 TEXT,
    IDgoalie2 TEXT,
    foreign key (IDgoalie1) references Master (playerID)
            on update cascade on delete cascade,
    foreign key (IDgoalie2) references  Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE Goalies
(
    playerID TEXT    not null,
    year     INTEGER not null,
    stint    INTEGER not null,
    tmID     TEXT,
    lgID     TEXT,
    GP       TEXT,
    Min      TEXT,
    W        TEXT,
    L        TEXT,
    "T/OL"   TEXT,
    ENG      TEXT,
    SHO      TEXT,
    GA       TEXT,
    SA       TEXT,
    PostGP   TEXT,
    PostMin  TEXT,
    PostW    TEXT,
    PostL    TEXT,
    PostT    TEXT,
    PostENG  TEXT,
    PostSHO  TEXT,
    PostGA   TEXT,
    PostSA   TEXT,
    primary key (playerID, year, stint),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE GoaliesSC
(
    playerID TEXT    not null,
    year     INTEGER not null,
    tmID     TEXT,
    lgID     TEXT,
    GP       INTEGER,
    Min      INTEGER,
    W        INTEGER,
    L        INTEGER,
    T        INTEGER,
    SHO      INTEGER,
    GA       INTEGER,
    primary key (playerID, year),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE GoaliesShootout
(
    playerID TEXT,
    year     INTEGER,
    stint    INTEGER,
    tmID     TEXT,
    W        INTEGER,
    L        INTEGER,
    SA       INTEGER,
    GA       INTEGER,
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (playerID)  references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE Scoring
(
    playerID  TEXT,
    year      INTEGER,
    stint     INTEGER,
    tmID      TEXT,
    lgID      TEXT,
    pos       TEXT,
    GP        INTEGER,
    G         INTEGER,
    A         INTEGER,
    Pts       INTEGER,
    PIM       INTEGER,
    "+/-"     TEXT,
    PPG       TEXT,
    PPA       TEXT,
    SHG       TEXT,
    SHA       TEXT,
    GWG       TEXT,
    GTG       TEXT,
    SOG       TEXT,
    PostGP    TEXT,
    PostG     TEXT,
    PostA     TEXT,
    PostPts   TEXT,
    PostPIM   TEXT,
    "Post+/-" TEXT,
    PostPPG   TEXT,
    PostPPA   TEXT,
    PostSHG   TEXT,
    PostSHA   TEXT,
    PostGWG  TEXT,
    PostSOG   TEXT,
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE ScoringSC
(
    playerID TEXT,
    year     INTEGER,
    tmID     TEXT,
    lgID     TEXT,
    pos      TEXT,
    GP       INTEGER,
    G        INTEGER,
    A        INTEGER,
    Pts      INTEGER,
    PIM      INTEGER,
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE ScoringShootout
(
    playerID TEXT,
    year     INTEGER,
    stint    INTEGER,
    tmID     TEXT,
    S        INTEGER,
    G        INTEGER,
    GDG      INTEGER,
     foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE ScoringSup
(
    playerID TEXT,
    year     INTEGER,
    PPA      TEXT,
    SHA      TEXT,
     foreign key (playerID) references Master (playerID)
            on update cascade on delete cascade
);
CREATE TABLE SeriesPost
(
    year        INTEGER,
    round       TEXT,
    series      TEXT,
    tmIDWinner  TEXT,
    lgIDWinner  TEXT,
    tmIDLoser   TEXT,
    lgIDLoser   TEXT,
    W           INTEGER,
    L           INTEGER,
    T           INTEGER,
    GoalsWinner INTEGER,
    GoalsLoser  INTEGER,
    note        TEXT,
    foreign key (year, tmIDWinner) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (year, tmIDLoser) references Teams (year, tmID)
        on update cascade on delete cascade
);
CREATE TABLE TeamSplits
(
    year  INTEGER          not null,
    lgID  TEXT,
    tmID  TEXT not null,
    hW    INTEGER,
    hL    INTEGER,
    hT    INTEGER,
    hOTL  TEXT,
    rW    INTEGER,
    rL    INTEGER,
    rT    INTEGER,
    rOTL  TEXT,
    SepW  TEXT,
    SepL  TEXT,
    SepT  TEXT,
    SepOL TEXT,
    OctW TEXT,
    OctL  TEXT,
    OctT  TEXT,
    OctOL TEXT,
    NovW  TEXT,
    NovL  TEXT,
    NovT  TEXT,
    NovOL TEXT,
    DecW  TEXT,
    DecL  TEXT,
    DecT  TEXT,
    DecOL TEXT,
    JanW  INTEGER,
    JanL  INTEGER,
    JanT  INTEGER,
    JanOL TEXT,
    FebW  INTEGER,
    FebL  INTEGER,
    FebT  INTEGER,
    FebOL TEXT,
    MarW  TEXT,
    MarL  TEXT,
    MarT  TEXT,
    MarOL TEXT,
    AprW  TEXT,
    AprL  TEXT,
    AprT  TEXT,
    AprOL TEXT,
    primary key (year, tmID),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade
);
CREATE TABLE TeamVsTeam
(
    year  INTEGER          not null,
    lgID  TEXT,
    tmID  TEXT not null,
    oppID TEXT not null,
    W     INTEGER,
    L     INTEGER,
    T     INTEGER,
    OTL   TEXT,
    primary key (year, tmID, oppID),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade,
    foreign key (oppID, year) references Teams (tmID, year)
        on update cascade on delete cascade
);
CREATE TABLE TeamsHalf
(
    year INTEGER          not null,
    lgID TEXT,
    tmID TEXT not null,
    half INTEGER          not null,
    rank INTEGER,
    G    INTEGER,
    W    INTEGER,
    L    INTEGER,
    T    INTEGER,
    GF   INTEGER,
    GA   INTEGER,
    primary key (year, tmID, half),
    foreign key (tmID, year) references Teams (tmID, year)
        on update cascade on delete cascade
);
CREATE TABLE TeamsPost
(
    year       INTEGER          not null,
    lgID       TEXT,
    tmID       TEXT not null,
    G          INTEGER,
    W          INTEGER,
    L          INTEGER,
    T          INTEGER,
    GF         INTEGER,
    GA         INTEGER,
    PIM        TEXT,
    BenchMinor TEXT,
    PPG        TEXT,
    PPC        TEXT,
    SHA        TEXT,
    PKG        TEXT,
    PKC        TEXT,
    SHF        TEXT,
    primary key (year, tmID),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade
);
CREATE TABLE TeamsSC
(
    year INTEGER          not null,
    lgID TEXT,
    tmID TEXT not null,
    G    INTEGER,
    W    INTEGER,
    L    INTEGER,
    T    INTEGER,
    GF   INTEGER,
    GA   INTEGER,
    PIM  TEXT,
    primary key (year, tmID),
    foreign key (year, tmID) references Teams (year, tmID)
        on update cascade on delete cascade
);
CREATE TABLE abbrev
(
    Type     TEXT not null,
    Code     TEXT not null,
    Fullname TEXT,
    primary key (Type, Code)
);
 | 
| 
	music_platform_2 | 
	List all of the two-star reviews and their categories. | 
	two-stars review refers to rating = 2 | 
	SELECT T1.category FROM categories AS T1 INNER JOIN reviews AS T2 ON T2.podcast_id = T1.podcast_id WHERE T2.rating = 2 | 
	CREATE TABLE runs (
        run_at text not null,
        max_rowid integer not null,
        reviews_added integer not null
    );
CREATE TABLE podcasts (
        podcast_id text primary key,
        itunes_id integer not null,
        slug text not null,
        itunes_url text not null,
        title text not null
    );
CREATE TABLE IF NOT EXISTS "reviews"
(
    podcast_id TEXT    not null
        constraint reviews_podcasts_podcast_id_fk
            references podcasts,
    title      TEXT    not null,
    content    TEXT    not null,
    rating     INTEGER not null,
    author_id  TEXT    not null,
    created_at TEXT    not null
);
CREATE TABLE IF NOT EXISTS "categories"
(
    podcast_id TEXT not null
        constraint categories_podcasts_podcast_id_fk
            references podcasts,
    category   TEXT not null,
    constraint "PRIMARY"
        primary key (podcast_id, category)
);
CREATE INDEX category_podcast_id_idx
    on categories (podcast_id);
 | 
| 
	food_inspection_2 | 
	Who inspected Jean Samocki and what was the result? | 
	employee's name refers to first_name, last_name; Jean Samocki refers to dba_name = 'JEAN SAMOCKI' | 
	SELECT T3.first_name, T3.last_name, T2.results FROM establishment AS T1 INNER JOIN inspection AS T2 ON T1.license_no = T2.license_no INNER JOIN employee AS T3 ON T2.employee_id = T3.employee_id WHERE T1.dba_name = 'JEAN SAMOCKI' | 
	CREATE TABLE employee
(
    employee_id INTEGER
            primary key,
    first_name  TEXT,
    last_name   TEXT,
    address     TEXT,
    city        TEXT,
    state       TEXT,
    zip         INTEGER,
    phone       TEXT,
    title       TEXT,
    salary      INTEGER,
    supervisor  INTEGER,
    foreign key (supervisor) references employee(employee_id)
);
CREATE TABLE establishment
(
    license_no    INTEGER
            primary key,
    dba_name      TEXT,
    aka_name      TEXT,
    facility_type TEXT,
    risk_level    INTEGER,
    address       TEXT,
    city          TEXT,
    state         TEXT,
    zip           INTEGER,
    latitude      REAL,
    longitude     REAL,
    ward          INTEGER
);
CREATE TABLE inspection
(
    inspection_id   INTEGER
            primary key,
    inspection_date DATE,
    inspection_type TEXT,
    results         TEXT,
    employee_id     INTEGER,
    license_no      INTEGER,
    followup_to     INTEGER,
    foreign key (employee_id) references employee(employee_id),
    foreign key (license_no) references establishment(license_no),
    foreign key (followup_to) references inspection(inspection_id)
);
CREATE TABLE inspection_point
(
    point_id    INTEGER
            primary key,
    Description TEXT,
    category    TEXT,
    code        TEXT,
    fine        INTEGER,
    point_level TEXT
);
CREATE TABLE violation
(
    inspection_id     INTEGER,
    point_id          INTEGER,
    fine              INTEGER,
    inspector_comment TEXT,
    primary key (inspection_id, point_id),
    foreign key (inspection_id) references inspection(inspection_id),
    foreign key (point_id) references inspection_point(point_id)
);
 | 
| 
	car_retails | 
	Calculate the total price of shipped orders belonging to Land of Toys Inc. under the classic car line of products. | 
	SUM(MULTIPLY(quantityOrdered, priceEach)) where productLine = 'Classic Cars'; status = 'Shipped'; customername = 'Land of Toys Inc'; | 
	SELECT SUM(t3.priceEach * t3.quantityOrdered) FROM customers AS t1 INNER JOIN orders AS t2 ON t1.customerNumber = t2.customerNumber INNER JOIN orderdetails AS t3 ON t2.orderNumber = t3.orderNumber INNER JOIN products AS t4 ON t3.productCode = t4.productCode WHERE t4.productLine = 'Classic Cars' AND t1.customerName = 'Land of Toys Inc.' AND t2.status = 'Shipped' | 
	CREATE TABLE offices
(
    officeCode   TEXT not null
        primary key,
    city         TEXT not null,
    phone        TEXT not null,
    addressLine1 TEXT not null,
    addressLine2 TEXT,
    state        TEXT,
    country      TEXT not null,
    postalCode  TEXT not null,
    territory    TEXT not null
);
CREATE TABLE employees
(
    employeeNumber INTEGER      not null
        primary key,
    lastName       TEXT  not null,
    firstName      TEXT  not null,
    extension      TEXT  not null,
    email          TEXT not null,
    officeCode     TEXT  not null,
    reportsTo      INTEGER,
    jobTitle       TEXT  not null,
    foreign key (officeCode) references offices(officeCode),
    foreign key (reportsTo) references employees(employeeNumber)
);
CREATE TABLE customers
(
    customerNumber         INTEGER     not null
        primary key,
    customerName           TEXT not null,
    contactLastName        TEXT not null,
    contactFirstName       TEXT not null,
    phone                  TEXT not null,
    addressLine1           TEXT not null,
    addressLine2           TEXT,
    city                   TEXT not null,
    state                  TEXT,
    postalCode             TEXT,
    country                TEXT not null,
    salesRepEmployeeNumber INTEGER,
    creditLimit            REAL,
    foreign key (salesRepEmployeeNumber) references employees(employeeNumber)
);
CREATE TABLE orders
(
    orderNumber    INTEGER     not null
        primary key,
    orderDate      DATE        not null,
    requiredDate   DATE        not null,
    shippedDate    DATE,
    status         TEXT not null,
    comments       TEXT,
    customerNumber INTEGER     not null,
    foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE payments
(
    customerNumber INTEGER     not null,
    checkNumber    TEXT not null,
    paymentDate    DATE        not null,
    amount         REAL        not null,
    primary key (customerNumber, checkNumber),
    foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE productlines
(
    productLine     TEXT not null
        primary key,
    textDescription TEXT,
    htmlDescription TEXT,
    image           BLOB
);
CREATE TABLE products
(
    productCode        TEXT not null
        primary key,
    productName        TEXT not null,
    productLine        TEXT not null,
    productScale      TEXT not null,
    productVendor      TEXT not null,
    productDescription TEXT        not null,
    quantityInStock    INTEGER     not null,
    buyPrice           REAL        not null,
    MSRP               REAL        not null,
    foreign key (productLine) references productlines(productLine)
);
CREATE TABLE IF NOT EXISTS "orderdetails"
(
    orderNumber     INTEGER not null
        references orders,
    productCode     TEXT    not null
        references products,
    quantityOrdered INTEGER not null,
    priceEach       REAL    not null,
    orderLineNumber INTEGER not null,
    primary key (orderNumber, productCode)
);
 | 
| 
	movie_platform | 
	How many users have rated the most popular movie? | 
	most popular refers to Max(movie_popularity); | 
	SELECT COUNT(rating_id) FROM ratings WHERE movie_id = ( SELECT movie_id FROM movies ORDER BY movie_popularity DESC LIMIT 1 ) | 
	CREATE TABLE IF NOT EXISTS "lists"
(
    user_id                     INTEGER
        references lists_users (user_id),
    list_id                     INTEGER not null
        primary key,
    list_title                  TEXT,
    list_movie_number           INTEGER,
    list_update_timestamp_utc   TEXT,
    list_creation_timestamp_utc TEXT,
    list_followers              INTEGER,
    list_url                    TEXT,
    list_comments               INTEGER,
    list_description            TEXT,
    list_cover_image_url        TEXT,
    list_first_image_url        TEXT,
    list_second_image_url       TEXT,
    list_third_image_url        TEXT
);
CREATE TABLE IF NOT EXISTS "movies"
(
    movie_id             INTEGER not null
        primary key,
    movie_title          TEXT,
    movie_release_year   INTEGER,
    movie_url            TEXT,
    movie_title_language TEXT,
    movie_popularity     INTEGER,
    movie_image_url      TEXT,
    director_id          TEXT,
    director_name        TEXT,
    director_url         TEXT
);
CREATE TABLE IF NOT EXISTS "ratings_users"
(
    user_id                 INTEGER
        references lists_users (user_id),
    rating_date_utc         TEXT,
    user_trialist           INTEGER,
    user_subscriber         INTEGER,
    user_avatar_image_url   TEXT,
    user_cover_image_url    TEXT,
    user_eligible_for_trial INTEGER,
    user_has_payment_method INTEGER
);
CREATE TABLE lists_users
(
    user_id                 INTEGER not null ,
    list_id                 INTEGER not null ,
    list_update_date_utc    TEXT,
    list_creation_date_utc  TEXT,
    user_trialist           INTEGER,
    user_subscriber         INTEGER,
    user_avatar_image_url   TEXT,
    user_cover_image_url    TEXT,
    user_eligible_for_trial TEXT,
    user_has_payment_method TEXT,
    primary key (user_id, list_id),
    foreign key (list_id) references lists(list_id),
    foreign key (user_id) references lists(user_id)
);
CREATE TABLE ratings
(
    movie_id                INTEGER,
    rating_id               INTEGER,
    rating_url              TEXT,
    rating_score            INTEGER,
    rating_timestamp_utc    TEXT,
    critic                  TEXT,
    critic_likes            INTEGER,
    critic_comments         INTEGER,
    user_id                 INTEGER,
    user_trialist           INTEGER,
    user_subscriber         INTEGER,
    user_eligible_for_trial INTEGER,
    user_has_payment_method INTEGER,
    foreign key (movie_id) references movies(movie_id),
    foreign key (user_id) references lists_users(user_id),
    foreign key (rating_id) references ratings(rating_id),
    foreign key (user_id) references ratings_users(user_id)
);
 | 
| 
	chicago_crime | 
	How many crimes had happened in the community area with the most population? | 
	the most population refers to max(population) | 
	SELECT COUNT(T2.report_no) FROM Community_Area AS T1 INNER JOIN Crime AS T2 ON T1.community_area_no = T2.community_area_no GROUP BY T1.community_area_name ORDER BY T1.population DESC LIMIT 1 | 
	CREATE TABLE Community_Area
(
    community_area_no   INTEGER
            primary key,
    community_area_name TEXT,
    side                TEXT,
    population          TEXT
);
CREATE TABLE District
(
    district_no   INTEGER
            primary key,
    district_name TEXT,
    address       TEXT,
    zip_code      INTEGER,
    commander     TEXT,
    email         TEXT,
    phone         TEXT,
    fax           TEXT,
    tty           TEXT,
    twitter       TEXT
);
CREATE TABLE FBI_Code
(
    fbi_code_no   TEXT
            primary key,
    title         TEXT,
    description   TEXT,
    crime_against TEXT
);
CREATE TABLE IUCR
(
    iucr_no               TEXT
            primary key,
    primary_description   TEXT,
    secondary_description TEXT,
    index_code            TEXT
);
CREATE TABLE Neighborhood
(
    neighborhood_name TEXT
            primary key,
    community_area_no INTEGER,
    foreign key (community_area_no) references Community_Area(community_area_no)
);
CREATE TABLE Ward
(
    ward_no                INTEGER
            primary key,
    alderman_first_name    TEXT,
    alderman_last_name     TEXT,
    alderman_name_suffix   TEXT,
    ward_office_address    TEXT,
    ward_office_zip        TEXT,
    ward_email             TEXT,
    ward_office_phone      TEXT,
    ward_office_fax        TEXT,
    city_hall_office_room  INTEGER,
    city_hall_office_phone TEXT,
    city_hall_office_fax   TEXT,
    Population             INTEGER
);
CREATE TABLE Crime
(
    report_no            INTEGER
            primary key,
    case_number          TEXT,
    date                 TEXT,
    block                TEXT,
    iucr_no              TEXT,
    location_description TEXT,
    arrest               TEXT,
    domestic             TEXT,
    beat                 INTEGER,
    district_no          INTEGER,
    ward_no              INTEGER,
    community_area_no    INTEGER,
    fbi_code_no          TEXT,
    latitude             TEXT,
    longitude            TEXT,
    foreign key (ward_no) references Ward(ward_no),
    foreign key (iucr_no) references IUCR(iucr_no),
    foreign key (district_no) references District(district_no),
    foreign key (community_area_no) references Community_Area(community_area_no),
    foreign key (fbi_code_no) references FBI_Code(fbi_code_no)
);
 | 
| 
	human_resources | 
	Mention the employee's full name and performance status who got the lowest in salary per year. | 
	full name = firstname, lastname; the lowest salary refers to MIN(salary) | 
	SELECT firstname, lastname, performance FROM employee ORDER BY salary ASC LIMIT 1 | 
	CREATE TABLE location
(
    locationID   INTEGER
        constraint location_pk
            primary key,
    locationcity TEXT,
    address      TEXT,
    state        TEXT,
    zipcode      INTEGER,
    officephone  TEXT
);
CREATE TABLE position
(
    positionID        INTEGER
        constraint position_pk
            primary key,
    positiontitle     TEXT,
    educationrequired TEXT,
    minsalary         TEXT,
    maxsalary         TEXT
);
CREATE TABLE employee
(
    ssn         TEXT
            primary key,
    lastname    TEXT,
    firstname   TEXT,
    hiredate    TEXT,
    salary      TEXT,
    gender      TEXT,
    performance TEXT,
    positionID  INTEGER,
    locationID  INTEGER,
    foreign key (locationID) references location(locationID),
    foreign key (positionID) references position(positionID)
);
 | 
| 
	computer_student | 
	Which courses were taught by a professor who is not a faculty member? | 
	courses refers to taughtBy.course_id; professor refers to professor = 1; is not a faculty member refers to hasPosition = 0 | 
	SELECT DISTINCT T2.course_id FROM person AS T1 INNER JOIN taughtBy AS T2 ON T1.p_id = T2.p_id WHERE T1.professor = 1 AND T1.hasPosition = 0 | 
	CREATE TABLE course
(
    course_id   INTEGER
        constraint course_pk
            primary key,
    courseLevel TEXT
);
CREATE TABLE person
(
    p_id           INTEGER
        constraint person_pk
            primary key,
    professor      INTEGER,
    student        INTEGER,
    hasPosition    TEXT,
    inPhase        TEXT,
    yearsInProgram TEXT
);
CREATE TABLE IF NOT EXISTS "advisedBy"
(
    p_id       INTEGER,
    p_id_dummy INTEGER,
    constraint advisedBy_pk
        primary key (p_id, p_id_dummy),
    constraint advisedBy_person_p_id_p_id_fk
        foreign key (p_id, p_id_dummy) references person (p_id, p_id)
);
CREATE TABLE taughtBy
(
    course_id INTEGER,
    p_id      INTEGER,
    primary key (course_id, p_id),
    foreign key (p_id) references person(p_id),
    foreign key (course_id) references course(course_id)
);
 | 
| 
	sales | 
	What is the full name of the customer who purchased the highest amount of total price in a single purchase? | 
	full name of the customer = FirstName, MiddleInitial, LastName; highest amount of total price refers to MAX(MULTIPLY(Quantity, Price)); | 
	SELECT T2.FirstName, T2.MiddleInitial, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID INNER JOIN Products AS T3 ON T1.ProductID = T3.ProductID GROUP BY T1.SalesID, T1.Quantity, T3.Price, FirstName, MiddleInitial, LastName ORDER BY T1.Quantity * T3.Price DESC LIMIT 1 | 
	CREATE TABLE Customers
(
    CustomerID    INTEGER         not null
        primary key,
    FirstName     TEXT not null,
    MiddleInitial TEXT null,
    LastName      TEXT not null
);
CREATE TABLE Employees
(
    EmployeeID    INTEGER         not null
        primary key,
    FirstName     TEXT not null,
    MiddleInitial TEXT null,
    LastName      TEXT not null
);
CREATE TABLE Products
(
    ProductID INTEGER            not null
        primary key,
    Name      TEXT    not null,
    Price     REAL null
);
CREATE TABLE Sales
(
    SalesID       INTEGER not null
        primary key,
    SalesPersonID INTEGER not null,
    CustomerID    INTEGER not null,
    ProductID     INTEGER not null,
    Quantity      INTEGER not null,
    foreign key (SalesPersonID) references Employees (EmployeeID)
            on update cascade on delete cascade,
        foreign key (CustomerID) references Customers (CustomerID)
            on update cascade on delete cascade,
        foreign key (ProductID) references Products (ProductID)
            on update cascade on delete cascade
);
 | 
| 
	movies_4 | 
	Provide the average revenue of all the French movies. | 
	French movies refers to country_name = 'France'; average revenue = AVG(revenue) | 
	SELECT AVG(T1.revenue) FROM movie AS T1 INNER JOIN production_COUNTry AS T2 ON T1.movie_id = T2.movie_id INNER JOIN COUNTry AS T3 ON T2.COUNTry_id = T3.COUNTry_id WHERE T3.COUNTry_name = 'France' | 
	CREATE TABLE country
(
    country_id       INTEGER not null
            primary key,
    country_iso_code TEXT  default NULL,
    country_name     TEXT default NULL
);
CREATE TABLE department
(
    department_id   INTEGER not null
            primary key,
    department_name TEXT default NULL
);
CREATE TABLE gender
(
    gender_id INTEGER not null
            primary key,
    gender    TEXT default NULL
);
CREATE TABLE genre
(
    genre_id   INTEGER not null
            primary key,
    genre_name TEXT default NULL
);
CREATE TABLE keyword
(
    keyword_id   INTEGER not null
            primary key,
    keyword_name TEXT default NULL
);
CREATE TABLE language
(
    language_id   INTEGER not null
            primary key,
    language_code TEXT  default NULL,
    language_name TEXT default NULL
);
CREATE TABLE language_role
(
    role_id       INTEGER not null
            primary key,
    language_role TEXT default NULL
);
CREATE TABLE movie
(
    movie_id    INTEGER not null
            primary key,
    title        TEXT  default NULL,
    budget       INTEGER            default NULL,
    homepage     TEXT  default NULL,
    overview     TEXT  default NULL,
    popularity   REAL default NULL,
    release_date DATE           default NULL,
    revenue      INTEGER     default NULL,
    runtime      INTEGER           default NULL,
    movie_status TEXT    default NULL,
    tagline      TEXT  default NULL,
    vote_average REAL  default NULL,
    vote_count   INTEGER            default NULL
);
CREATE TABLE movie_genres
(
    movie_id INTEGER default NULL,
    genre_id INTEGER default NULL,
    foreign key (genre_id) references genre(genre_id),
    foreign key (movie_id) references movie(movie_id)
);
CREATE TABLE movie_languages
(
    movie_id         INTEGER default NULL,
    language_id      INTEGER default NULL,
    language_role_id INTEGER default NULL,
    foreign key (language_id) references language(language_id),
    foreign key (movie_id) references movie(movie_id),
    foreign key (language_role_id) references language_role(role_id)
);
CREATE TABLE person
(
    person_id   INTEGER not null
            primary key,
    person_name TEXT default NULL
);
CREATE TABLE movie_crew
(
    movie_id      INTEGER          default NULL,
    person_id     INTEGER          default NULL,
    department_id INTEGER          default NULL,
    job           TEXT default NULL,
    foreign key (department_id) references department(department_id),
    foreign key (movie_id) references movie(movie_id),
    foreign key (person_id) references person(person_id)
);
CREATE TABLE production_company
(
    company_id   INTEGER not null
            primary key,
    company_name TEXT default NULL
);
CREATE TABLE production_country
(
    movie_id   INTEGER default NULL,
    country_id INTEGER default NULL,
    foreign key (country_id) references country(country_id),
    foreign key (movie_id) references movie(movie_id)
);
CREATE TABLE movie_cast
(
    movie_id       INTEGER          default NULL,
    person_id      INTEGER          default NULL,
    character_name TEXT default NULL,
    gender_id      INTEGER          default NULL,
    cast_order     INTEGER       default NULL,
    foreign key (gender_id) references gender(gender_id),
    foreign key (movie_id) references movie(movie_id),
    foreign key (person_id) references person(person_id)
);
CREATE TABLE IF NOT EXISTS "movie_keywords"
(
    movie_id   INTEGER default NULL
        references movie,
    keyword_id INTEGER default NULL
        references keyword
);
CREATE TABLE IF NOT EXISTS "movie_company"
(
    movie_id   INTEGER default NULL
        references movie,
    company_id INTEGER default NULL
        references production_company
);
 | 
| 
	donor | 
	What is the name of the vendor that the project "Bloody Times" uses for their resources? | 
	project "Bloody Times" refers to title = 'Bloody Times' | 
	SELECT T3.vendor_name FROM essays AS T1 INNER JOIN projects AS T2 ON T1.projectid = T2.projectid INNER JOIN resources AS T3 ON T2.projectid = T3.projectid WHERE T1.title = 'Bloody Times' | 
	CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "essays"
(
    projectid         TEXT,
    teacher_acctid    TEXT,
    title             TEXT,
    short_description TEXT,
    need_statement    TEXT,
    essay             TEXT
);
CREATE TABLE IF NOT EXISTS "projects"
(
    projectid                              TEXT not null
        primary key,
    teacher_acctid                         TEXT,
    schoolid                               TEXT,
    school_ncesid                          TEXT,
    school_latitude                        REAL,
    school_longitude                       REAL,
    school_city                            TEXT,
    school_state                           TEXT,
    school_zip                             INTEGER,
    school_metro                           TEXT,
    school_district                        TEXT,
    school_county                          TEXT,
    school_charter                         TEXT,
    school_magnet                          TEXT,
    school_year_round                      TEXT,
    school_nlns                            TEXT,
    school_kipp                            TEXT,
    school_charter_ready_promise           TEXT,
    teacher_prefix                         TEXT,
    teacher_teach_for_america              TEXT,
    teacher_ny_teaching_fellow             TEXT,
    primary_focus_subject                  TEXT,
    primary_focus_area                     TEXT,
    secondary_focus_subject                TEXT,
    secondary_focus_area                   TEXT,
    resource_type                          TEXT,
    poverty_level                          TEXT,
    grade_level                            TEXT,
    fulfillment_labor_materials            REAL,
    total_price_excluding_optional_support REAL,
    total_price_including_optional_support REAL,
    students_reached                       INTEGER,
    eligible_double_your_impact_match      TEXT,
    eligible_almost_home_match             TEXT,
    date_posted                            DATE
);
CREATE TABLE donations
(
    donationid                               TEXT not null
            primary key,
    projectid                               TEXT,
    donor_acctid                             TEXT,
    donor_city                               TEXT,
    donor_state                              TEXT,
    donor_zip                                TEXT,
    is_teacher_acct                          TEXT,
    donation_timestamp                       DATETIME,
    donation_to_project                      REAL,
    donation_optional_support                REAL,
    donation_total                           REAL,
    dollar_amount                            TEXT,
    donation_included_optional_support       TEXT,
    payment_method                           TEXT,
    payment_included_acct_credit             TEXT,
    payment_included_campaign_gift_card      TEXT,
    payment_included_web_purchased_gift_card TEXT,
    payment_was_promo_matched                TEXT,
    via_giving_page                          TEXT,
    for_honoree                              TEXT,
    donation_message                         TEXT,
    foreign key (projectid) references projects(projectid)
);
CREATE TABLE resources
(
    resourceid            TEXT not null
            primary key,
    projectid             TEXT,
    vendorid              INTEGER,
    vendor_name           TEXT,
    project_resource_type TEXT,
    item_name             TEXT,
    item_number           TEXT,
    item_unit_price       REAL,
    item_quantity         INTEGER,
    foreign key (projectid) references projects(projectid)
);
 | 
| 
	retail_complains | 
	What is the oldest age of male clients? | 
	oldest age refers to max(age); male refers to sex = 'Male' | 
	SELECT MAX(age) FROM client WHERE sex = 'Male' | 
	CREATE TABLE state
(
    StateCode TEXT
        constraint state_pk
            primary key,
    State     TEXT,
    Region    TEXT
);
CREATE TABLE callcenterlogs
(
    "Date received" DATE,
    "Complaint ID"  TEXT,
    "rand client"   TEXT,
    phonefinal      TEXT,
    "vru+line"      TEXT,
    call_id         INTEGER,
    priority        INTEGER,
    type            TEXT,
    outcome         TEXT,
    server          TEXT,
    ser_start       TEXT,
    ser_exit        TEXT,
    ser_time        TEXT,
    primary key ("Complaint ID"),
    foreign key ("rand client") references client(client_id)
);
CREATE TABLE client
(
    client_id   TEXT
            primary key,
    sex         TEXT,
    day         INTEGER,
    month       INTEGER,
    year        INTEGER,
    age         INTEGER,
    social      TEXT,
    first       TEXT,
    middle      TEXT,
    last        TEXT,
    phone       TEXT,
    email       TEXT,
    address_1   TEXT,
    address_2   TEXT,
    city        TEXT,
    state       TEXT,
    zipcode     INTEGER,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
);
CREATE TABLE district
(
    district_id  INTEGER
            primary key,
    city         TEXT,
    state_abbrev TEXT,
    division     TEXT,
    foreign key (state_abbrev) references state(StateCode)
);
CREATE TABLE events
(
    "Date received"                DATE,
    Product                        TEXT,
    "Sub-product"                  TEXT,
    Issue                          TEXT,
    "Sub-issue"                    TEXT,
    "Consumer complaint narrative" TEXT,
    Tags                           TEXT,
    "Consumer consent provided?"   TEXT,
    "Submitted via"                TEXT,
    "Date sent to company"         TEXT,
    "Company response to consumer" TEXT,
    "Timely response?"             TEXT,
    "Consumer disputed?"           TEXT,
    "Complaint ID"                 TEXT,
    Client_ID                      TEXT,
    primary key ("Complaint ID", Client_ID),
    foreign key ("Complaint ID") references callcenterlogs("Complaint ID"),
    foreign key (Client_ID) references client(client_id)
);
CREATE TABLE reviews
(
    "Date"        DATE
            primary key,
    Stars       INTEGER,
    Reviews     TEXT,
    Product     TEXT,
    district_id INTEGER,
    foreign key (district_id) references district(district_id)
);
 | 
| 
	works_cycles | 
	Please tell the meaning of CultureID "fr". | 
	tell the meaning is to find the name of culture | 
	SELECT Name FROM Culture WHERE CultureID = 'fr' | 
	CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
    CountryRegionCode TEXT                          not null
        primary key,
    Name              TEXT                        not null
            unique,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE Culture
(
    CultureID    TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Currency
(
    CurrencyCode TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE CountryRegionCurrency
(
    CountryRegionCode TEXT                          not null,
    CurrencyCode      TEXT                             not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    primary key (CountryRegionCode, CurrencyCode),
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode),
    foreign key (CurrencyCode) references Currency(CurrencyCode)
);
CREATE TABLE Person
(
    BusinessEntityID      INTEGER                                  not null
        primary key,
    PersonType            TEXT                              not null,
    NameStyle             INTEGER default 0                 not null,
    Title                 TEXT,
    FirstName             TEXT                         not null,
    MiddleName            TEXT,
    LastName              TEXT                         not null,
    Suffix                TEXT,
    EmailPromotion        INTEGER        default 0                 not null,
    AdditionalContactInfo TEXT,
    Demographics          TEXT,
    rowguid               TEXT                          not null
            unique,
    ModifiedDate          DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE BusinessEntityContact
(
    BusinessEntityID INTEGER                                 not null,
    PersonID         INTEGER                                 not null,
    ContactTypeID    INTEGER                                 not null,
    rowguid         TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, PersonID, ContactTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (ContactTypeID) references ContactType(ContactTypeID),
    foreign key (PersonID) references Person(BusinessEntityID)
);
CREATE TABLE EmailAddress
(
    BusinessEntityID INTEGER                                 not null,
    EmailAddressID   INTEGER,
    EmailAddress     TEXT,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (EmailAddressID, BusinessEntityID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Employee
(
    BusinessEntityID  INTEGER                                 not null
        primary key,
    NationalIDNumber  TEXT                          not null
            unique,
    LoginID           TEXT                         not null
            unique,
    OrganizationNode  TEXT,
    OrganizationLevel INTEGER,
    JobTitle          TEXT                          not null,
    BirthDate         DATE                                 not null,
    MaritalStatus     TEXT                                 not null,
    Gender            TEXT                                 not null,
    HireDate          DATE                                 not null,
    SalariedFlag      INTEGER default 1                 not null,
    VacationHours     INTEGER   default 0                 not null,
    SickLeaveHours    INTEGER   default 0                 not null,
    CurrentFlag       INTEGER default 1                 not null,
    rowguid           TEXT                          not null
            unique,
    ModifiedDate      DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Password
(
    BusinessEntityID INTEGER                                 not null
        primary key,
    PasswordHash     TEXT                        not null,
    PasswordSalt     TEXT                         not null,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE PersonCreditCard
(
    BusinessEntityID INTEGER                                 not null,
    CreditCardID     INTEGER                                 not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, CreditCardID),
    foreign key (CreditCardID) references CreditCard(CreditCardID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE ProductCategory
(
    ProductCategoryID INTEGER
        primary key autoincrement,
    Name              TEXT                        not null
        unique,
    rowguid           TEXT                         not null
        unique,
    ModifiedDate      DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductDescription
(
    ProductDescriptionID INTEGER
        primary key autoincrement,
    Description          TEXT                        not null,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModel
(
    ProductModelID     INTEGER
        primary key autoincrement,
    Name               TEXT                        not null
        unique,
    CatalogDescription TEXT,
    Instructions       TEXT,
    rowguid            TEXT                         not null
        unique,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModelProductDescriptionCulture
(
    ProductModelID       INTEGER                             not null,
    ProductDescriptionID INTEGER                             not null,
    CultureID            TEXT                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductModelID, ProductDescriptionID, CultureID),
    foreign key (ProductModelID) references ProductModel(ProductModelID),
    foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID),
    foreign key (CultureID) references Culture(CultureID)
);
CREATE TABLE ProductPhoto
(
    ProductPhotoID         INTEGER
        primary key autoincrement,
    ThumbNailPhoto         BLOB,
    ThumbnailPhotoFileName TEXT,
    LargePhoto             BLOB,
    LargePhotoFileName     TEXT,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductSubcategory
(
    ProductSubcategoryID INTEGER
        primary key autoincrement,
    ProductCategoryID    INTEGER                             not null,
    Name                 TEXT                        not null
        unique,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate        DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID)
);
CREATE TABLE SalesReason
(
    SalesReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null,
    ReasonType    TEXT                        not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE SalesTerritory
(
    TerritoryID       INTEGER
        primary key autoincrement,
    Name              TEXT                             not null
        unique,
    CountryRegionCode TEXT                               not null,
    "Group"           TEXT                              not null,
    SalesYTD          REAL default 0.0000            not null,
    SalesLastYear     REAL default 0.0000            not null,
    CostYTD           REAL default 0.0000            not null,
    CostLastYear      REAL default 0.0000            not null,
    rowguid           TEXT                              not null
        unique,
    ModifiedDate      DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode)
);
CREATE TABLE SalesPerson
(
    BusinessEntityID INTEGER                                  not null
        primary key,
    TerritoryID      INTEGER,
    SalesQuota       REAL,
    Bonus            REAL default 0.0000            not null,
    CommissionPct    REAL default 0.0000            not null,
    SalesYTD         REAL default 0.0000            not null,
    SalesLastYear    REAL default 0.0000            not null,
    rowguid          TEXT                              not null
        unique,
    ModifiedDate     DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references Employee(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE SalesPersonQuotaHistory
(
    BusinessEntityID INTEGER                             not null,
    QuotaDate        DATETIME                            not null,
    SalesQuota       REAL                      not null,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, QuotaDate),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesTerritoryHistory
(
    BusinessEntityID INTEGER                             not null,
    TerritoryID      INTEGER                             not null,
    StartDate        DATETIME                            not null,
    EndDate          DATETIME,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, StartDate, TerritoryID),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE ScrapReason
(
    ScrapReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null
        unique,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE Shift
(
    ShiftID      INTEGER
        primary key autoincrement,
    Name         TEXT                        not null
        unique,
    StartTime    TEXT                                not null,
    EndTime      TEXT                                not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    unique (StartTime, EndTime)
);
CREATE TABLE ShipMethod
(
    ShipMethodID INTEGER
        primary key autoincrement,
    Name         TEXT                             not null
        unique,
    ShipBase     REAL default 0.0000            not null,
    ShipRate    REAL default 0.0000            not null,
    rowguid      TEXT                              not null
        unique,
    ModifiedDate DATETIME      default CURRENT_TIMESTAMP not null
);
CREATE TABLE SpecialOffer
(
    SpecialOfferID INTEGER
        primary key autoincrement,
    Description    TEXT                             not null,
    DiscountPct    REAL   default 0.0000            not null,
    Type           TEXT                             not null,
    Category       TEXT                             not null,
    StartDate      DATETIME                            not null,
    EndDate        DATETIME                            not null,
    MinQty         INTEGER   default 0                 not null,
    MaxQty         INTEGER,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE BusinessEntityAddress
(
    BusinessEntityID INTEGER                                 not null,
    AddressID        INTEGER                                 not null,
    AddressTypeID    INTEGER                                 not null,
    rowguid          TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, AddressID, AddressTypeID),
    foreign key (AddressID) references Address(AddressID),
    foreign key (AddressTypeID) references AddressType(AddressTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE SalesTaxRate
(
    SalesTaxRateID  INTEGER
        primary key autoincrement,
    StateProvinceID INTEGER                                  not null,
    TaxType         INTEGER                                  not null,
    TaxRate         REAL default 0.0000            not null,
    Name            TEXT                             not null,
    rowguid         TEXT                              not null
        unique,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    unique (StateProvinceID, TaxType),
    foreign key (StateProvinceID) references StateProvince(StateProvinceID)
);
CREATE TABLE Store
(
    BusinessEntityID INTEGER                             not null
        primary key,
    Name             TEXT                        not null,
    SalesPersonID    INTEGER,
    Demographics     TEXT,
    rowguid          TEXT                             not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (SalesPersonID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesOrderHeaderSalesReason
(
    SalesOrderID  INTEGER                             not null,
    SalesReasonID INTEGER                             not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SalesOrderID, SalesReasonID),
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SalesReasonID) references SalesReason(SalesReasonID)
);
CREATE TABLE TransactionHistoryArchive
(
    TransactionID        INTEGER                             not null
        primary key,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE UnitMeasure
(
    UnitMeasureCode TEXT                             not null
        primary key,
    Name            TEXT                        not null
        unique,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductCostHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    StandardCost REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ProductDocument
(
    ProductID    INTEGER                             not null,
    DocumentNode TEXT                        not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, DocumentNode),
    foreign key (ProductID) references Product(ProductID),
    foreign key (DocumentNode) references Document(DocumentNode)
);
CREATE TABLE ProductInventory
(
    ProductID    INTEGER                             not null,
    LocationID   INTEGER                            not null,
    Shelf        TEXT                         not null,
    Bin          INTEGER                             not null,
    Quantity     INTEGER  default 0                 not null,
    rowguid      TEXT                         not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, LocationID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE ProductProductPhoto
(
    ProductID      INTEGER                             not null,
    ProductPhotoID INTEGER                             not null,
    "Primary"      INTEGER   default 0                 not null,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, ProductPhotoID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID)
);
CREATE TABLE ProductReview
(
    ProductReviewID INTEGER
        primary key autoincrement,
    ProductID       INTEGER                             not null,
    ReviewerName   TEXT                        not null,
    ReviewDate      DATETIME default CURRENT_TIMESTAMP not null,
    EmailAddress    TEXT                         not null,
    Rating          INTEGER                             not null,
    Comments        TEXT,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ShoppingCartItem
(
    ShoppingCartItemID INTEGER
        primary key autoincrement,
    ShoppingCartID     TEXT                         not null,
    Quantity           INTEGER   default 1                 not null,
    ProductID          INTEGER                             not null,
    DateCreated        DATETIME default CURRENT_TIMESTAMP not null,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SpecialOfferProduct
(
    SpecialOfferID INTEGER                             not null,
    ProductID      INTEGER                             not null,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SpecialOfferID, ProductID),
    foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SalesOrderDetail
(
    SalesOrderID          INTEGER                             not null,
    SalesOrderDetailID    INTEGER
        primary key autoincrement,
    CarrierTrackingNumber TEXT,
    OrderQty              INTEGER                             not null,
    ProductID             INTEGER                             not null,
    SpecialOfferID        INTEGER                             not null,
    UnitPrice             REAL                             not null,
    UnitPriceDiscount     REAL   default 0.0000            not null,
    LineTotal             REAL                             not null,
    rowguid               TEXT                             not null
        unique,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID)
);
CREATE TABLE TransactionHistory
(
    TransactionID        INTEGER
        primary key autoincrement,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE Vendor
(
    BusinessEntityID        INTEGER                             not null
        primary key,
    AccountNumber           TEXT                         not null
        unique,
    Name                    TEXT                        not null,
    CreditRating            INTEGER                             not null,
    PreferredVendorStatus   INTEGER   default 1                 not null,
    ActiveFlag              INTEGER   default 1                 not null,
    PurchasingWebServiceURL TEXT,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE ProductVendor
(
    ProductID        INTEGER                             not null,
    BusinessEntityID INTEGER                             not null,
    AverageLeadTime  INTEGER                             not null,
    StandardPrice    REAL                      not null,
    LastReceiptCost  REAL,
    LastReceiptDate  DATETIME,
    MinOrderQty      INTEGER                             not null,
    MaxOrderQty      INTEGER                             not null,
    OnOrderQty       INTEGER,
    UnitMeasureCode  TEXT                             not null,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, BusinessEntityID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (BusinessEntityID) references Vendor(BusinessEntityID),
    foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode)
);
CREATE TABLE PurchaseOrderHeader
(
    PurchaseOrderID INTEGER
        primary key autoincrement,
    RevisionNumber  INTEGER        default 0                 not null,
    Status          INTEGER        default 1                 not null,
    EmployeeID      INTEGER                                  not null,
    VendorID        INTEGER                                  not null,
    ShipMethodID    INTEGER                                  not null,
    OrderDate       DATETIME      default CURRENT_TIMESTAMP not null,
    ShipDate        DATETIME,
    SubTotal        REAL default 0.0000            not null,
    TaxAmt          REAL default 0.0000            not null,
    Freight         REAL default 0.0000            not null,
    TotalDue        REAL                          not null,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (EmployeeID) references Employee(BusinessEntityID),
    foreign key (VendorID) references Vendor(BusinessEntityID),
    foreign key (ShipMethodID) references ShipMethod(ShipMethodID)
);
CREATE TABLE PurchaseOrderDetail
(
    PurchaseOrderID       INTEGER                            not null,
    PurchaseOrderDetailID INTEGER
        primary key autoincrement,
    DueDate               DATETIME                           not null,
    OrderQty              INTEGER                           not null,
    ProductID             INTEGER                            not null,
    UnitPrice             REAL                            not null,
    LineTotal             REAL                            not null,
    ReceivedQty           REAL                            not null,
    RejectedQty           REAL                            not null,
    StockedQty            REAL                            not null,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE WorkOrder
(
    WorkOrderID   INTEGER
        primary key autoincrement,
    ProductID     INTEGER                             not null,
    OrderQty      INTEGER                             not null,
    StockedQty    INTEGER                             not null,
    ScrappedQty   INTEGER                           not null,
    StartDate     DATETIME                            not null,
    EndDate       DATETIME,
    DueDate       DATETIME                            not null,
    ScrapReasonID INTEGER,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID),
    foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID)
);
CREATE TABLE WorkOrderRouting
(
    WorkOrderID        INTEGER                             not null,
    ProductID          INTEGER                             not null,
    OperationSequence  INTEGER                             not null,
    LocationID         INTEGER                             not null,
    ScheduledStartDate DATETIME                            not null,
    ScheduledEndDate   DATETIME                            not null,
    ActualStartDate    DATETIME,
    ActualEndDate      DATETIME,
    ActualResourceHrs  REAL,
    PlannedCost        REAL                      not null,
    ActualCost         REAL,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    primary key (WorkOrderID, ProductID, OperationSequence),
    foreign key (WorkOrderID) references WorkOrder(WorkOrderID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE Customer
(
    CustomerID    INTEGER
        primary key,
    PersonID      INTEGER,
    StoreID       INTEGER,
    TerritoryID   INTEGER,
    AccountNumber TEXT                         not null
            unique,
    rowguid       TEXT                         not null
            unique,
    ModifiedDate  DATETIME default current_timestamp not null,
    foreign key (PersonID) references Person(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID),
    foreign key (StoreID) references Store(BusinessEntityID)
);
CREATE TABLE ProductListPriceHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    ListPrice    REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE IF NOT EXISTS "Address"
(
    AddressID       INTEGER
        primary key autoincrement,
    AddressLine1    TEXT                               not null,
    AddressLine2    TEXT,
    City            TEXT                               not null,
    StateProvinceID INTEGER                            not null
        references StateProvince,
    PostalCode      TEXT                               not null,
    SpatialLocation TEXT,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode)
);
CREATE TABLE IF NOT EXISTS "AddressType"
(
    AddressTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    rowguid       TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "BillOfMaterials"
(
    BillOfMaterialsID INTEGER
        primary key autoincrement,
    ProductAssemblyID INTEGER
        references Product,
    ComponentID       INTEGER                            not null
        references Product,
    StartDate         DATETIME default current_timestamp not null,
    EndDate           DATETIME,
    UnitMeasureCode   TEXT                               not null
        references UnitMeasure,
    BOMLevel          INTEGER                            not null,
    PerAssemblyQty    REAL     default 1.00              not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    unique (ProductAssemblyID, ComponentID, StartDate)
);
CREATE TABLE IF NOT EXISTS "BusinessEntity"
(
    BusinessEntityID INTEGER
        primary key autoincrement,
    rowguid          TEXT                               not null
        unique,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "ContactType"
(
    ContactTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "CurrencyRate"
(
    CurrencyRateID   INTEGER
        primary key autoincrement,
    CurrencyRateDate DATETIME                           not null,
    FromCurrencyCode TEXT                               not null
        references Currency,
    ToCurrencyCode   TEXT                               not null
        references Currency,
    AverageRate      REAL                               not null,
    EndOfDayRate     REAL                               not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode)
);
CREATE TABLE IF NOT EXISTS "Department"
(
    DepartmentID INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    GroupName    TEXT                               not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    DepartmentID     INTEGER                            not null
        references Department,
    ShiftID          INTEGER                            not null
        references Shift,
    StartDate        DATE                               not null,
    EndDate          DATE,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID)
);
CREATE TABLE IF NOT EXISTS "EmployeePayHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    RateChangeDate   DATETIME                           not null,
    Rate             REAL                               not null,
    PayFrequency     INTEGER                            not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, RateChangeDate)
);
CREATE TABLE IF NOT EXISTS "JobCandidate"
(
    JobCandidateID   INTEGER
        primary key autoincrement,
    BusinessEntityID INTEGER
        references Employee,
    Resume           TEXT,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Location"
(
    LocationID   INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    CostRate     REAL     default 0.0000            not null,
    Availability REAL     default 0.00              not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "PhoneNumberType"
(
    PhoneNumberTypeID INTEGER
        primary key autoincrement,
    Name              TEXT                               not null,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Product"
(
    ProductID             INTEGER
        primary key autoincrement,
    Name                  TEXT                               not null
        unique,
    ProductNumber         TEXT                               not null
        unique,
    MakeFlag              INTEGER  default 1                 not null,
    FinishedGoodsFlag     INTEGER  default 1                 not null,
    Color                 TEXT,
    SafetyStockLevel      INTEGER                            not null,
    ReorderPoint          INTEGER                            not null,
    StandardCost          REAL                               not null,
    ListPrice             REAL                               not null,
    Size                  TEXT,
    SizeUnitMeasureCode   TEXT
        references UnitMeasure,
    WeightUnitMeasureCode TEXT
        references UnitMeasure,
    Weight                REAL,
    DaysToManufacture     INTEGER                            not null,
    ProductLine           TEXT,
    Class                 TEXT,
    Style                 TEXT,
    ProductSubcategoryID  INTEGER
        references ProductSubcategory,
    ProductModelID        INTEGER
        references ProductModel,
    SellStartDate         DATETIME                           not null,
    SellEndDate           DATETIME,
    DiscontinuedDate      DATETIME,
    rowguid               TEXT                               not null
        unique,
    ModifiedDate          DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Document"
(
    DocumentNode    TEXT                               not null
        primary key,
    DocumentLevel   INTEGER,
    Title           TEXT                               not null,
    Owner           INTEGER                            not null
        references Employee,
    FolderFlag      INTEGER  default 0                 not null,
    FileName        TEXT                               not null,
    FileExtension   TEXT                               not null,
    Revision        TEXT                               not null,
    ChangeNumber    INTEGER  default 0                 not null,
    Status          INTEGER                            not null,
    DocumentSummary TEXT,
    Document        BLOB,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (DocumentLevel, DocumentNode)
);
CREATE TABLE IF NOT EXISTS "StateProvince"
(
    StateProvinceID         INTEGER
        primary key autoincrement,
    StateProvinceCode       TEXT                               not null,
    CountryRegionCode       TEXT                               not null
        references CountryRegion,
    IsOnlyStateProvinceFlag INTEGER  default 1                 not null,
    Name                    TEXT                               not null
        unique,
    TerritoryID             INTEGER                            not null
        references SalesTerritory,
    rowguid                 TEXT                               not null
        unique,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    unique (StateProvinceCode, CountryRegionCode)
);
CREATE TABLE IF NOT EXISTS "CreditCard"
(
    CreditCardID INTEGER
        primary key autoincrement,
    CardType     TEXT                               not null,
    CardNumber   TEXT                               not null
        unique,
    ExpMonth     INTEGER                            not null,
    ExpYear      INTEGER                            not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "SalesOrderHeader"
(
    SalesOrderID           INTEGER
        primary key autoincrement,
    RevisionNumber         INTEGER  default 0                 not null,
    OrderDate              DATETIME default CURRENT_TIMESTAMP not null,
    DueDate                DATETIME                           not null,
    ShipDate               DATETIME,
    Status                 INTEGER  default 1                 not null,
    OnlineOrderFlag        INTEGER  default 1                 not null,
    SalesOrderNumber       TEXT                               not null
        unique,
    PurchaseOrderNumber    TEXT,
    AccountNumber          TEXT,
    CustomerID             INTEGER                            not null
        references Customer,
    SalesPersonID          INTEGER
        references SalesPerson,
    TerritoryID            INTEGER
        references SalesTerritory,
    BillToAddressID        INTEGER                            not null
        references Address,
    ShipToAddressID        INTEGER                            not null
        references Address,
    ShipMethodID           INTEGER                            not null
        references Address,
    CreditCardID           INTEGER
        references CreditCard,
    CreditCardApprovalCode TEXT,
    CurrencyRateID         INTEGER
        references CurrencyRate,
    SubTotal               REAL     default 0.0000            not null,
    TaxAmt                 REAL     default 0.0000            not null,
    Freight                REAL     default 0.0000            not null,
    TotalDue               REAL                               not null,
    Comment                TEXT,
    rowguid                TEXT                               not null
        unique,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
 | 
| 
	retail_world | 
	What is the average annual amount of shipped sales from 1997 to 1998? | 
	from 1997 to 1998 refers to ShippedDate > '1996-1-1' and ShippedDate < '1998-12-31'; average annual amount refers to SUM(MULTIPLY(UnitPrice, Quantity, SUBTRACT(1, Discount))) | 
	SELECT SUM(T2.UnitPrice * T2.Quantity * (1 - T2.Discount)) / 3 FROM Orders AS T1 INNER JOIN `Order Details` AS T2 ON T1.OrderID = T2.OrderID WHERE T1.ShippedDate BETWEEN '1996-01-01 00:00:00' AND '1998-12-31 23:59:59' | 
	CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE Categories
(
    CategoryID INTEGER PRIMARY KEY AUTOINCREMENT,
    CategoryName TEXT,
    Description TEXT
);
CREATE TABLE Customers
(
    CustomerID INTEGER PRIMARY KEY AUTOINCREMENT,
    CustomerName TEXT,
    ContactName TEXT,
    Address TEXT,
    City TEXT,
    PostalCode TEXT,
    Country TEXT
);
CREATE TABLE Employees
(
    EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT,
    LastName TEXT,
    FirstName TEXT,
    BirthDate DATE,
    Photo TEXT,
    Notes TEXT
);
CREATE TABLE Shippers(
    ShipperID INTEGER PRIMARY KEY AUTOINCREMENT,
    ShipperName TEXT,
    Phone TEXT
);
CREATE TABLE Suppliers(
    SupplierID INTEGER PRIMARY KEY AUTOINCREMENT,
    SupplierName TEXT,
    ContactName TEXT,
    Address TEXT,
    City TEXT,
    PostalCode TEXT,
    Country TEXT,
    Phone TEXT
);
CREATE TABLE Products(
    ProductID INTEGER PRIMARY KEY AUTOINCREMENT,
    ProductName TEXT,
    SupplierID INTEGER,
    CategoryID INTEGER,
    Unit TEXT,
    Price REAL DEFAULT 0,
	FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID),
	FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID)
);
CREATE TABLE Orders(
    OrderID INTEGER PRIMARY KEY AUTOINCREMENT,
    CustomerID INTEGER,
    EmployeeID INTEGER,
    OrderDate DATETIME,
    ShipperID INTEGER,
    FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID),
    FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),
    FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID)
);
CREATE TABLE OrderDetails(
    OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT,
    OrderID INTEGER,
    ProductID INTEGER,
    Quantity INTEGER,
	FOREIGN KEY (OrderID) REFERENCES Orders (OrderID),
	FOREIGN KEY (ProductID) REFERENCES Products (ProductID)
);
 | 
| 
	simpson_episodes | 
	What is the keyword for episodes with stars score of 10 at 30% and above? | 
	stars score of 10 at 30% and above refers to stars = 10 and percent > 29 | 
	SELECT T1.keyword FROM Keyword AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 10 AND T2.percent > 29; | 
	CREATE TABLE IF NOT EXISTS "Episode"
(
    episode_id       TEXT
        constraint Episode_pk
            primary key,
    season           INTEGER,
    episode          INTEGER,
    number_in_series INTEGER,
    title            TEXT,
    summary          TEXT,
    air_date         TEXT,
    episode_image    TEXT,
    rating           REAL,
    votes            INTEGER
);
CREATE TABLE Person
(
    name          TEXT
        constraint Person_pk
            primary key,
    birthdate     TEXT,
    birth_name    TEXT,
    birth_place   TEXT,
    birth_region  TEXT,
    birth_country TEXT,
    height_meters REAL,
    nickname      TEXT
);
CREATE TABLE Award
(
    award_id       INTEGER
            primary key,
    organization   TEXT,
    year           INTEGER,
    award_category TEXT,
    award          TEXT,
    person         TEXT,
    role           TEXT,
    episode_id     TEXT,
    season         TEXT,
    song           TEXT,
    result         TEXT,
    foreign key (person) references Person(name),
    foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Character_Award
(
    award_id  INTEGER,
    character TEXT,
    foreign key (award_id) references Award(award_id)
);
CREATE TABLE Credit
(
    episode_id TEXT,
    category   TEXT,
    person     TEXT,
    role       TEXT,
    credited   TEXT,
    foreign key (episode_id) references Episode(episode_id),
    foreign key (person) references Person(name)
);
CREATE TABLE Keyword
(
    episode_id TEXT,
    keyword    TEXT,
    primary key (episode_id, keyword),
    foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Vote
(
    episode_id TEXT,
    stars      INTEGER,
    votes      INTEGER,
    percent    REAL,
    foreign key (episode_id) references Episode(episode_id)
);
 | 
| 
	movie_3 | 
	Please give the full names of all the active staff. | 
	full name refers to first_name, last_name; active staff refers to active = 1 | 
	SELECT first_name, last_name FROM staff WHERE active = 1 | 
	CREATE TABLE film_text
(
    film_id     INTEGER     not null
        primary key,
    title       TEXT not null,
    description TEXT         null
);
CREATE TABLE IF NOT EXISTS "actor"
(
    actor_id    INTEGER
        primary key autoincrement,
    first_name  TEXT                               not null,
    last_name   TEXT                               not null,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "address"
(
    address_id  INTEGER
        primary key autoincrement,
    address     TEXT                               not null,
    address2    TEXT,
    district    TEXT                               not null,
    city_id     INTEGER                            not null
        references city
            on update cascade,
    postal_code TEXT,
    phone       TEXT                               not null,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "category"
(
    category_id INTEGER
        primary key autoincrement,
    name        TEXT                               not null,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "city"
(
    city_id     INTEGER
        primary key autoincrement,
    city        TEXT                               not null,
    country_id  INTEGER                            not null
        references country
            on update cascade,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "country"
(
    country_id  INTEGER
        primary key autoincrement,
    country     TEXT                               not null,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "customer"
(
    customer_id INTEGER
        primary key autoincrement,
    store_id    INTEGER                            not null
        references store
            on update cascade,
    first_name  TEXT                               not null,
    last_name   TEXT                               not null,
    email       TEXT,
    address_id  INTEGER                            not null
        references address
            on update cascade,
    active      INTEGER  default 1                 not null,
    create_date DATETIME                           not null,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "film"
(
    film_id              INTEGER
        primary key autoincrement,
    title                TEXT                               not null,
    description          TEXT,
    release_year         TEXT,
    language_id          INTEGER                            not null
        references language
            on update cascade,
    original_language_id INTEGER
        references language
            on update cascade,
    rental_duration      INTEGER  default 3                 not null,
    rental_rate          REAL     default 4.99              not null,
    length               INTEGER,
    replacement_cost     REAL     default 19.99             not null,
    rating               TEXT     default 'G',
    special_features     TEXT,
    last_update          DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "film_actor"
(
    actor_id    INTEGER                            not null
        references actor
            on update cascade,
    film_id     INTEGER                            not null
        references film
            on update cascade,
    last_update DATETIME default CURRENT_TIMESTAMP not null,
    primary key (actor_id, film_id)
);
CREATE TABLE IF NOT EXISTS "film_category"
(
    film_id     INTEGER                            not null
        references film
            on update cascade,
    category_id INTEGER                            not null
        references category
            on update cascade,
    last_update DATETIME default CURRENT_TIMESTAMP not null,
    primary key (film_id, category_id)
);
CREATE TABLE IF NOT EXISTS "inventory"
(
    inventory_id INTEGER
        primary key autoincrement,
    film_id      INTEGER                            not null
        references film
            on update cascade,
    store_id     INTEGER                            not null
        references store
            on update cascade,
    last_update  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "language"
(
    language_id INTEGER
        primary key autoincrement,
    name        TEXT                               not null,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "payment"
(
    payment_id   INTEGER
        primary key autoincrement,
    customer_id  INTEGER                            not null
        references customer
            on update cascade,
    staff_id     INTEGER                            not null
        references staff
            on update cascade,
    rental_id    INTEGER
                                                    references rental
                                                        on update cascade on delete set null,
    amount       REAL                               not null,
    payment_date DATETIME                           not null,
    last_update  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "rental"
(
    rental_id    INTEGER
        primary key autoincrement,
    rental_date  DATETIME                           not null,
    inventory_id INTEGER                            not null
        references inventory
            on update cascade,
    customer_id  INTEGER                            not null
        references customer
            on update cascade,
    return_date  DATETIME,
    staff_id     INTEGER                            not null
        references staff
            on update cascade,
    last_update  DATETIME default CURRENT_TIMESTAMP not null,
    unique (rental_date, inventory_id, customer_id)
);
CREATE TABLE IF NOT EXISTS "staff"
(
    staff_id    INTEGER
        primary key autoincrement,
    first_name  TEXT                               not null,
    last_name   TEXT                               not null,
    address_id  INTEGER                            not null
        references address
            on update cascade,
    picture     BLOB,
    email       TEXT,
    store_id    INTEGER                            not null
        references store
            on update cascade,
    active      INTEGER  default 1                 not null,
    username    TEXT                               not null,
    password    TEXT,
    last_update DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE IF NOT EXISTS "store"
(
    store_id         INTEGER
        primary key autoincrement,
    manager_staff_id INTEGER                            not null
        unique
        references staff
            on update cascade,
    address_id       INTEGER                            not null
        references address
            on update cascade,
    last_update      DATETIME default CURRENT_TIMESTAMP not null
);
 | 
| 
	olympics | 
	What is the percentage of people whose age greater than 24 and participate in winter season? | 
	DIVIDE(COUNT(season = 'Winter' and age > 24), COUNT(person_id)) as percentage; | 
	SELECT CAST(COUNT(CASE WHEN T2.age > 24 AND T1.season = 'Winter' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.games_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id | 
	CREATE TABLE city
(
    id        INTEGER not null
            primary key,
    city_name TEXT default NULL
);
CREATE TABLE games
(
    id         INTEGER not null
            primary key,
    games_year INTEGER          default NULL,
    games_name TEXT default NULL,
    season     TEXT default NULL
);
CREATE TABLE games_city
(
    games_id INTEGER default NULL,
    city_id  INTEGER default NULL,
    foreign key (city_id) references city(id),
    foreign key (games_id) references games(id)
);
CREATE TABLE medal
(
    id         INTEGER not null
            primary key,
    medal_name TEXT default NULL
);
CREATE TABLE noc_region
(
    id          INTEGER not null
            primary key,
    noc         TEXT   default NULL,
    region_name TEXT default NULL
);
CREATE TABLE person
(
    id        INTEGER not null
        primary key,
    full_name TEXT default NULL,
    gender    TEXT  default NULL,
    height    INTEGER          default NULL,
    weight    INTEGER          default NULL
);
CREATE TABLE games_competitor
(
    id        INTEGER not null
            primary key,
    games_id  INTEGER default NULL,
    person_id INTEGER default NULL,
    age       INTEGER default NULL,
    foreign key (games_id) references games(id),
    foreign key (person_id) references person(id)
);
CREATE TABLE person_region
(
    person_id INTEGER default NULL,
    region_id INTEGER default NULL,
    foreign key (person_id) references person(id),
    foreign key (region_id) references noc_region(id)
);
CREATE TABLE sport
(
    id         INTEGER not null
            primary key,
    sport_name TEXT default NULL
);
CREATE TABLE event
(
    id         INTEGER not null
            primary key,
    sport_id   INTEGER          default NULL,
    event_name TEXT default NULL,
    foreign key (sport_id) references sport(id)
);
CREATE TABLE competitor_event
(
    event_id      INTEGER default NULL,
    competitor_id INTEGER default NULL,
    medal_id      INTEGER default NULL,
    foreign key (competitor_id) references games_competitor(id),
    foreign key (event_id) references event(id),
    foreign key (medal_id) references medal(id)
);
 | 
| 
	sales | 
	Calculate the total number of sales closed by Michel E. DeFrance? | 
	SELECT COUNT(T1.SalesID) FROM Sales AS T1 INNER JOIN Employees AS T2 ON T1.SalesPersonID = T2.EmployeeID WHERE T2.FirstName = 'Michel' AND T2.MiddleInitial = 'e' AND T2.LastName = 'DeFrance' | 
	CREATE TABLE Customers
(
    CustomerID    INTEGER         not null
        primary key,
    FirstName     TEXT not null,
    MiddleInitial TEXT null,
    LastName      TEXT not null
);
CREATE TABLE Employees
(
    EmployeeID    INTEGER         not null
        primary key,
    FirstName     TEXT not null,
    MiddleInitial TEXT null,
    LastName      TEXT not null
);
CREATE TABLE Products
(
    ProductID INTEGER            not null
        primary key,
    Name      TEXT    not null,
    Price     REAL null
);
CREATE TABLE Sales
(
    SalesID       INTEGER not null
        primary key,
    SalesPersonID INTEGER not null,
    CustomerID    INTEGER not null,
    ProductID     INTEGER not null,
    Quantity      INTEGER not null,
    foreign key (SalesPersonID) references Employees (EmployeeID)
            on update cascade on delete cascade,
        foreign key (CustomerID) references Customers (CustomerID)
            on update cascade on delete cascade,
        foreign key (ProductID) references Products (ProductID)
            on update cascade on delete cascade
);
 | |
| 
	superstore | 
	List the products that were ordered by Anne McFarland from the Western store. | 
	Anne McFarland' is the "Customer Name"; Western store refers to west_superstore; products refers to "Product Name" | 
	SELECT DISTINCT T3.`Product Name` FROM west_superstore AS T1 INNER JOIN people AS T2 ON T1.`Customer ID` = T2.`Customer ID` INNER JOIN product AS T3 ON T3.`Product ID` = T1.`Product ID` WHERE T2.`Customer Name` = 'Anne McFarland' | 
	CREATE TABLE people
(
    "Customer ID"   TEXT,
    "Customer Name" TEXT,
    Segment         TEXT,
    Country         TEXT,
    City            TEXT,
    State           TEXT,
    "Postal Code"   INTEGER,
    Region          TEXT,
    primary key ("Customer ID", Region)
);
CREATE TABLE product
(
    "Product ID"   TEXT,
    "Product Name" TEXT,
    Category       TEXT,
    "Sub-Category" TEXT,
    Region         TEXT,
    primary key ("Product ID", Region)
);
CREATE TABLE central_superstore
(
    "Row ID"      INTEGER
            primary key,
    "Order ID"    TEXT,
    "Order Date"  DATE,
    "Ship Date"   DATE,
    "Ship Mode"   TEXT,
    "Customer ID" TEXT,
    Region        TEXT,
    "Product ID"  TEXT,
    Sales         REAL,
    Quantity      INTEGER,
    Discount      REAL,
    Profit        REAL,
    foreign key ("Customer ID", Region) references people("Customer ID",Region),
    foreign key ("Product ID", Region) references product("Product ID",Region)
);
CREATE TABLE east_superstore
(
    "Row ID"      INTEGER
            primary key,
    "Order ID"    TEXT,
    "Order Date"  DATE,
    "Ship Date"   DATE,
    "Ship Mode"   TEXT,
    "Customer ID" TEXT,
    Region        TEXT,
    "Product ID"  TEXT,
    Sales         REAL,
    Quantity      INTEGER,
    Discount      REAL,
    Profit        REAL,
    foreign key ("Customer ID", Region) references people("Customer ID",Region),
    foreign key ("Product ID", Region) references product("Product ID",Region)
);
CREATE TABLE south_superstore
(
    "Row ID"      INTEGER
            primary key,
    "Order ID"    TEXT,
    "Order Date"  DATE,
    "Ship Date"   DATE,
    "Ship Mode"   TEXT,
    "Customer ID" TEXT,
    Region        TEXT,
    "Product ID"  TEXT,
    Sales         REAL,
    Quantity      INTEGER,
    Discount      REAL,
    Profit        REAL,
    foreign key ("Customer ID", Region) references people("Customer ID",Region),
    foreign key ("Product ID", Region) references product("Product ID",Region)
);
CREATE TABLE west_superstore
(
    "Row ID"      INTEGER
            primary key,
    "Order ID"    TEXT,
    "Order Date"  DATE,
    "Ship Date"   DATE,
    "Ship Mode"   TEXT,
    "Customer ID" TEXT,
    Region        TEXT,
    "Product ID"  TEXT,
    Sales         REAL,
    Quantity      INTEGER,
    Discount      REAL,
    Profit        REAL,
    foreign key ("Customer ID", Region) references people("Customer ID",Region),
    foreign key ("Product ID", Region) references product("Product ID",Region)
);
 | 
| 
	books | 
	How much time does it take to update the status of order "2398"? | 
	"2398" is the order_id; time =   Subtract(strftime('%Y', status_date), strftime('%Y', order_date)) AS "year" , Subtract(strftime('%m', status_date), strftime('%m', order_date)) AS "month", Subtract (strftime('%d', status_date), strftime('%d', order_date)) AS "day" | 
	SELECT strftime('%J', T2.status_date) - strftime('%J', T1.order_date) FROM cust_order AS T1 INNER JOIN order_history AS T2 ON T1.order_id = T2.order_id WHERE T1.order_id = 2398 | 
	CREATE TABLE address_status
(
    status_id      INTEGER
            primary key,
    address_status TEXT
);
CREATE TABLE author
(
    author_id   INTEGER
            primary key,
    author_name TEXT
);
CREATE TABLE book_language
(
    language_id   INTEGER
            primary key,
    language_code TEXT,
    language_name TEXT
);
CREATE TABLE country
(
    country_id   INTEGER
            primary key,
    country_name TEXT
);
CREATE TABLE address
(
    address_id    INTEGER
            primary key,
    street_number TEXT,
    street_name   TEXT,
    city          TEXT,
    country_id    INTEGER,
    foreign key (country_id) references country(country_id)
);
CREATE TABLE customer
(
    customer_id INTEGER
            primary key,
    first_name  TEXT,
    last_name   TEXT,
    email       TEXT
);
CREATE TABLE customer_address
(
    customer_id INTEGER,
    address_id  INTEGER,
    status_id   INTEGER,
    primary key (customer_id, address_id),
    foreign key (address_id) references address(address_id),
    foreign key (customer_id) references customer(customer_id)
);
CREATE TABLE order_status
(
    status_id    INTEGER
            primary key,
    status_value TEXT
);
CREATE TABLE publisher
(
    publisher_id   INTEGER
            primary key,
    publisher_name TEXT
);
CREATE TABLE book
(
    book_id          INTEGER
            primary key,
    title            TEXT,
    isbn13           TEXT,
    language_id      INTEGER,
    num_pages        INTEGER,
    publication_date DATE,
    publisher_id     INTEGER,
    foreign key (language_id) references book_language(language_id),
    foreign key (publisher_id) references publisher(publisher_id)
);
CREATE TABLE book_author
(
    book_id   INTEGER,
    author_id INTEGER,
    primary key (book_id, author_id),
    foreign key (author_id) references author(author_id),
    foreign key (book_id) references book(book_id)
);
CREATE TABLE shipping_method
(
    method_id   INTEGER
            primary key,
    method_name TEXT,
    cost        REAL
);
CREATE TABLE IF NOT EXISTS "cust_order"
(
    order_id           INTEGER
        primary key autoincrement,
    order_date         DATETIME,
    customer_id        INTEGER
        references customer,
    shipping_method_id INTEGER
        references shipping_method,
    dest_address_id    INTEGER
        references address
);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "order_history"
(
    history_id  INTEGER
        primary key autoincrement,
    order_id    INTEGER
        references cust_order,
    status_id   INTEGER
        references order_status,
    status_date DATETIME
);
CREATE TABLE IF NOT EXISTS "order_line"
(
    line_id  INTEGER
        primary key autoincrement,
    order_id INTEGER
        references cust_order,
    book_id  INTEGER
        references book,
    price    REAL
);
 | 
| 
	image_and_language | 
	List all the attribute classes of image ID 22. | 
	attribute classes of image ID 22 refer to ATT_CLASS where MG_ID = 22; | 
	SELECT T1.ATT_CLASS FROM ATT_CLASSES AS T1 INNER JOIN IMG_OBJ_ATT AS T2 ON T1.ATT_CLASS_ID = T2.ATT_CLASS_ID WHERE T2.IMG_ID = 22 | 
	CREATE TABLE ATT_CLASSES
(
    ATT_CLASS_ID INTEGER default 0 not null
        primary key,
    ATT_CLASS    TEXT      not null
);
CREATE TABLE OBJ_CLASSES
(
    OBJ_CLASS_ID INTEGER default 0 not null
        primary key,
    OBJ_CLASS    TEXT      not null
);
CREATE TABLE IMG_OBJ
(
    IMG_ID        INTEGER default 0 not null,
    OBJ_SAMPLE_ID INTEGER    default 0 not null,
    OBJ_CLASS_ID  INTEGER              null,
    X             INTEGER              null,
    Y             INTEGER             null,
    W             INTEGER              null,
    H             INTEGER              null,
    primary key (IMG_ID, OBJ_SAMPLE_ID),
    foreign key (OBJ_CLASS_ID) references OBJ_CLASSES (OBJ_CLASS_ID)
);
CREATE TABLE IMG_OBJ_ATT
(
    IMG_ID        INTEGER default 0 not null,
    ATT_CLASS_ID  INTEGER    default 0 not null,
    OBJ_SAMPLE_ID INTEGER    default 0 not null,
    primary key (IMG_ID, ATT_CLASS_ID, OBJ_SAMPLE_ID),
    foreign key (ATT_CLASS_ID) references ATT_CLASSES (ATT_CLASS_ID),
    foreign key (IMG_ID, OBJ_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID)
);
CREATE TABLE PRED_CLASSES
(
    PRED_CLASS_ID INTEGER default 0 not null
        primary key,
    PRED_CLASS    TEXT     not null
);
CREATE TABLE IMG_REL
(
    IMG_ID         INTEGER default 0 not null,
    PRED_CLASS_ID  INTEGER    default 0 not null,
    OBJ1_SAMPLE_ID INTEGER    default 0 not null,
    OBJ2_SAMPLE_ID INTEGER   default 0 not null,
    primary key (IMG_ID, PRED_CLASS_ID, OBJ1_SAMPLE_ID, OBJ2_SAMPLE_ID),
    foreign key (PRED_CLASS_ID) references PRED_CLASSES (PRED_CLASS_ID),
    foreign key (IMG_ID, OBJ1_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID),
    foreign key (IMG_ID, OBJ2_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID)
);
 | 
| 
	genes | 
	Among the genes with nucleic acid metabolism defects, how many of them can be found in the vacuole? | 
	SELECT COUNT(T1.GeneID) FROM Genes AS T1 INNER JOIN Classification AS T2 ON T1.GeneID = T2.GeneID WHERE T2.Localization = 'vacuole' AND T1.Phenotype = 'Nucleic acid metabolism defects' | 
	CREATE TABLE Classification
(
    GeneID       TEXT   not null
        primary key,
    Localization TEXT not null
);
CREATE TABLE Genes
(
    GeneID       TEXT   not null,
    Essential    TEXT not null,
    Class        TEXT not null,
    Complex      TEXT null,
    Phenotype    TEXT not null,
    Motif        TEXT not null,
    Chromosome   INTEGER          not null,
    Function     TEXT not null,
    Localization TEXT not null,
    foreign key (GeneID) references Classification (GeneID)
            on update cascade on delete cascade
);
CREATE TABLE Interactions
(
    GeneID1         TEXT     not null,
    GeneID2         TEXT      not null,
    Type            TEXT    not null,
    Expression_Corr REAL not null,
    primary key (GeneID1, GeneID2),
    foreign key (GeneID1) references Classification (GeneID)
            on update cascade on delete cascade,
    foreign key (GeneID2) references Classification (GeneID)
            on update cascade on delete cascade
);
 | |
| 
	shipping | 
	What is the area of the destination city of shipment No.1346? | 
	shipment no. 1346 refers to ship_id = 1346 | 
	SELECT T2.area FROM shipment AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.city_id WHERE T1.ship_id = '1346' | 
	CREATE TABLE city
(
    city_id    INTEGER
            primary key,
    city_name  TEXT,
    state      TEXT,
    population INTEGER,
    area       REAL
);
CREATE TABLE customer
(
    cust_id        INTEGER
            primary key,
    cust_name      TEXT,
    annual_revenue INTEGER,
    cust_type      TEXT,
    address        TEXT,
    city           TEXT,
    state          TEXT,
    zip            REAL,
    phone          TEXT
);
CREATE TABLE driver
(
    driver_id  INTEGER
            primary key,
    first_name TEXT,
    last_name  TEXT,
    address    TEXT,
    city       TEXT,
    state      TEXT,
    zip_code   INTEGER,
    phone      TEXT
);
CREATE TABLE truck
(
    truck_id   INTEGER
            primary key,
    make       TEXT,
    model_year INTEGER
);
CREATE TABLE shipment
(
    ship_id   INTEGER
            primary key,
    cust_id   INTEGER,
    weight    REAL,
    truck_id  INTEGER,
    driver_id INTEGER,
    city_id   INTEGER,
    ship_date TEXT,
    foreign key (cust_id) references customer(cust_id),
    foreign key (city_id) references city(city_id),
    foreign key (driver_id) references driver(driver_id),
    foreign key (truck_id) references truck(truck_id)
);
 | 
| 
	software_company | 
	Among the customers over 30, how many of them are Machine-op-inspcts? | 
	over 30 refers to age > 30; OCCUPATION = 'Machine-op-inspct'; | 
	SELECT COUNT(ID) FROM Customers WHERE OCCUPATION = 'Machine-op-inspct' AND age > 30 | 
	CREATE TABLE Demog
(
    GEOID         INTEGER
        constraint Demog_pk
            primary key,
    INHABITANTS_K REAL,
    INCOME_K      REAL,
    A_VAR1        REAL,
    A_VAR2        REAL,
    A_VAR3        REAL,
    A_VAR4        REAL,
    A_VAR5        REAL,
    A_VAR6        REAL,
    A_VAR7        REAL,
    A_VAR8        REAL,
    A_VAR9        REAL,
    A_VAR10       REAL,
    A_VAR11       REAL,
    A_VAR12       REAL,
    A_VAR13       REAL,
    A_VAR14       REAL,
    A_VAR15       REAL,
    A_VAR16       REAL,
    A_VAR17       REAL,
    A_VAR18       REAL
);
CREATE TABLE mailings3
(
    REFID    INTEGER
        constraint mailings3_pk
            primary key,
    REF_DATE DATETIME,
    RESPONSE TEXT
);
CREATE TABLE IF NOT EXISTS "Customers"
(
    ID             INTEGER
        constraint Customers_pk
            primary key,
    SEX            TEXT,
    MARITAL_STATUS TEXT,
    GEOID          INTEGER
        constraint Customers_Demog_GEOID_fk
            references Demog,
    EDUCATIONNUM   INTEGER,
    OCCUPATION     TEXT,
    age            INTEGER
);
CREATE TABLE IF NOT EXISTS "Mailings1_2"
(
    REFID    INTEGER
        constraint Mailings1_2_pk
            primary key
        constraint Mailings1_2_Customers_ID_fk
            references Customers,
    REF_DATE DATETIME,
    RESPONSE TEXT
);
CREATE TABLE IF NOT EXISTS "Sales"
(
    EVENTID    INTEGER
        constraint Sales_pk
            primary key,
    REFID      INTEGER
        references Customers,
    EVENT_DATE DATETIME,
    AMOUNT     REAL
);
 | 
| 
	computer_student | 
	Please list the IDs of the advisors of the students who are in the 5th year of their program. | 
	IDs of the advisors refers to p_id_dummy; in the 5th year of their program refers to yearsInProgram = 'Year_5' | 
	SELECT T1.p_id_dummy FROM advisedBy AS T1 INNER JOIN person AS T2 ON T1.p_id = T2.p_id WHERE T2.yearsInProgram = 'Year_5' | 
	CREATE TABLE course
(
    course_id   INTEGER
        constraint course_pk
            primary key,
    courseLevel TEXT
);
CREATE TABLE person
(
    p_id           INTEGER
        constraint person_pk
            primary key,
    professor      INTEGER,
    student        INTEGER,
    hasPosition    TEXT,
    inPhase        TEXT,
    yearsInProgram TEXT
);
CREATE TABLE IF NOT EXISTS "advisedBy"
(
    p_id       INTEGER,
    p_id_dummy INTEGER,
    constraint advisedBy_pk
        primary key (p_id, p_id_dummy),
    constraint advisedBy_person_p_id_p_id_fk
        foreign key (p_id, p_id_dummy) references person (p_id, p_id)
);
CREATE TABLE taughtBy
(
    course_id INTEGER,
    p_id      INTEGER,
    primary key (course_id, p_id),
    foreign key (p_id) references person(p_id),
    foreign key (course_id) references course(course_id)
);
 | 
| 
	student_loan | 
	List 10 students that have no due payments and are not males. | 
	no due payments refers to bool = 'neg'; not males refers to not in male table | 
	SELECT T1.name FROM no_payment_due AS T1 INNER JOIN person AS T2 ON T1.`name` = T2.`name` WHERE T2.`name` NOT IN ( SELECT name FROM male ) AND T1.bool = 'neg' | 
	CREATE TABLE bool
(
    "name" TEXT default '' not null
        primary key
);
CREATE TABLE person
(
    "name" TEXT default '' not null
        primary key
);
CREATE TABLE disabled
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE enlist
(
    "name"  TEXT not null,
    organ TEXT not null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE filed_for_bankrupcy
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE longest_absense_from_school
(
    "name"  TEXT default '' not null
        primary key,
    "month" INTEGER       default 0  null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE male
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE no_payment_due
(
    "name" TEXT default '' not null
        primary key,
    bool TEXT             null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade,
        foreign key (bool) references bool ("name")
            on update cascade on delete cascade
);
CREATE TABLE unemployed
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE `enrolled` (
  `name` TEXT NOT NULL,
  `school` TEXT NOT NULL,
  `month` INTEGER NOT NULL DEFAULT 0,
  PRIMARY KEY (`name`,`school`),
  FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
);
 | 
| 
	image_and_language | 
	How many attribute classes are there for image id 5? | 
	attribute classes refer to ATT_CLASS_ID; image id 5 refers to IMG_ID = 5; | 
	SELECT COUNT(ATT_CLASS_ID) FROM IMG_OBJ_ATT WHERE IMG_ID = 5 | 
	CREATE TABLE ATT_CLASSES
(
    ATT_CLASS_ID INTEGER default 0 not null
        primary key,
    ATT_CLASS    TEXT      not null
);
CREATE TABLE OBJ_CLASSES
(
    OBJ_CLASS_ID INTEGER default 0 not null
        primary key,
    OBJ_CLASS    TEXT      not null
);
CREATE TABLE IMG_OBJ
(
    IMG_ID        INTEGER default 0 not null,
    OBJ_SAMPLE_ID INTEGER    default 0 not null,
    OBJ_CLASS_ID  INTEGER              null,
    X             INTEGER              null,
    Y             INTEGER             null,
    W             INTEGER              null,
    H             INTEGER              null,
    primary key (IMG_ID, OBJ_SAMPLE_ID),
    foreign key (OBJ_CLASS_ID) references OBJ_CLASSES (OBJ_CLASS_ID)
);
CREATE TABLE IMG_OBJ_ATT
(
    IMG_ID        INTEGER default 0 not null,
    ATT_CLASS_ID  INTEGER    default 0 not null,
    OBJ_SAMPLE_ID INTEGER    default 0 not null,
    primary key (IMG_ID, ATT_CLASS_ID, OBJ_SAMPLE_ID),
    foreign key (ATT_CLASS_ID) references ATT_CLASSES (ATT_CLASS_ID),
    foreign key (IMG_ID, OBJ_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID)
);
CREATE TABLE PRED_CLASSES
(
    PRED_CLASS_ID INTEGER default 0 not null
        primary key,
    PRED_CLASS    TEXT     not null
);
CREATE TABLE IMG_REL
(
    IMG_ID         INTEGER default 0 not null,
    PRED_CLASS_ID  INTEGER    default 0 not null,
    OBJ1_SAMPLE_ID INTEGER    default 0 not null,
    OBJ2_SAMPLE_ID INTEGER   default 0 not null,
    primary key (IMG_ID, PRED_CLASS_ID, OBJ1_SAMPLE_ID, OBJ2_SAMPLE_ID),
    foreign key (PRED_CLASS_ID) references PRED_CLASSES (PRED_CLASS_ID),
    foreign key (IMG_ID, OBJ1_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID),
    foreign key (IMG_ID, OBJ2_SAMPLE_ID) references IMG_OBJ (IMG_ID, OBJ_SAMPLE_ID)
);
 | 
| 
	music_tracker | 
	Provide the name of artists who had no more than 100 downloads and are tagged "funk" in 1980. | 
	no more than 100 downloads refer to totalSnatched ≤ 100; groupYear = 1980; tag = 'funk'; | 
	SELECT T1.artist FROM torrents AS T1 INNER JOIN tags AS T2 ON T1.id = T2.id WHERE T2.tag = 'funk' AND T1.groupYear = 1980 AND T1.totalSnatched <= 100 | 
	CREATE TABLE IF NOT EXISTS "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
);
CREATE TABLE IF NOT EXISTS "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
);
CREATE INDEX ix_tags_index
    on tags ("index");
 | 
| 
	cookbook | 
	How many calories does the turkey tenderloin bundles recipe have? | 
	turkey tenderloin refers to title | 
	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' | 
	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)
);
 | 
| 
	cars | 
	List the name of the cars with model year 1975. | 
	name of the car refers to car_name; model year 1975 refers to model_year = 1975 | 
	SELECT T1.car_name FROM data AS T1 INNER JOIN production AS T2 ON T1.ID = T2.ID WHERE T2.model_year = 1975 | 
	CREATE TABLE country
(
    origin  INTEGER
            primary key,
    country TEXT
);
CREATE TABLE price
(
    ID    INTEGER
            primary key,
    price REAL
);
CREATE TABLE data
(
    ID           INTEGER
            primary key,
    mpg          REAL,
    cylinders    INTEGER,
    displacement REAL,
    horsepower   INTEGER,
    weight       INTEGER,
    acceleration REAL,
    model        INTEGER,
    car_name     TEXT,
    foreign key (ID) references price(ID)
);
CREATE TABLE production
(
    ID         INTEGER,
    model_year INTEGER,
    country    INTEGER,
    primary key (ID, model_year),
    foreign key (country) references country(origin),
    foreign key (ID) references data(ID),
    foreign key (ID) references price(ID)
);
 | 
| 
	european_football_1 | 
	For a game had a score of 1-8 in the year of 2011, what division was that game in? Give the full name of the division. | 
	2011 refers to season; a score of 1-8 refers to FTHG = '1' and FTAG = '8'; | 
	SELECT T2.division, T2.name FROM matchs AS T1 INNER JOIN divisions AS T2 ON T1.Div = T2.division WHERE T1.season = 2011 AND T1.FTHG = 1 AND T1.FTAG = 8 | 
	CREATE TABLE divisions
(
    division TEXT not null
        primary key,
    name     TEXT,
    country  TEXT
);
CREATE TABLE matchs
(
    Div      TEXT,
    Date     DATE,
    HomeTeam TEXT,
    AwayTeam TEXT,
    FTHG     INTEGER,
    FTAG     INTEGER,
    FTR      TEXT,
    season   INTEGER,
    foreign key (Div) references divisions(division)
);
 | 
| 
	ice_hockey_draft | 
	Who is the youngest player to have played during the 1997-1998 season for OHL League? | 
	youngest player refers to MAX(birthdate); 1997-1998 season refers to SEASON = '1997-1998'; OHL league refers to LEAGUE = 'OHL'; | 
	SELECT DISTINCT T2.PlayerName FROM SeasonStatus AS T1 INNER JOIN PlayerInfo AS T2 ON T1.ELITEID = T2.ELITEID WHERE T1.SEASON = '1997-1998' AND T1.LEAGUE = 'OHL' ORDER BY T2.birthdate DESC LIMIT 1 | 
	CREATE TABLE height_info
(
    height_id      INTEGER
            primary key,
    height_in_cm   INTEGER,
    height_in_inch TEXT
);
CREATE TABLE weight_info
(
    weight_id     INTEGER
            primary key,
    weight_in_kg  INTEGER,
    weight_in_lbs INTEGER
);
CREATE TABLE PlayerInfo
(
    ELITEID           INTEGER
            primary key,
    PlayerName        TEXT,
    birthdate         TEXT,
    birthyear         DATE,
    birthmonth        INTEGER,
    birthday          INTEGER,
    birthplace        TEXT,
    nation            TEXT,
    height            INTEGER,
    weight            INTEGER,
    position_info     TEXT,
    shoots            TEXT,
    draftyear         INTEGER,
    draftround        INTEGER,
    overall           INTEGER,
    overallby         TEXT,
    CSS_rank          INTEGER,
    sum_7yr_GP        INTEGER,
    sum_7yr_TOI       INTEGER,
    GP_greater_than_0 TEXT,
    foreign key (height) references height_info(height_id),
    foreign key (weight) references weight_info(weight_id)
);
CREATE TABLE SeasonStatus
(
    ELITEID   INTEGER,
    SEASON    TEXT,
    TEAM      TEXT,
    LEAGUE    TEXT,
    GAMETYPE  TEXT,
    GP        INTEGER,
    G         INTEGER,
    A         INTEGER,
    P         INTEGER,
    PIM       INTEGER,
    PLUSMINUS INTEGER,
    foreign key (ELITEID) references PlayerInfo(ELITEID)
);
 | 
| 
	soccer_2016 | 
	List the name of all New Zealand umpires. | 
	New Zealand umpires refers to Country_Name = 'New Zealand'; name of umpires refers to Umpire_Name | 
	SELECT T1.Umpire_Name FROM Umpire AS T1 INNER JOIN Country AS T2 ON T1.Umpire_Country = T2.Country_Id WHERE T2.Country_Name = 'New Zealand' | 
	CREATE TABLE Batting_Style
(
    Batting_Id   INTEGER
            primary key,
    Batting_hand TEXT
);
CREATE TABLE Bowling_Style
(
    Bowling_Id    INTEGER
            primary key,
    Bowling_skill TEXT
);
CREATE TABLE City
(
    City_Id    INTEGER
            primary key,
    City_Name  TEXT,
    Country_id INTEGER
);
CREATE TABLE Country
(
    Country_Id   INTEGER
            primary key,
    Country_Name TEXT,
    foreign key (Country_Id) references Country(Country_Id)
);
CREATE TABLE Extra_Type
(
    Extra_Id   INTEGER
            primary key,
    Extra_Name TEXT
);
CREATE TABLE Extra_Runs
(
    Match_Id      INTEGER,
    Over_Id       INTEGER,
    Ball_Id       INTEGER,
    Extra_Type_Id INTEGER,
    Extra_Runs    INTEGER,
    Innings_No    INTEGER,
    primary key (Match_Id, Over_Id, Ball_Id, Innings_No),
    foreign key (Extra_Type_Id) references Extra_Type(Extra_Id)
);
CREATE TABLE Out_Type
(
    Out_Id   INTEGER
            primary key,
    Out_Name TEXT
);
CREATE TABLE Outcome
(
    Outcome_Id   INTEGER
            primary key,
    Outcome_Type TEXT
);
CREATE TABLE Player
(
    Player_Id     INTEGER
            primary key,
    Player_Name   TEXT,
    DOB           DATE,
    Batting_hand  INTEGER,
    Bowling_skill INTEGER,
    Country_Name  INTEGER,
    foreign key (Batting_hand) references Batting_Style(Batting_Id),
    foreign key (Bowling_skill) references Bowling_Style(Bowling_Id),
    foreign key (Country_Name) references Country(Country_Id)
);
CREATE TABLE Rolee
(
    Role_Id   INTEGER
            primary key,
    Role_Desc TEXT
);
CREATE TABLE Season
(
    Season_Id         INTEGER
            primary key,
    Man_of_the_Series INTEGER,
    Orange_Cap        INTEGER,
    Purple_Cap        INTEGER,
    Season_Year       INTEGER
);
CREATE TABLE Team
(
    Team_Id   INTEGER
            primary key,
    Team_Name TEXT
);
CREATE TABLE Toss_Decision
(
    Toss_Id   INTEGER
            primary key,
    Toss_Name TEXT
);
CREATE TABLE Umpire
(
    Umpire_Id      INTEGER
            primary key,
    Umpire_Name    TEXT,
    Umpire_Country INTEGER,
    foreign key (Umpire_Country) references Country(Country_Id)
);
CREATE TABLE Venue
(
    Venue_Id   INTEGER
            primary key,
    Venue_Name TEXT,
    City_Id    INTEGER,
    foreign key (City_Id) references City(City_Id)
);
CREATE TABLE Win_By
(
    Win_Id   INTEGER
            primary key,
    Win_Type TEXT
);
CREATE TABLE Match
(
    Match_Id         INTEGER
            primary key,
    Team_1           INTEGER,
    Team_2           INTEGER,
    Match_Date       DATE,
    Season_Id        INTEGER,
    Venue_Id         INTEGER,
    Toss_Winner      INTEGER,
    Toss_Decide      INTEGER,
    Win_Type         INTEGER,
    Win_Margin       INTEGER,
    Outcome_type     INTEGER,
    Match_Winner     INTEGER,
    Man_of_the_Match INTEGER,
    foreign key (Team_1) references Team(Team_Id),
    foreign key (Team_2) references Team(Team_Id),
    foreign key (Season_Id) references Season(Season_Id),
    foreign key (Venue_Id) references Venue(Venue_Id),
    foreign key (Toss_Winner) references Team(Team_Id),
    foreign key (Toss_Decide) references Toss_Decision(Toss_Id),
    foreign key (Win_Type) references Win_By(Win_Id),
    foreign key (Outcome_type) references Out_Type(Out_Id),
    foreign key (Match_Winner) references Team(Team_Id),
    foreign key (Man_of_the_Match) references Player(Player_Id)
);
CREATE TABLE Ball_by_Ball
(
    Match_Id                 INTEGER,
    Over_Id                  INTEGER,
    Ball_Id                  INTEGER,
    Innings_No               INTEGER,
    Team_Batting             INTEGER,
    Team_Bowling             INTEGER,
    Striker_Batting_Position INTEGER,
    Striker                  INTEGER,
    Non_Striker              INTEGER,
    Bowler                   INTEGER,
    primary key (Match_Id, Over_Id, Ball_Id, Innings_No),
    foreign key (Match_Id) references Match(Match_Id)
);
CREATE TABLE Batsman_Scored
(
    Match_Id    INTEGER,
    Over_Id     INTEGER,
    Ball_Id     INTEGER,
    Runs_Scored INTEGER,
    Innings_No  INTEGER,
    primary key (Match_Id, Over_Id, Ball_Id, Innings_No),
    foreign key (Match_Id) references Match(Match_Id)
);
CREATE TABLE Player_Match
(
    Match_Id  INTEGER,
    Player_Id INTEGER,
    Role_Id   INTEGER,
    Team_Id   INTEGER,
    primary key (Match_Id, Player_Id, Role_Id),
    foreign key (Match_Id) references Match(Match_Id),
    foreign key (Player_Id) references Player(Player_Id),
    foreign key (Team_Id) references Team(Team_Id),
    foreign key (Role_Id) references Rolee(Role_Id)
);
CREATE TABLE Wicket_Taken
(
    Match_Id   INTEGER,
    Over_Id    INTEGER,
    Ball_Id    INTEGER,
    Player_Out INTEGER,
    Kind_Out   INTEGER,
    Fielders   INTEGER,
    Innings_No INTEGER,
    primary key (Match_Id, Over_Id, Ball_Id, Innings_No),
    foreign key (Match_Id) references Match(Match_Id),
    foreign key (Player_Out) references Player(Player_Id),
    foreign key (Kind_Out) references Out_Type(Out_Id),
    foreign key (Fielders) references Player(Player_Id)
);
 | 
| 
	social_media | 
	What is the percentage of male Twitter users from Florida? | 
	"Florida" is the State; male user refers to Gender = 'Male'; percentage = Divide (Count(UserID where Gender = 'Male'), Count (UserID)) * 100 | 
	SELECT SUM(CASE WHEN T3.Gender = 'Male' THEN 1.0 ELSE 0 END) / COUNT(T1.TweetID) AS percentage FROM twitter AS T1 INNER JOIN location AS T2 ON T2.LocationID = T1.LocationID INNER JOIN user AS T3 ON T3.UserID = T1.UserID WHERE T2.State = 'Florida' | 
	CREATE TABLE location
(
    LocationID INTEGER
        constraint location_pk
            primary key,
    Country    TEXT,
    State      TEXT,
    StateCode  TEXT,
    City       TEXT
);
CREATE TABLE user
(
    UserID TEXT
        constraint user_pk
            primary key,
    Gender TEXT
);
CREATE TABLE twitter
(
    TweetID         TEXT
            primary key,
    Weekday         TEXT,
    Hour         INTEGER,
    Day          INTEGER,
    Lang         TEXT,
    IsReshare    TEXT,
    Reach        INTEGER,
    RetweetCount INTEGER,
    Likes        INTEGER,
    Klout        INTEGER,
    Sentiment    REAL,
    "text"         TEXT,
    LocationID   INTEGER,
    UserID       TEXT,
    foreign key (LocationID) references location(LocationID),
    foreign key (UserID) references user(UserID)
);
 | 
| 
	music_tracker | 
	How many albums and Single-Tables were released by the artist named '50 cent' between 2010 and 2015? | 
	albums refer to releaseType = 'album'; releaseType = 'single'; between 2010 and 2015 refers to groupYear between 2010 and 2015; | 
	SELECT COUNT(id), ( SELECT COUNT(id) FROM torrents WHERE groupYear BETWEEN 2010 AND 2015 AND artist LIKE '50 cent' AND releaseType LIKE 'album' ) FROM torrents WHERE groupYear BETWEEN 2010 AND 2015 AND artist LIKE '50 cent' AND releaseType LIKE 'Single' | 
	CREATE TABLE IF NOT EXISTS "torrents"
(
    groupName     TEXT,
    totalSnatched INTEGER,
    artist        TEXT,
    groupYear     INTEGER,
    releaseType   TEXT,
    groupId       INTEGER,
    id            INTEGER
        constraint torrents_pk
            primary key
);
CREATE TABLE IF NOT EXISTS "tags"
(
    "index" INTEGER
        constraint tags_pk
            primary key,
    id      INTEGER
        constraint tags_torrents_id_fk
            references torrents,
    tag     TEXT
);
CREATE INDEX ix_tags_index
    on tags ("index");
 | 
| 
	world_development_indicators | 
	How many of the countries name start with alphabet A? List down the Alpha2Code of them. | 
	countries name starts with alphabet A refers to shortname like 'A%'; | 
	SELECT COUNT(ShortName) FROM Country WHERE ShortName LIKE 'A%' UNION SELECT alpha2code FROM country WHERE shortname LIKE 'A%' | 
	CREATE TABLE IF NOT EXISTS "Country"
(
    CountryCode                                TEXT not null
        primary key,
    ShortName                                  TEXT,
    TableName                                  TEXT,
    LongName                                   TEXT,
    Alpha2Code                                 TEXT,
    CurrencyUnit                               TEXT,
    SpecialNotes                               TEXT,
    Region                                     TEXT,
    IncomeGroup                                TEXT,
    Wb2Code                                    TEXT,
    NationalAccountsBaseYear                   TEXT,
    NationalAccountsReferenceYear              TEXT,
    SnaPriceValuation                          TEXT,
    LendingCategory                            TEXT,
    OtherGroups                                TEXT,
    SystemOfNationalAccounts                   TEXT,
    AlternativeConversionFactor                TEXT,
    PppSurveyYear                              TEXT,
    BalanceOfPaymentsManualInUse               TEXT,
    ExternalDebtReportingStatus                TEXT,
    SystemOfTrade                              TEXT,
    GovernmentAccountingConcept                TEXT,
    ImfDataDisseminationStandard               TEXT,
    LatestPopulationCensus                     TEXT,
    LatestHouseholdSurvey                      TEXT,
    SourceOfMostRecentIncomeAndExpenditureData TEXT,
    VitalRegistrationComplete                  TEXT,
    LatestAgriculturalCensus                   TEXT,
    LatestIndustrialData                       INTEGER,
    LatestTradeData                            INTEGER,
    LatestWaterWithdrawalData                  INTEGER
);
CREATE TABLE IF NOT EXISTS "Series"
(
    SeriesCode                       TEXT not null
        primary key,
    Topic                            TEXT,
    IndicatorName                    TEXT,
    ShortDefinition                  TEXT,
    LongDefinition                   TEXT,
    UnitOfMeasure                    TEXT,
    Periodicity                      TEXT,
    BasePeriod                       TEXT,
    OtherNotes                       INTEGER,
    AggregationMethod                TEXT,
    LimitationsAndExceptions         TEXT,
    NotesFromOriginalSource          TEXT,
    GeneralComments                  TEXT,
    Source                           TEXT,
    StatisticalConceptAndMethodology TEXT,
    DevelopmentRelevance             TEXT,
    RelatedSourceLinks               TEXT,
    OtherWebLinks                    INTEGER,
    RelatedIndicators                INTEGER,
    LicenseType                      TEXT
);
CREATE TABLE CountryNotes
(
    Countrycode TEXT NOT NULL ,
    Seriescode  TEXT NOT NULL ,
    Description TEXT,
    primary key (Countrycode, Seriescode),
    FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode),
    FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode)
);
CREATE TABLE Footnotes
(
    Countrycode TEXT NOT NULL ,
    Seriescode  TEXT NOT NULL ,
    Year        TEXT,
    Description TEXT,
    primary key (Countrycode, Seriescode, Year),
    FOREIGN KEY (Seriescode) REFERENCES Series(SeriesCode),
    FOREIGN KEY (Countrycode) REFERENCES Country(CountryCode)
);
CREATE TABLE Indicators
(
    CountryName   TEXT,
    CountryCode   TEXT NOT NULL ,
    IndicatorName TEXT,
    IndicatorCode TEXT NOT NULL ,
    Year          INTEGER NOT NULL ,
    Value         INTEGER,
    primary key (CountryCode, IndicatorCode, Year),
    FOREIGN KEY (CountryCode) REFERENCES Country(CountryCode)
);
CREATE TABLE SeriesNotes
(
    Seriescode  TEXT not null ,
    Year        TEXT not null ,
    Description TEXT,
    primary key (Seriescode, Year),
    foreign key (Seriescode) references Series(SeriesCode)
);
 | 
| 
	airline | 
	For the flight from ATL to PHL on 2018/8/1 that scheduled local departure time as "2040", which air carrier does this flight belong to? | 
	flight from ATL refers to ORIGIN = 'ATL'; flight to PHL refers to DEST = 'PHL'; on 2018/8/1 refers to FL_DATE = '2018/8/1'; local departure time refers to CRS_DEP_TIME; CRS_DEP_TIME = '2040'; | 
	SELECT T2.Description FROM Airlines AS T1 INNER JOIN `Air Carriers` AS T2 ON T1.OP_CARRIER_AIRLINE_ID = T2.Code WHERE T1.FL_DATE = '2018/8/1' AND T1.ORIGIN = 'ATL' AND T1.DEST = 'PHL' AND T1.CRS_DEP_TIME = '2040' GROUP BY T2.Description | 
	CREATE TABLE IF NOT EXISTS "Air Carriers"
(
    Code        INTEGER
            primary key,
    Description TEXT
);
CREATE TABLE Airports
(
    Code        TEXT
            primary key,
    Description TEXT
);
CREATE TABLE Airlines
(
    FL_DATE               TEXT,
    OP_CARRIER_AIRLINE_ID INTEGER,
    TAIL_NUM              TEXT,
    OP_CARRIER_FL_NUM     INTEGER,
    ORIGIN_AIRPORT_ID     INTEGER,
    ORIGIN_AIRPORT_SEQ_ID INTEGER,
    ORIGIN_CITY_MARKET_ID INTEGER,
    ORIGIN                TEXT,
    DEST_AIRPORT_ID       INTEGER,
    DEST_AIRPORT_SEQ_ID   INTEGER,
    DEST_CITY_MARKET_ID   INTEGER,
    DEST                  TEXT,
    CRS_DEP_TIME          INTEGER,
    DEP_TIME              INTEGER,
    DEP_DELAY             INTEGER,
    DEP_DELAY_NEW         INTEGER,
    ARR_TIME              INTEGER,
    ARR_DELAY             INTEGER,
    ARR_DELAY_NEW         INTEGER,
    CANCELLED             INTEGER,
    CANCELLATION_CODE     TEXT,
    CRS_ELAPSED_TIME      INTEGER,
    ACTUAL_ELAPSED_TIME   INTEGER,
    CARRIER_DELAY         INTEGER,
    WEATHER_DELAY         INTEGER,
    NAS_DELAY             INTEGER,
    SECURITY_DELAY        INTEGER,
    LATE_AIRCRAFT_DELAY   INTEGER,
    FOREIGN KEY (ORIGIN) REFERENCES Airports(Code),
    FOREIGN KEY (DEST) REFERENCES Airports(Code),
    FOREIGN KEY (OP_CARRIER_AIRLINE_ID) REFERENCES "Air Carriers"(Code)
);
 | 
| 
	sales_in_weather | 
	What is the ID of the item that sold the best on 2012/1/1 in store no.1? | 
	sold on 2012/1/1 refers to date = '2012-01-01'; in store no.1 refers to store_nbr = 1; item sold the best refers to Max(units) | 
	SELECT item_nbr FROM sales_in_weather WHERE `date` = '2012-01-01' AND store_nbr = 1 ORDER BY units DESC LIMIT 1 | 
	CREATE TABLE sales_in_weather
(
    date      DATE,
    store_nbr INTEGER,
    item_nbr  INTEGER,
    units     INTEGER,
    primary key (store_nbr, date, item_nbr)
);
CREATE TABLE weather
(
    station_nbr INTEGER,
    date        DATE,
    tmax        INTEGER,
    tmin        INTEGER,
    tavg        INTEGER,
    depart      INTEGER,
    dewpoint    INTEGER,
    wetbulb     INTEGER,
    heat        INTEGER,
    cool        INTEGER,
    sunrise     TEXT,
    sunset      TEXT,
    codesum     TEXT,
    snowfall    REAL,
    preciptotal REAL,
    stnpressure REAL,
    sealevel    REAL,
    resultspeed REAL,
    resultdir   INTEGER,
    avgspeed    REAL,
    primary key (station_nbr, date)
);
CREATE TABLE relation
(
    store_nbr   INTEGER
            primary key,
    station_nbr INTEGER,
    foreign key (store_nbr) references sales_in_weather(store_nbr),
    foreign key (station_nbr) references weather(station_nbr)
);
 | 
| 
	car_retails | 
	List out full name of employees who are working in Boston? | 
	full name = contactFirstName, contactLastName; Boston is a city; | 
	SELECT T1.firstName, T1.lastName FROM employees AS T1 INNER JOIN offices AS T2 ON T1.officeCode = T2.officeCode WHERE T2.city = 'Boston' | 
	CREATE TABLE offices
(
    officeCode   TEXT not null
        primary key,
    city         TEXT not null,
    phone        TEXT not null,
    addressLine1 TEXT not null,
    addressLine2 TEXT,
    state        TEXT,
    country      TEXT not null,
    postalCode  TEXT not null,
    territory    TEXT not null
);
CREATE TABLE employees
(
    employeeNumber INTEGER      not null
        primary key,
    lastName       TEXT  not null,
    firstName      TEXT  not null,
    extension      TEXT  not null,
    email          TEXT not null,
    officeCode     TEXT  not null,
    reportsTo      INTEGER,
    jobTitle       TEXT  not null,
    foreign key (officeCode) references offices(officeCode),
    foreign key (reportsTo) references employees(employeeNumber)
);
CREATE TABLE customers
(
    customerNumber         INTEGER     not null
        primary key,
    customerName           TEXT not null,
    contactLastName        TEXT not null,
    contactFirstName       TEXT not null,
    phone                  TEXT not null,
    addressLine1           TEXT not null,
    addressLine2           TEXT,
    city                   TEXT not null,
    state                  TEXT,
    postalCode             TEXT,
    country                TEXT not null,
    salesRepEmployeeNumber INTEGER,
    creditLimit            REAL,
    foreign key (salesRepEmployeeNumber) references employees(employeeNumber)
);
CREATE TABLE orders
(
    orderNumber    INTEGER     not null
        primary key,
    orderDate      DATE        not null,
    requiredDate   DATE        not null,
    shippedDate    DATE,
    status         TEXT not null,
    comments       TEXT,
    customerNumber INTEGER     not null,
    foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE payments
(
    customerNumber INTEGER     not null,
    checkNumber    TEXT not null,
    paymentDate    DATE        not null,
    amount         REAL        not null,
    primary key (customerNumber, checkNumber),
    foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE productlines
(
    productLine     TEXT not null
        primary key,
    textDescription TEXT,
    htmlDescription TEXT,
    image           BLOB
);
CREATE TABLE products
(
    productCode        TEXT not null
        primary key,
    productName        TEXT not null,
    productLine        TEXT not null,
    productScale      TEXT not null,
    productVendor      TEXT not null,
    productDescription TEXT        not null,
    quantityInStock    INTEGER     not null,
    buyPrice           REAL        not null,
    MSRP               REAL        not null,
    foreign key (productLine) references productlines(productLine)
);
CREATE TABLE IF NOT EXISTS "orderdetails"
(
    orderNumber     INTEGER not null
        references orders,
    productCode     TEXT    not null
        references products,
    quantityOrdered INTEGER not null,
    priceEach       REAL    not null,
    orderLineNumber INTEGER not null,
    primary key (orderNumber, productCode)
);
 | 
| 
	app_store | 
	What are the top 5 installed free apps? | 
	free app refers to price = 0; most installed app refers to MAX(Installs); | 
	SELECT App FROM playstore WHERE Price = 0 ORDER BY CAST(REPLACE(REPLACE(Installs, ',', ''), '+', '') AS INTEGER) DESC LIMIT 5 | 
	CREATE TABLE IF NOT EXISTS "playstore"
(
    App              TEXT,
    Category         TEXT,
    Rating           REAL,
    Reviews          INTEGER,
    Size             TEXT,
    Installs         TEXT,
    Type             TEXT,
    Price            TEXT,
    "Content Rating" TEXT,
    Genres           TEXT
);
CREATE TABLE IF NOT EXISTS "user_reviews"
(
    App                    TEXT
        references "playstore" (App),
    Translated_Review      TEXT,
    Sentiment              TEXT,
    Sentiment_Polarity     TEXT,
    Sentiment_Subjectivity TEXT
);
 | 
| 
	donor | 
	From which state do the 5 biggest donor, who gave the highest cost of optional support, come from? List their donor_acctid and calculate for their average cost of optional support for every donations they make and identtify the project's type of resource to which they gave the hightest optional support. | 
	which state refers to school_state; highest cost of optional support refers to max(donation_optional_support); average cost of optional support = avg(donation_optional_support) | 
	SELECT T1.school_state, T2.donor_acctid, AVG(T2.donation_optional_support), T1.resource_type FROM projects AS T1 INNER JOIN donations AS T2 ON T1.projectid = T2.projectid ORDER BY T2.donation_optional_support DESC LIMIT 5 | 
	CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "essays"
(
    projectid         TEXT,
    teacher_acctid    TEXT,
    title             TEXT,
    short_description TEXT,
    need_statement    TEXT,
    essay             TEXT
);
CREATE TABLE IF NOT EXISTS "projects"
(
    projectid                              TEXT not null
        primary key,
    teacher_acctid                         TEXT,
    schoolid                               TEXT,
    school_ncesid                          TEXT,
    school_latitude                        REAL,
    school_longitude                       REAL,
    school_city                            TEXT,
    school_state                           TEXT,
    school_zip                             INTEGER,
    school_metro                           TEXT,
    school_district                        TEXT,
    school_county                          TEXT,
    school_charter                         TEXT,
    school_magnet                          TEXT,
    school_year_round                      TEXT,
    school_nlns                            TEXT,
    school_kipp                            TEXT,
    school_charter_ready_promise           TEXT,
    teacher_prefix                         TEXT,
    teacher_teach_for_america              TEXT,
    teacher_ny_teaching_fellow             TEXT,
    primary_focus_subject                  TEXT,
    primary_focus_area                     TEXT,
    secondary_focus_subject                TEXT,
    secondary_focus_area                   TEXT,
    resource_type                          TEXT,
    poverty_level                          TEXT,
    grade_level                            TEXT,
    fulfillment_labor_materials            REAL,
    total_price_excluding_optional_support REAL,
    total_price_including_optional_support REAL,
    students_reached                       INTEGER,
    eligible_double_your_impact_match      TEXT,
    eligible_almost_home_match             TEXT,
    date_posted                            DATE
);
CREATE TABLE donations
(
    donationid                               TEXT not null
            primary key,
    projectid                               TEXT,
    donor_acctid                             TEXT,
    donor_city                               TEXT,
    donor_state                              TEXT,
    donor_zip                                TEXT,
    is_teacher_acct                          TEXT,
    donation_timestamp                       DATETIME,
    donation_to_project                      REAL,
    donation_optional_support                REAL,
    donation_total                           REAL,
    dollar_amount                            TEXT,
    donation_included_optional_support       TEXT,
    payment_method                           TEXT,
    payment_included_acct_credit             TEXT,
    payment_included_campaign_gift_card      TEXT,
    payment_included_web_purchased_gift_card TEXT,
    payment_was_promo_matched                TEXT,
    via_giving_page                          TEXT,
    for_honoree                              TEXT,
    donation_message                         TEXT,
    foreign key (projectid) references projects(projectid)
);
CREATE TABLE resources
(
    resourceid            TEXT not null
            primary key,
    projectid             TEXT,
    vendorid              INTEGER,
    vendor_name           TEXT,
    project_resource_type TEXT,
    item_name             TEXT,
    item_number           TEXT,
    item_unit_price       REAL,
    item_quantity         INTEGER,
    foreign key (projectid) references projects(projectid)
);
 | 
| 
	retails | 
	List the 5 orders with the highest total price, indicating the delivery date. | 
	order refers to o_orderkey; the highest total price refers to max(o_totalprice); delivery date refers to l_shipdate | 
	SELECT T1.o_orderkey, T2.l_shipdate FROM orders AS T1 INNER JOIN lineitem AS T2 ON T1.o_orderkey = T2.l_orderkey ORDER BY T1.o_totalprice DESC LIMIT 5 | 
	CREATE TABLE `customer` (
  `c_custkey` INTEGER NOT NULL,
  `c_mktsegment` TEXT DEFAULT NULL,
  `c_nationkey` INTEGER DEFAULT NULL,
  `c_name` TEXT DEFAULT NULL,
  `c_address` TEXT DEFAULT NULL,
  `c_phone` TEXT DEFAULT NULL,
  `c_acctbal` REAL DEFAULT NULL,
  `c_comment` TEXT DEFAULT NULL,
  PRIMARY KEY (`c_custkey`),
  FOREIGN KEY (`c_nationkey`) REFERENCES `nation` (`n_nationkey`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE lineitem
(
    l_shipdate      DATE           null,
    l_orderkey      INTEGER         not null,
    l_discount      REAL not null,
    l_extendedprice REAL not null,
    l_suppkey       INTEGER            not null,
    l_quantity      INTEGER         not null,
    l_returnflag    TEXT           null,
    l_partkey       INTEGER         not null,
    l_linestatus    TEXT           null,
    l_tax           REAL not null,
    l_commitdate    DATE           null,
    l_receiptdate   DATE           null,
    l_shipmode      TEXT       null,
    l_linenumber    INTEGER         not null,
    l_shipinstruct  TEXT       null,
    l_comment       TEXT    null,
    primary key (l_orderkey, l_linenumber),
    foreign key (l_orderkey) references orders (o_orderkey)
            on update cascade on delete cascade,
    foreign key (l_partkey, l_suppkey) references partsupp (ps_partkey, ps_suppkey)
            on update cascade on delete cascade
);
CREATE TABLE nation
(
    n_nationkey INTEGER          not null
        primary key,
    n_name      TEXT     null,
    n_regionkey INTEGER          null,
    n_comment   TEXT null,
    foreign key (n_regionkey) references region (r_regionkey)
            on update cascade on delete cascade
);
CREATE TABLE orders
(
    o_orderdate     DATE           null,
    o_orderkey      INTEGER         not null
        primary key,
    o_custkey       INTEGER         not null,
    o_orderpriority TEXT       null,
    o_shippriority  INTEGER            null,
    o_clerk         TEXT       null,
    o_orderstatus   TEXT           null,
    o_totalprice    REAL null,
    o_comment       TEXT    null,
    foreign key (o_custkey) references customer (c_custkey)
            on update cascade on delete cascade
);
CREATE TABLE part
(
    p_partkey     INTEGER         not null
        primary key,
    p_type        TEXT    null,
    p_size        INTEGER            null,
    p_brand       TEXT       null,
    p_name        TEXT    null,
    p_container   TEXT       null,
    p_mfgr        TEXT       null,
    p_retailprice REAL null,
    p_comment     TEXT    null
);
CREATE TABLE partsupp
(
    ps_partkey    INTEGER         not null,
    ps_suppkey    INTEGER            not null,
    ps_supplycost REAL not null,
    ps_availqty   INTEGER            null,
    ps_comment    TEXT   null,
    primary key (ps_partkey, ps_suppkey),
    foreign key (ps_partkey) references part (p_partkey)
            on update cascade on delete cascade,
    foreign key (ps_suppkey) references supplier (s_suppkey)
            on update cascade on delete cascade
);
CREATE TABLE region
(
    r_regionkey INTEGER          not null
        primary key,
    r_name      TEXT     null,
    r_comment   TEXT null
);
CREATE TABLE supplier
(
    s_suppkey   INTEGER            not null
        primary key,
    s_nationkey INTEGER            null,
    s_comment   TEXT   null,
    s_name      TEXT       null,
    s_address   TEXT    null,
    s_phone     TEXT       null,
    s_acctbal   REAL null,
    foreign key (s_nationkey) references nation (n_nationkey)
);
 | 
| 
	retails | 
	Please list the names of the top 3 suppliers with the most amount of money in their accounts. | 
	supplier name refers to s_name; the most amount of money refers to max(s_acctbal) | 
	SELECT s_name FROM supplier ORDER BY s_acctbal DESC LIMIT 3 | 
	CREATE TABLE `customer` (
  `c_custkey` INTEGER NOT NULL,
  `c_mktsegment` TEXT DEFAULT NULL,
  `c_nationkey` INTEGER DEFAULT NULL,
  `c_name` TEXT DEFAULT NULL,
  `c_address` TEXT DEFAULT NULL,
  `c_phone` TEXT DEFAULT NULL,
  `c_acctbal` REAL DEFAULT NULL,
  `c_comment` TEXT DEFAULT NULL,
  PRIMARY KEY (`c_custkey`),
  FOREIGN KEY (`c_nationkey`) REFERENCES `nation` (`n_nationkey`) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE TABLE lineitem
(
    l_shipdate      DATE           null,
    l_orderkey      INTEGER         not null,
    l_discount      REAL not null,
    l_extendedprice REAL not null,
    l_suppkey       INTEGER            not null,
    l_quantity      INTEGER         not null,
    l_returnflag    TEXT           null,
    l_partkey       INTEGER         not null,
    l_linestatus    TEXT           null,
    l_tax           REAL not null,
    l_commitdate    DATE           null,
    l_receiptdate   DATE           null,
    l_shipmode      TEXT       null,
    l_linenumber    INTEGER         not null,
    l_shipinstruct  TEXT       null,
    l_comment       TEXT    null,
    primary key (l_orderkey, l_linenumber),
    foreign key (l_orderkey) references orders (o_orderkey)
            on update cascade on delete cascade,
    foreign key (l_partkey, l_suppkey) references partsupp (ps_partkey, ps_suppkey)
            on update cascade on delete cascade
);
CREATE TABLE nation
(
    n_nationkey INTEGER          not null
        primary key,
    n_name      TEXT     null,
    n_regionkey INTEGER          null,
    n_comment   TEXT null,
    foreign key (n_regionkey) references region (r_regionkey)
            on update cascade on delete cascade
);
CREATE TABLE orders
(
    o_orderdate     DATE           null,
    o_orderkey      INTEGER         not null
        primary key,
    o_custkey       INTEGER         not null,
    o_orderpriority TEXT       null,
    o_shippriority  INTEGER            null,
    o_clerk         TEXT       null,
    o_orderstatus   TEXT           null,
    o_totalprice    REAL null,
    o_comment       TEXT    null,
    foreign key (o_custkey) references customer (c_custkey)
            on update cascade on delete cascade
);
CREATE TABLE part
(
    p_partkey     INTEGER         not null
        primary key,
    p_type        TEXT    null,
    p_size        INTEGER            null,
    p_brand       TEXT       null,
    p_name        TEXT    null,
    p_container   TEXT       null,
    p_mfgr        TEXT       null,
    p_retailprice REAL null,
    p_comment     TEXT    null
);
CREATE TABLE partsupp
(
    ps_partkey    INTEGER         not null,
    ps_suppkey    INTEGER            not null,
    ps_supplycost REAL not null,
    ps_availqty   INTEGER            null,
    ps_comment    TEXT   null,
    primary key (ps_partkey, ps_suppkey),
    foreign key (ps_partkey) references part (p_partkey)
            on update cascade on delete cascade,
    foreign key (ps_suppkey) references supplier (s_suppkey)
            on update cascade on delete cascade
);
CREATE TABLE region
(
    r_regionkey INTEGER          not null
        primary key,
    r_name      TEXT     null,
    r_comment   TEXT null
);
CREATE TABLE supplier
(
    s_suppkey   INTEGER            not null
        primary key,
    s_nationkey INTEGER            null,
    s_comment   TEXT   null,
    s_name      TEXT       null,
    s_address   TEXT    null,
    s_phone     TEXT       null,
    s_acctbal   REAL null,
    foreign key (s_nationkey) references nation (n_nationkey)
);
 | 
| 
	works_cycles | 
	Show me the phone number of Gerald Patel's. | 
	SELECT T2.PhoneNumber FROM Person AS T1 INNER JOIN PersonPhone AS T2 ON T1.BusinessEntityID = T2.BusinessEntityID WHERE T1.FirstName = 'Gerald' AND T1.LastName = 'Patel' | 
	CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
    CountryRegionCode TEXT                          not null
        primary key,
    Name              TEXT                        not null
            unique,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE Culture
(
    CultureID    TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Currency
(
    CurrencyCode TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE CountryRegionCurrency
(
    CountryRegionCode TEXT                          not null,
    CurrencyCode      TEXT                             not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    primary key (CountryRegionCode, CurrencyCode),
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode),
    foreign key (CurrencyCode) references Currency(CurrencyCode)
);
CREATE TABLE Person
(
    BusinessEntityID      INTEGER                                  not null
        primary key,
    PersonType            TEXT                              not null,
    NameStyle             INTEGER default 0                 not null,
    Title                 TEXT,
    FirstName             TEXT                         not null,
    MiddleName            TEXT,
    LastName              TEXT                         not null,
    Suffix                TEXT,
    EmailPromotion        INTEGER        default 0                 not null,
    AdditionalContactInfo TEXT,
    Demographics          TEXT,
    rowguid               TEXT                          not null
            unique,
    ModifiedDate          DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE BusinessEntityContact
(
    BusinessEntityID INTEGER                                 not null,
    PersonID         INTEGER                                 not null,
    ContactTypeID    INTEGER                                 not null,
    rowguid         TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, PersonID, ContactTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (ContactTypeID) references ContactType(ContactTypeID),
    foreign key (PersonID) references Person(BusinessEntityID)
);
CREATE TABLE EmailAddress
(
    BusinessEntityID INTEGER                                 not null,
    EmailAddressID   INTEGER,
    EmailAddress     TEXT,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (EmailAddressID, BusinessEntityID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Employee
(
    BusinessEntityID  INTEGER                                 not null
        primary key,
    NationalIDNumber  TEXT                          not null
            unique,
    LoginID           TEXT                         not null
            unique,
    OrganizationNode  TEXT,
    OrganizationLevel INTEGER,
    JobTitle          TEXT                          not null,
    BirthDate         DATE                                 not null,
    MaritalStatus     TEXT                                 not null,
    Gender            TEXT                                 not null,
    HireDate          DATE                                 not null,
    SalariedFlag      INTEGER default 1                 not null,
    VacationHours     INTEGER   default 0                 not null,
    SickLeaveHours    INTEGER   default 0                 not null,
    CurrentFlag       INTEGER default 1                 not null,
    rowguid           TEXT                          not null
            unique,
    ModifiedDate      DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Password
(
    BusinessEntityID INTEGER                                 not null
        primary key,
    PasswordHash     TEXT                        not null,
    PasswordSalt     TEXT                         not null,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE PersonCreditCard
(
    BusinessEntityID INTEGER                                 not null,
    CreditCardID     INTEGER                                 not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, CreditCardID),
    foreign key (CreditCardID) references CreditCard(CreditCardID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE ProductCategory
(
    ProductCategoryID INTEGER
        primary key autoincrement,
    Name              TEXT                        not null
        unique,
    rowguid           TEXT                         not null
        unique,
    ModifiedDate      DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductDescription
(
    ProductDescriptionID INTEGER
        primary key autoincrement,
    Description          TEXT                        not null,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModel
(
    ProductModelID     INTEGER
        primary key autoincrement,
    Name               TEXT                        not null
        unique,
    CatalogDescription TEXT,
    Instructions       TEXT,
    rowguid            TEXT                         not null
        unique,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModelProductDescriptionCulture
(
    ProductModelID       INTEGER                             not null,
    ProductDescriptionID INTEGER                             not null,
    CultureID            TEXT                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductModelID, ProductDescriptionID, CultureID),
    foreign key (ProductModelID) references ProductModel(ProductModelID),
    foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID),
    foreign key (CultureID) references Culture(CultureID)
);
CREATE TABLE ProductPhoto
(
    ProductPhotoID         INTEGER
        primary key autoincrement,
    ThumbNailPhoto         BLOB,
    ThumbnailPhotoFileName TEXT,
    LargePhoto             BLOB,
    LargePhotoFileName     TEXT,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductSubcategory
(
    ProductSubcategoryID INTEGER
        primary key autoincrement,
    ProductCategoryID    INTEGER                             not null,
    Name                 TEXT                        not null
        unique,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate        DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID)
);
CREATE TABLE SalesReason
(
    SalesReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null,
    ReasonType    TEXT                        not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE SalesTerritory
(
    TerritoryID       INTEGER
        primary key autoincrement,
    Name              TEXT                             not null
        unique,
    CountryRegionCode TEXT                               not null,
    "Group"           TEXT                              not null,
    SalesYTD          REAL default 0.0000            not null,
    SalesLastYear     REAL default 0.0000            not null,
    CostYTD           REAL default 0.0000            not null,
    CostLastYear      REAL default 0.0000            not null,
    rowguid           TEXT                              not null
        unique,
    ModifiedDate      DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode)
);
CREATE TABLE SalesPerson
(
    BusinessEntityID INTEGER                                  not null
        primary key,
    TerritoryID      INTEGER,
    SalesQuota       REAL,
    Bonus            REAL default 0.0000            not null,
    CommissionPct    REAL default 0.0000            not null,
    SalesYTD         REAL default 0.0000            not null,
    SalesLastYear    REAL default 0.0000            not null,
    rowguid          TEXT                              not null
        unique,
    ModifiedDate     DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references Employee(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE SalesPersonQuotaHistory
(
    BusinessEntityID INTEGER                             not null,
    QuotaDate        DATETIME                            not null,
    SalesQuota       REAL                      not null,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, QuotaDate),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesTerritoryHistory
(
    BusinessEntityID INTEGER                             not null,
    TerritoryID      INTEGER                             not null,
    StartDate        DATETIME                            not null,
    EndDate          DATETIME,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, StartDate, TerritoryID),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE ScrapReason
(
    ScrapReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null
        unique,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE Shift
(
    ShiftID      INTEGER
        primary key autoincrement,
    Name         TEXT                        not null
        unique,
    StartTime    TEXT                                not null,
    EndTime      TEXT                                not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    unique (StartTime, EndTime)
);
CREATE TABLE ShipMethod
(
    ShipMethodID INTEGER
        primary key autoincrement,
    Name         TEXT                             not null
        unique,
    ShipBase     REAL default 0.0000            not null,
    ShipRate    REAL default 0.0000            not null,
    rowguid      TEXT                              not null
        unique,
    ModifiedDate DATETIME      default CURRENT_TIMESTAMP not null
);
CREATE TABLE SpecialOffer
(
    SpecialOfferID INTEGER
        primary key autoincrement,
    Description    TEXT                             not null,
    DiscountPct    REAL   default 0.0000            not null,
    Type           TEXT                             not null,
    Category       TEXT                             not null,
    StartDate      DATETIME                            not null,
    EndDate        DATETIME                            not null,
    MinQty         INTEGER   default 0                 not null,
    MaxQty         INTEGER,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE BusinessEntityAddress
(
    BusinessEntityID INTEGER                                 not null,
    AddressID        INTEGER                                 not null,
    AddressTypeID    INTEGER                                 not null,
    rowguid          TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, AddressID, AddressTypeID),
    foreign key (AddressID) references Address(AddressID),
    foreign key (AddressTypeID) references AddressType(AddressTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE SalesTaxRate
(
    SalesTaxRateID  INTEGER
        primary key autoincrement,
    StateProvinceID INTEGER                                  not null,
    TaxType         INTEGER                                  not null,
    TaxRate         REAL default 0.0000            not null,
    Name            TEXT                             not null,
    rowguid         TEXT                              not null
        unique,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    unique (StateProvinceID, TaxType),
    foreign key (StateProvinceID) references StateProvince(StateProvinceID)
);
CREATE TABLE Store
(
    BusinessEntityID INTEGER                             not null
        primary key,
    Name             TEXT                        not null,
    SalesPersonID    INTEGER,
    Demographics     TEXT,
    rowguid          TEXT                             not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (SalesPersonID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesOrderHeaderSalesReason
(
    SalesOrderID  INTEGER                             not null,
    SalesReasonID INTEGER                             not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SalesOrderID, SalesReasonID),
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SalesReasonID) references SalesReason(SalesReasonID)
);
CREATE TABLE TransactionHistoryArchive
(
    TransactionID        INTEGER                             not null
        primary key,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE UnitMeasure
(
    UnitMeasureCode TEXT                             not null
        primary key,
    Name            TEXT                        not null
        unique,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductCostHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    StandardCost REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ProductDocument
(
    ProductID    INTEGER                             not null,
    DocumentNode TEXT                        not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, DocumentNode),
    foreign key (ProductID) references Product(ProductID),
    foreign key (DocumentNode) references Document(DocumentNode)
);
CREATE TABLE ProductInventory
(
    ProductID    INTEGER                             not null,
    LocationID   INTEGER                            not null,
    Shelf        TEXT                         not null,
    Bin          INTEGER                             not null,
    Quantity     INTEGER  default 0                 not null,
    rowguid      TEXT                         not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, LocationID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE ProductProductPhoto
(
    ProductID      INTEGER                             not null,
    ProductPhotoID INTEGER                             not null,
    "Primary"      INTEGER   default 0                 not null,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, ProductPhotoID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID)
);
CREATE TABLE ProductReview
(
    ProductReviewID INTEGER
        primary key autoincrement,
    ProductID       INTEGER                             not null,
    ReviewerName   TEXT                        not null,
    ReviewDate      DATETIME default CURRENT_TIMESTAMP not null,
    EmailAddress    TEXT                         not null,
    Rating          INTEGER                             not null,
    Comments        TEXT,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ShoppingCartItem
(
    ShoppingCartItemID INTEGER
        primary key autoincrement,
    ShoppingCartID     TEXT                         not null,
    Quantity           INTEGER   default 1                 not null,
    ProductID          INTEGER                             not null,
    DateCreated        DATETIME default CURRENT_TIMESTAMP not null,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SpecialOfferProduct
(
    SpecialOfferID INTEGER                             not null,
    ProductID      INTEGER                             not null,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SpecialOfferID, ProductID),
    foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SalesOrderDetail
(
    SalesOrderID          INTEGER                             not null,
    SalesOrderDetailID    INTEGER
        primary key autoincrement,
    CarrierTrackingNumber TEXT,
    OrderQty              INTEGER                             not null,
    ProductID             INTEGER                             not null,
    SpecialOfferID        INTEGER                             not null,
    UnitPrice             REAL                             not null,
    UnitPriceDiscount     REAL   default 0.0000            not null,
    LineTotal             REAL                             not null,
    rowguid               TEXT                             not null
        unique,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID)
);
CREATE TABLE TransactionHistory
(
    TransactionID        INTEGER
        primary key autoincrement,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE Vendor
(
    BusinessEntityID        INTEGER                             not null
        primary key,
    AccountNumber           TEXT                         not null
        unique,
    Name                    TEXT                        not null,
    CreditRating            INTEGER                             not null,
    PreferredVendorStatus   INTEGER   default 1                 not null,
    ActiveFlag              INTEGER   default 1                 not null,
    PurchasingWebServiceURL TEXT,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE ProductVendor
(
    ProductID        INTEGER                             not null,
    BusinessEntityID INTEGER                             not null,
    AverageLeadTime  INTEGER                             not null,
    StandardPrice    REAL                      not null,
    LastReceiptCost  REAL,
    LastReceiptDate  DATETIME,
    MinOrderQty      INTEGER                             not null,
    MaxOrderQty      INTEGER                             not null,
    OnOrderQty       INTEGER,
    UnitMeasureCode  TEXT                             not null,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, BusinessEntityID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (BusinessEntityID) references Vendor(BusinessEntityID),
    foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode)
);
CREATE TABLE PurchaseOrderHeader
(
    PurchaseOrderID INTEGER
        primary key autoincrement,
    RevisionNumber  INTEGER        default 0                 not null,
    Status          INTEGER        default 1                 not null,
    EmployeeID      INTEGER                                  not null,
    VendorID        INTEGER                                  not null,
    ShipMethodID    INTEGER                                  not null,
    OrderDate       DATETIME      default CURRENT_TIMESTAMP not null,
    ShipDate        DATETIME,
    SubTotal        REAL default 0.0000            not null,
    TaxAmt          REAL default 0.0000            not null,
    Freight         REAL default 0.0000            not null,
    TotalDue        REAL                          not null,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (EmployeeID) references Employee(BusinessEntityID),
    foreign key (VendorID) references Vendor(BusinessEntityID),
    foreign key (ShipMethodID) references ShipMethod(ShipMethodID)
);
CREATE TABLE PurchaseOrderDetail
(
    PurchaseOrderID       INTEGER                            not null,
    PurchaseOrderDetailID INTEGER
        primary key autoincrement,
    DueDate               DATETIME                           not null,
    OrderQty              INTEGER                           not null,
    ProductID             INTEGER                            not null,
    UnitPrice             REAL                            not null,
    LineTotal             REAL                            not null,
    ReceivedQty           REAL                            not null,
    RejectedQty           REAL                            not null,
    StockedQty            REAL                            not null,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE WorkOrder
(
    WorkOrderID   INTEGER
        primary key autoincrement,
    ProductID     INTEGER                             not null,
    OrderQty      INTEGER                             not null,
    StockedQty    INTEGER                             not null,
    ScrappedQty   INTEGER                           not null,
    StartDate     DATETIME                            not null,
    EndDate       DATETIME,
    DueDate       DATETIME                            not null,
    ScrapReasonID INTEGER,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID),
    foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID)
);
CREATE TABLE WorkOrderRouting
(
    WorkOrderID        INTEGER                             not null,
    ProductID          INTEGER                             not null,
    OperationSequence  INTEGER                             not null,
    LocationID         INTEGER                             not null,
    ScheduledStartDate DATETIME                            not null,
    ScheduledEndDate   DATETIME                            not null,
    ActualStartDate    DATETIME,
    ActualEndDate      DATETIME,
    ActualResourceHrs  REAL,
    PlannedCost        REAL                      not null,
    ActualCost         REAL,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    primary key (WorkOrderID, ProductID, OperationSequence),
    foreign key (WorkOrderID) references WorkOrder(WorkOrderID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE Customer
(
    CustomerID    INTEGER
        primary key,
    PersonID      INTEGER,
    StoreID       INTEGER,
    TerritoryID   INTEGER,
    AccountNumber TEXT                         not null
            unique,
    rowguid       TEXT                         not null
            unique,
    ModifiedDate  DATETIME default current_timestamp not null,
    foreign key (PersonID) references Person(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID),
    foreign key (StoreID) references Store(BusinessEntityID)
);
CREATE TABLE ProductListPriceHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    ListPrice    REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE IF NOT EXISTS "Address"
(
    AddressID       INTEGER
        primary key autoincrement,
    AddressLine1    TEXT                               not null,
    AddressLine2    TEXT,
    City            TEXT                               not null,
    StateProvinceID INTEGER                            not null
        references StateProvince,
    PostalCode      TEXT                               not null,
    SpatialLocation TEXT,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode)
);
CREATE TABLE IF NOT EXISTS "AddressType"
(
    AddressTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    rowguid       TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "BillOfMaterials"
(
    BillOfMaterialsID INTEGER
        primary key autoincrement,
    ProductAssemblyID INTEGER
        references Product,
    ComponentID       INTEGER                            not null
        references Product,
    StartDate         DATETIME default current_timestamp not null,
    EndDate           DATETIME,
    UnitMeasureCode   TEXT                               not null
        references UnitMeasure,
    BOMLevel          INTEGER                            not null,
    PerAssemblyQty    REAL     default 1.00              not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    unique (ProductAssemblyID, ComponentID, StartDate)
);
CREATE TABLE IF NOT EXISTS "BusinessEntity"
(
    BusinessEntityID INTEGER
        primary key autoincrement,
    rowguid          TEXT                               not null
        unique,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "ContactType"
(
    ContactTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "CurrencyRate"
(
    CurrencyRateID   INTEGER
        primary key autoincrement,
    CurrencyRateDate DATETIME                           not null,
    FromCurrencyCode TEXT                               not null
        references Currency,
    ToCurrencyCode   TEXT                               not null
        references Currency,
    AverageRate      REAL                               not null,
    EndOfDayRate     REAL                               not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode)
);
CREATE TABLE IF NOT EXISTS "Department"
(
    DepartmentID INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    GroupName    TEXT                               not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    DepartmentID     INTEGER                            not null
        references Department,
    ShiftID          INTEGER                            not null
        references Shift,
    StartDate        DATE                               not null,
    EndDate          DATE,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID)
);
CREATE TABLE IF NOT EXISTS "EmployeePayHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    RateChangeDate   DATETIME                           not null,
    Rate             REAL                               not null,
    PayFrequency     INTEGER                            not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, RateChangeDate)
);
CREATE TABLE IF NOT EXISTS "JobCandidate"
(
    JobCandidateID   INTEGER
        primary key autoincrement,
    BusinessEntityID INTEGER
        references Employee,
    Resume           TEXT,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Location"
(
    LocationID   INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    CostRate     REAL     default 0.0000            not null,
    Availability REAL     default 0.00              not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "PhoneNumberType"
(
    PhoneNumberTypeID INTEGER
        primary key autoincrement,
    Name              TEXT                               not null,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Product"
(
    ProductID             INTEGER
        primary key autoincrement,
    Name                  TEXT                               not null
        unique,
    ProductNumber         TEXT                               not null
        unique,
    MakeFlag              INTEGER  default 1                 not null,
    FinishedGoodsFlag     INTEGER  default 1                 not null,
    Color                 TEXT,
    SafetyStockLevel      INTEGER                            not null,
    ReorderPoint          INTEGER                            not null,
    StandardCost          REAL                               not null,
    ListPrice             REAL                               not null,
    Size                  TEXT,
    SizeUnitMeasureCode   TEXT
        references UnitMeasure,
    WeightUnitMeasureCode TEXT
        references UnitMeasure,
    Weight                REAL,
    DaysToManufacture     INTEGER                            not null,
    ProductLine           TEXT,
    Class                 TEXT,
    Style                 TEXT,
    ProductSubcategoryID  INTEGER
        references ProductSubcategory,
    ProductModelID        INTEGER
        references ProductModel,
    SellStartDate         DATETIME                           not null,
    SellEndDate           DATETIME,
    DiscontinuedDate      DATETIME,
    rowguid               TEXT                               not null
        unique,
    ModifiedDate          DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Document"
(
    DocumentNode    TEXT                               not null
        primary key,
    DocumentLevel   INTEGER,
    Title           TEXT                               not null,
    Owner           INTEGER                            not null
        references Employee,
    FolderFlag      INTEGER  default 0                 not null,
    FileName        TEXT                               not null,
    FileExtension   TEXT                               not null,
    Revision        TEXT                               not null,
    ChangeNumber    INTEGER  default 0                 not null,
    Status          INTEGER                            not null,
    DocumentSummary TEXT,
    Document        BLOB,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (DocumentLevel, DocumentNode)
);
CREATE TABLE IF NOT EXISTS "StateProvince"
(
    StateProvinceID         INTEGER
        primary key autoincrement,
    StateProvinceCode       TEXT                               not null,
    CountryRegionCode       TEXT                               not null
        references CountryRegion,
    IsOnlyStateProvinceFlag INTEGER  default 1                 not null,
    Name                    TEXT                               not null
        unique,
    TerritoryID             INTEGER                            not null
        references SalesTerritory,
    rowguid                 TEXT                               not null
        unique,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    unique (StateProvinceCode, CountryRegionCode)
);
CREATE TABLE IF NOT EXISTS "CreditCard"
(
    CreditCardID INTEGER
        primary key autoincrement,
    CardType     TEXT                               not null,
    CardNumber   TEXT                               not null
        unique,
    ExpMonth     INTEGER                            not null,
    ExpYear      INTEGER                            not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "SalesOrderHeader"
(
    SalesOrderID           INTEGER
        primary key autoincrement,
    RevisionNumber         INTEGER  default 0                 not null,
    OrderDate              DATETIME default CURRENT_TIMESTAMP not null,
    DueDate                DATETIME                           not null,
    ShipDate               DATETIME,
    Status                 INTEGER  default 1                 not null,
    OnlineOrderFlag        INTEGER  default 1                 not null,
    SalesOrderNumber       TEXT                               not null
        unique,
    PurchaseOrderNumber    TEXT,
    AccountNumber          TEXT,
    CustomerID             INTEGER                            not null
        references Customer,
    SalesPersonID          INTEGER
        references SalesPerson,
    TerritoryID            INTEGER
        references SalesTerritory,
    BillToAddressID        INTEGER                            not null
        references Address,
    ShipToAddressID        INTEGER                            not null
        references Address,
    ShipMethodID           INTEGER                            not null
        references Address,
    CreditCardID           INTEGER
        references CreditCard,
    CreditCardApprovalCode TEXT,
    CurrencyRateID         INTEGER
        references CurrencyRate,
    SubTotal               REAL     default 0.0000            not null,
    TaxAmt                 REAL     default 0.0000            not null,
    Freight                REAL     default 0.0000            not null,
    TotalDue               REAL                               not null,
    Comment                TEXT,
    rowguid                TEXT                               not null
        unique,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
 | |
| 
	chicago_crime | 
	What is the name of the district with the highest number of domestic violence cases? | 
	domestic violence refers to domestic = 'TRUE'; highest number of case refers to Max(Count(district_no)); name of district refers to distric_name | 
	SELECT T2.district_name FROM Crime AS T1 INNER JOIN District AS T2 ON T1.district_no = T2.district_no WHERE T1.domestic = 'TRUE' GROUP BY T2.district_name ORDER BY COUNT(T1.district_no) DESC LIMIT 1 | 
	CREATE TABLE Community_Area
(
    community_area_no   INTEGER
            primary key,
    community_area_name TEXT,
    side                TEXT,
    population          TEXT
);
CREATE TABLE District
(
    district_no   INTEGER
            primary key,
    district_name TEXT,
    address       TEXT,
    zip_code      INTEGER,
    commander     TEXT,
    email         TEXT,
    phone         TEXT,
    fax           TEXT,
    tty           TEXT,
    twitter       TEXT
);
CREATE TABLE FBI_Code
(
    fbi_code_no   TEXT
            primary key,
    title         TEXT,
    description   TEXT,
    crime_against TEXT
);
CREATE TABLE IUCR
(
    iucr_no               TEXT
            primary key,
    primary_description   TEXT,
    secondary_description TEXT,
    index_code            TEXT
);
CREATE TABLE Neighborhood
(
    neighborhood_name TEXT
            primary key,
    community_area_no INTEGER,
    foreign key (community_area_no) references Community_Area(community_area_no)
);
CREATE TABLE Ward
(
    ward_no                INTEGER
            primary key,
    alderman_first_name    TEXT,
    alderman_last_name     TEXT,
    alderman_name_suffix   TEXT,
    ward_office_address    TEXT,
    ward_office_zip        TEXT,
    ward_email             TEXT,
    ward_office_phone      TEXT,
    ward_office_fax        TEXT,
    city_hall_office_room  INTEGER,
    city_hall_office_phone TEXT,
    city_hall_office_fax   TEXT,
    Population             INTEGER
);
CREATE TABLE Crime
(
    report_no            INTEGER
            primary key,
    case_number          TEXT,
    date                 TEXT,
    block                TEXT,
    iucr_no              TEXT,
    location_description TEXT,
    arrest               TEXT,
    domestic             TEXT,
    beat                 INTEGER,
    district_no          INTEGER,
    ward_no              INTEGER,
    community_area_no    INTEGER,
    fbi_code_no          TEXT,
    latitude             TEXT,
    longitude            TEXT,
    foreign key (ward_no) references Ward(ward_no),
    foreign key (iucr_no) references IUCR(iucr_no),
    foreign key (district_no) references District(district_no),
    foreign key (community_area_no) references Community_Area(community_area_no),
    foreign key (fbi_code_no) references FBI_Code(fbi_code_no)
);
 | 
| 
	works_cycles | 
	What is the total amount due of all the purchases made by the company to the vendor that has the lowest selling price amount of a single product? Indicate the name of the vendor to which the purchases was made. | 
	Vendor's selling price of a single product refers to UnitPrice; | 
	SELECT T1.UnitPrice, T3.Name FROM PurchaseOrderDetail AS T1 INNER JOIN PurchaseOrderHeader AS T2 ON T1.PurchaseOrderID = T2.PurchaseOrderID INNER JOIN Vendor AS T3 ON T2.VendorID = T3.BusinessEntityID ORDER BY T1.UnitPrice LIMIT 1 | 
	CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
    CountryRegionCode TEXT                          not null
        primary key,
    Name              TEXT                        not null
            unique,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE Culture
(
    CultureID    TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Currency
(
    CurrencyCode TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE CountryRegionCurrency
(
    CountryRegionCode TEXT                          not null,
    CurrencyCode      TEXT                             not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    primary key (CountryRegionCode, CurrencyCode),
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode),
    foreign key (CurrencyCode) references Currency(CurrencyCode)
);
CREATE TABLE Person
(
    BusinessEntityID      INTEGER                                  not null
        primary key,
    PersonType            TEXT                              not null,
    NameStyle             INTEGER default 0                 not null,
    Title                 TEXT,
    FirstName             TEXT                         not null,
    MiddleName            TEXT,
    LastName              TEXT                         not null,
    Suffix                TEXT,
    EmailPromotion        INTEGER        default 0                 not null,
    AdditionalContactInfo TEXT,
    Demographics          TEXT,
    rowguid               TEXT                          not null
            unique,
    ModifiedDate          DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE BusinessEntityContact
(
    BusinessEntityID INTEGER                                 not null,
    PersonID         INTEGER                                 not null,
    ContactTypeID    INTEGER                                 not null,
    rowguid         TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, PersonID, ContactTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (ContactTypeID) references ContactType(ContactTypeID),
    foreign key (PersonID) references Person(BusinessEntityID)
);
CREATE TABLE EmailAddress
(
    BusinessEntityID INTEGER                                 not null,
    EmailAddressID   INTEGER,
    EmailAddress     TEXT,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (EmailAddressID, BusinessEntityID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Employee
(
    BusinessEntityID  INTEGER                                 not null
        primary key,
    NationalIDNumber  TEXT                          not null
            unique,
    LoginID           TEXT                         not null
            unique,
    OrganizationNode  TEXT,
    OrganizationLevel INTEGER,
    JobTitle          TEXT                          not null,
    BirthDate         DATE                                 not null,
    MaritalStatus     TEXT                                 not null,
    Gender            TEXT                                 not null,
    HireDate          DATE                                 not null,
    SalariedFlag      INTEGER default 1                 not null,
    VacationHours     INTEGER   default 0                 not null,
    SickLeaveHours    INTEGER   default 0                 not null,
    CurrentFlag       INTEGER default 1                 not null,
    rowguid           TEXT                          not null
            unique,
    ModifiedDate      DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Password
(
    BusinessEntityID INTEGER                                 not null
        primary key,
    PasswordHash     TEXT                        not null,
    PasswordSalt     TEXT                         not null,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE PersonCreditCard
(
    BusinessEntityID INTEGER                                 not null,
    CreditCardID     INTEGER                                 not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, CreditCardID),
    foreign key (CreditCardID) references CreditCard(CreditCardID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE ProductCategory
(
    ProductCategoryID INTEGER
        primary key autoincrement,
    Name              TEXT                        not null
        unique,
    rowguid           TEXT                         not null
        unique,
    ModifiedDate      DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductDescription
(
    ProductDescriptionID INTEGER
        primary key autoincrement,
    Description          TEXT                        not null,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModel
(
    ProductModelID     INTEGER
        primary key autoincrement,
    Name               TEXT                        not null
        unique,
    CatalogDescription TEXT,
    Instructions       TEXT,
    rowguid            TEXT                         not null
        unique,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModelProductDescriptionCulture
(
    ProductModelID       INTEGER                             not null,
    ProductDescriptionID INTEGER                             not null,
    CultureID            TEXT                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductModelID, ProductDescriptionID, CultureID),
    foreign key (ProductModelID) references ProductModel(ProductModelID),
    foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID),
    foreign key (CultureID) references Culture(CultureID)
);
CREATE TABLE ProductPhoto
(
    ProductPhotoID         INTEGER
        primary key autoincrement,
    ThumbNailPhoto         BLOB,
    ThumbnailPhotoFileName TEXT,
    LargePhoto             BLOB,
    LargePhotoFileName     TEXT,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductSubcategory
(
    ProductSubcategoryID INTEGER
        primary key autoincrement,
    ProductCategoryID    INTEGER                             not null,
    Name                 TEXT                        not null
        unique,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate        DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID)
);
CREATE TABLE SalesReason
(
    SalesReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null,
    ReasonType    TEXT                        not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE SalesTerritory
(
    TerritoryID       INTEGER
        primary key autoincrement,
    Name              TEXT                             not null
        unique,
    CountryRegionCode TEXT                               not null,
    "Group"           TEXT                              not null,
    SalesYTD          REAL default 0.0000            not null,
    SalesLastYear     REAL default 0.0000            not null,
    CostYTD           REAL default 0.0000            not null,
    CostLastYear      REAL default 0.0000            not null,
    rowguid           TEXT                              not null
        unique,
    ModifiedDate      DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode)
);
CREATE TABLE SalesPerson
(
    BusinessEntityID INTEGER                                  not null
        primary key,
    TerritoryID      INTEGER,
    SalesQuota       REAL,
    Bonus            REAL default 0.0000            not null,
    CommissionPct    REAL default 0.0000            not null,
    SalesYTD         REAL default 0.0000            not null,
    SalesLastYear    REAL default 0.0000            not null,
    rowguid          TEXT                              not null
        unique,
    ModifiedDate     DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references Employee(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE SalesPersonQuotaHistory
(
    BusinessEntityID INTEGER                             not null,
    QuotaDate        DATETIME                            not null,
    SalesQuota       REAL                      not null,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, QuotaDate),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesTerritoryHistory
(
    BusinessEntityID INTEGER                             not null,
    TerritoryID      INTEGER                             not null,
    StartDate        DATETIME                            not null,
    EndDate          DATETIME,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, StartDate, TerritoryID),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE ScrapReason
(
    ScrapReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null
        unique,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE Shift
(
    ShiftID      INTEGER
        primary key autoincrement,
    Name         TEXT                        not null
        unique,
    StartTime    TEXT                                not null,
    EndTime      TEXT                                not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    unique (StartTime, EndTime)
);
CREATE TABLE ShipMethod
(
    ShipMethodID INTEGER
        primary key autoincrement,
    Name         TEXT                             not null
        unique,
    ShipBase     REAL default 0.0000            not null,
    ShipRate    REAL default 0.0000            not null,
    rowguid      TEXT                              not null
        unique,
    ModifiedDate DATETIME      default CURRENT_TIMESTAMP not null
);
CREATE TABLE SpecialOffer
(
    SpecialOfferID INTEGER
        primary key autoincrement,
    Description    TEXT                             not null,
    DiscountPct    REAL   default 0.0000            not null,
    Type           TEXT                             not null,
    Category       TEXT                             not null,
    StartDate      DATETIME                            not null,
    EndDate        DATETIME                            not null,
    MinQty         INTEGER   default 0                 not null,
    MaxQty         INTEGER,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE BusinessEntityAddress
(
    BusinessEntityID INTEGER                                 not null,
    AddressID        INTEGER                                 not null,
    AddressTypeID    INTEGER                                 not null,
    rowguid          TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, AddressID, AddressTypeID),
    foreign key (AddressID) references Address(AddressID),
    foreign key (AddressTypeID) references AddressType(AddressTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE SalesTaxRate
(
    SalesTaxRateID  INTEGER
        primary key autoincrement,
    StateProvinceID INTEGER                                  not null,
    TaxType         INTEGER                                  not null,
    TaxRate         REAL default 0.0000            not null,
    Name            TEXT                             not null,
    rowguid         TEXT                              not null
        unique,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    unique (StateProvinceID, TaxType),
    foreign key (StateProvinceID) references StateProvince(StateProvinceID)
);
CREATE TABLE Store
(
    BusinessEntityID INTEGER                             not null
        primary key,
    Name             TEXT                        not null,
    SalesPersonID    INTEGER,
    Demographics     TEXT,
    rowguid          TEXT                             not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (SalesPersonID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesOrderHeaderSalesReason
(
    SalesOrderID  INTEGER                             not null,
    SalesReasonID INTEGER                             not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SalesOrderID, SalesReasonID),
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SalesReasonID) references SalesReason(SalesReasonID)
);
CREATE TABLE TransactionHistoryArchive
(
    TransactionID        INTEGER                             not null
        primary key,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE UnitMeasure
(
    UnitMeasureCode TEXT                             not null
        primary key,
    Name            TEXT                        not null
        unique,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductCostHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    StandardCost REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ProductDocument
(
    ProductID    INTEGER                             not null,
    DocumentNode TEXT                        not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, DocumentNode),
    foreign key (ProductID) references Product(ProductID),
    foreign key (DocumentNode) references Document(DocumentNode)
);
CREATE TABLE ProductInventory
(
    ProductID    INTEGER                             not null,
    LocationID   INTEGER                            not null,
    Shelf        TEXT                         not null,
    Bin          INTEGER                             not null,
    Quantity     INTEGER  default 0                 not null,
    rowguid      TEXT                         not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, LocationID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE ProductProductPhoto
(
    ProductID      INTEGER                             not null,
    ProductPhotoID INTEGER                             not null,
    "Primary"      INTEGER   default 0                 not null,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, ProductPhotoID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID)
);
CREATE TABLE ProductReview
(
    ProductReviewID INTEGER
        primary key autoincrement,
    ProductID       INTEGER                             not null,
    ReviewerName   TEXT                        not null,
    ReviewDate      DATETIME default CURRENT_TIMESTAMP not null,
    EmailAddress    TEXT                         not null,
    Rating          INTEGER                             not null,
    Comments        TEXT,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ShoppingCartItem
(
    ShoppingCartItemID INTEGER
        primary key autoincrement,
    ShoppingCartID     TEXT                         not null,
    Quantity           INTEGER   default 1                 not null,
    ProductID          INTEGER                             not null,
    DateCreated        DATETIME default CURRENT_TIMESTAMP not null,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SpecialOfferProduct
(
    SpecialOfferID INTEGER                             not null,
    ProductID      INTEGER                             not null,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SpecialOfferID, ProductID),
    foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SalesOrderDetail
(
    SalesOrderID          INTEGER                             not null,
    SalesOrderDetailID    INTEGER
        primary key autoincrement,
    CarrierTrackingNumber TEXT,
    OrderQty              INTEGER                             not null,
    ProductID             INTEGER                             not null,
    SpecialOfferID        INTEGER                             not null,
    UnitPrice             REAL                             not null,
    UnitPriceDiscount     REAL   default 0.0000            not null,
    LineTotal             REAL                             not null,
    rowguid               TEXT                             not null
        unique,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID)
);
CREATE TABLE TransactionHistory
(
    TransactionID        INTEGER
        primary key autoincrement,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE Vendor
(
    BusinessEntityID        INTEGER                             not null
        primary key,
    AccountNumber           TEXT                         not null
        unique,
    Name                    TEXT                        not null,
    CreditRating            INTEGER                             not null,
    PreferredVendorStatus   INTEGER   default 1                 not null,
    ActiveFlag              INTEGER   default 1                 not null,
    PurchasingWebServiceURL TEXT,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE ProductVendor
(
    ProductID        INTEGER                             not null,
    BusinessEntityID INTEGER                             not null,
    AverageLeadTime  INTEGER                             not null,
    StandardPrice    REAL                      not null,
    LastReceiptCost  REAL,
    LastReceiptDate  DATETIME,
    MinOrderQty      INTEGER                             not null,
    MaxOrderQty      INTEGER                             not null,
    OnOrderQty       INTEGER,
    UnitMeasureCode  TEXT                             not null,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, BusinessEntityID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (BusinessEntityID) references Vendor(BusinessEntityID),
    foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode)
);
CREATE TABLE PurchaseOrderHeader
(
    PurchaseOrderID INTEGER
        primary key autoincrement,
    RevisionNumber  INTEGER        default 0                 not null,
    Status          INTEGER        default 1                 not null,
    EmployeeID      INTEGER                                  not null,
    VendorID        INTEGER                                  not null,
    ShipMethodID    INTEGER                                  not null,
    OrderDate       DATETIME      default CURRENT_TIMESTAMP not null,
    ShipDate        DATETIME,
    SubTotal        REAL default 0.0000            not null,
    TaxAmt          REAL default 0.0000            not null,
    Freight         REAL default 0.0000            not null,
    TotalDue        REAL                          not null,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (EmployeeID) references Employee(BusinessEntityID),
    foreign key (VendorID) references Vendor(BusinessEntityID),
    foreign key (ShipMethodID) references ShipMethod(ShipMethodID)
);
CREATE TABLE PurchaseOrderDetail
(
    PurchaseOrderID       INTEGER                            not null,
    PurchaseOrderDetailID INTEGER
        primary key autoincrement,
    DueDate               DATETIME                           not null,
    OrderQty              INTEGER                           not null,
    ProductID             INTEGER                            not null,
    UnitPrice             REAL                            not null,
    LineTotal             REAL                            not null,
    ReceivedQty           REAL                            not null,
    RejectedQty           REAL                            not null,
    StockedQty            REAL                            not null,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE WorkOrder
(
    WorkOrderID   INTEGER
        primary key autoincrement,
    ProductID     INTEGER                             not null,
    OrderQty      INTEGER                             not null,
    StockedQty    INTEGER                             not null,
    ScrappedQty   INTEGER                           not null,
    StartDate     DATETIME                            not null,
    EndDate       DATETIME,
    DueDate       DATETIME                            not null,
    ScrapReasonID INTEGER,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID),
    foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID)
);
CREATE TABLE WorkOrderRouting
(
    WorkOrderID        INTEGER                             not null,
    ProductID          INTEGER                             not null,
    OperationSequence  INTEGER                             not null,
    LocationID         INTEGER                             not null,
    ScheduledStartDate DATETIME                            not null,
    ScheduledEndDate   DATETIME                            not null,
    ActualStartDate    DATETIME,
    ActualEndDate      DATETIME,
    ActualResourceHrs  REAL,
    PlannedCost        REAL                      not null,
    ActualCost         REAL,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    primary key (WorkOrderID, ProductID, OperationSequence),
    foreign key (WorkOrderID) references WorkOrder(WorkOrderID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE Customer
(
    CustomerID    INTEGER
        primary key,
    PersonID      INTEGER,
    StoreID       INTEGER,
    TerritoryID   INTEGER,
    AccountNumber TEXT                         not null
            unique,
    rowguid       TEXT                         not null
            unique,
    ModifiedDate  DATETIME default current_timestamp not null,
    foreign key (PersonID) references Person(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID),
    foreign key (StoreID) references Store(BusinessEntityID)
);
CREATE TABLE ProductListPriceHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    ListPrice    REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE IF NOT EXISTS "Address"
(
    AddressID       INTEGER
        primary key autoincrement,
    AddressLine1    TEXT                               not null,
    AddressLine2    TEXT,
    City            TEXT                               not null,
    StateProvinceID INTEGER                            not null
        references StateProvince,
    PostalCode      TEXT                               not null,
    SpatialLocation TEXT,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode)
);
CREATE TABLE IF NOT EXISTS "AddressType"
(
    AddressTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    rowguid       TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "BillOfMaterials"
(
    BillOfMaterialsID INTEGER
        primary key autoincrement,
    ProductAssemblyID INTEGER
        references Product,
    ComponentID       INTEGER                            not null
        references Product,
    StartDate         DATETIME default current_timestamp not null,
    EndDate           DATETIME,
    UnitMeasureCode   TEXT                               not null
        references UnitMeasure,
    BOMLevel          INTEGER                            not null,
    PerAssemblyQty    REAL     default 1.00              not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    unique (ProductAssemblyID, ComponentID, StartDate)
);
CREATE TABLE IF NOT EXISTS "BusinessEntity"
(
    BusinessEntityID INTEGER
        primary key autoincrement,
    rowguid          TEXT                               not null
        unique,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "ContactType"
(
    ContactTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "CurrencyRate"
(
    CurrencyRateID   INTEGER
        primary key autoincrement,
    CurrencyRateDate DATETIME                           not null,
    FromCurrencyCode TEXT                               not null
        references Currency,
    ToCurrencyCode   TEXT                               not null
        references Currency,
    AverageRate      REAL                               not null,
    EndOfDayRate     REAL                               not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode)
);
CREATE TABLE IF NOT EXISTS "Department"
(
    DepartmentID INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    GroupName    TEXT                               not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    DepartmentID     INTEGER                            not null
        references Department,
    ShiftID          INTEGER                            not null
        references Shift,
    StartDate        DATE                               not null,
    EndDate          DATE,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID)
);
CREATE TABLE IF NOT EXISTS "EmployeePayHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    RateChangeDate   DATETIME                           not null,
    Rate             REAL                               not null,
    PayFrequency     INTEGER                            not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, RateChangeDate)
);
CREATE TABLE IF NOT EXISTS "JobCandidate"
(
    JobCandidateID   INTEGER
        primary key autoincrement,
    BusinessEntityID INTEGER
        references Employee,
    Resume           TEXT,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Location"
(
    LocationID   INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    CostRate     REAL     default 0.0000            not null,
    Availability REAL     default 0.00              not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "PhoneNumberType"
(
    PhoneNumberTypeID INTEGER
        primary key autoincrement,
    Name              TEXT                               not null,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Product"
(
    ProductID             INTEGER
        primary key autoincrement,
    Name                  TEXT                               not null
        unique,
    ProductNumber         TEXT                               not null
        unique,
    MakeFlag              INTEGER  default 1                 not null,
    FinishedGoodsFlag     INTEGER  default 1                 not null,
    Color                 TEXT,
    SafetyStockLevel      INTEGER                            not null,
    ReorderPoint          INTEGER                            not null,
    StandardCost          REAL                               not null,
    ListPrice             REAL                               not null,
    Size                  TEXT,
    SizeUnitMeasureCode   TEXT
        references UnitMeasure,
    WeightUnitMeasureCode TEXT
        references UnitMeasure,
    Weight                REAL,
    DaysToManufacture     INTEGER                            not null,
    ProductLine           TEXT,
    Class                 TEXT,
    Style                 TEXT,
    ProductSubcategoryID  INTEGER
        references ProductSubcategory,
    ProductModelID        INTEGER
        references ProductModel,
    SellStartDate         DATETIME                           not null,
    SellEndDate           DATETIME,
    DiscontinuedDate      DATETIME,
    rowguid               TEXT                               not null
        unique,
    ModifiedDate          DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Document"
(
    DocumentNode    TEXT                               not null
        primary key,
    DocumentLevel   INTEGER,
    Title           TEXT                               not null,
    Owner           INTEGER                            not null
        references Employee,
    FolderFlag      INTEGER  default 0                 not null,
    FileName        TEXT                               not null,
    FileExtension   TEXT                               not null,
    Revision        TEXT                               not null,
    ChangeNumber    INTEGER  default 0                 not null,
    Status          INTEGER                            not null,
    DocumentSummary TEXT,
    Document        BLOB,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (DocumentLevel, DocumentNode)
);
CREATE TABLE IF NOT EXISTS "StateProvince"
(
    StateProvinceID         INTEGER
        primary key autoincrement,
    StateProvinceCode       TEXT                               not null,
    CountryRegionCode       TEXT                               not null
        references CountryRegion,
    IsOnlyStateProvinceFlag INTEGER  default 1                 not null,
    Name                    TEXT                               not null
        unique,
    TerritoryID             INTEGER                            not null
        references SalesTerritory,
    rowguid                 TEXT                               not null
        unique,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    unique (StateProvinceCode, CountryRegionCode)
);
CREATE TABLE IF NOT EXISTS "CreditCard"
(
    CreditCardID INTEGER
        primary key autoincrement,
    CardType     TEXT                               not null,
    CardNumber   TEXT                               not null
        unique,
    ExpMonth     INTEGER                            not null,
    ExpYear      INTEGER                            not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "SalesOrderHeader"
(
    SalesOrderID           INTEGER
        primary key autoincrement,
    RevisionNumber         INTEGER  default 0                 not null,
    OrderDate              DATETIME default CURRENT_TIMESTAMP not null,
    DueDate                DATETIME                           not null,
    ShipDate               DATETIME,
    Status                 INTEGER  default 1                 not null,
    OnlineOrderFlag        INTEGER  default 1                 not null,
    SalesOrderNumber       TEXT                               not null
        unique,
    PurchaseOrderNumber    TEXT,
    AccountNumber          TEXT,
    CustomerID             INTEGER                            not null
        references Customer,
    SalesPersonID          INTEGER
        references SalesPerson,
    TerritoryID            INTEGER
        references SalesTerritory,
    BillToAddressID        INTEGER                            not null
        references Address,
    ShipToAddressID        INTEGER                            not null
        references Address,
    ShipMethodID           INTEGER                            not null
        references Address,
    CreditCardID           INTEGER
        references CreditCard,
    CreditCardApprovalCode TEXT,
    CurrencyRateID         INTEGER
        references CurrencyRate,
    SubTotal               REAL     default 0.0000            not null,
    TaxAmt                 REAL     default 0.0000            not null,
    Freight                REAL     default 0.0000            not null,
    TotalDue               REAL                               not null,
    Comment                TEXT,
    rowguid                TEXT                               not null
        unique,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
 | 
| 
	restaurant | 
	What is the full address of the restaurant named "Sanuki Restaurant"? | 
	full address refers to city, street_num, street_name; restaurant named "Sanuki Restaurant" refers to label = 'sanuki restaurant' | 
	SELECT T2.city, T1.street_num, T1.street_name FROM location AS T1 INNER JOIN generalinfo AS T2 ON T1.id_restaurant = T2.id_restaurant WHERE T2.label = 'sanuki restaurant' | 
	CREATE TABLE geographic
(
    city   TEXT not null
        primary key,
    county TEXT null,
    region TEXT null
);
CREATE TABLE generalinfo
(
    id_restaurant INTEGER         not null
        primary key,
    label         TEXT  null,
    food_type     TEXT  null,
    city          TEXT  null,
    review        REAL null,
    foreign key (city) references geographic(city)
            on update cascade on delete cascade
);
CREATE TABLE location
(
    id_restaurant INTEGER        not null
        primary key,
    street_num    INTEGER          null,
    street_name   TEXT null,
    city          TEXT null,
    foreign key (city) references geographic (city)
            on update cascade on delete cascade,
    foreign key (id_restaurant) references generalinfo (id_restaurant)
            on update cascade on delete cascade
);
 | 
| 
	food_inspection_2 | 
	State the salary of the employee who did the most inspections. | 
	the most inspections refers to max(count(employee_id)) | 
	SELECT T1.salary FROM employee AS T1 INNER JOIN ( SELECT T.employee_id, COUNT(T.inspection_id) FROM inspection AS T GROUP BY T.employee_id ORDER BY COUNT(T.inspection_id) DESC LIMIT 1 ) AS T2 ON T1.employee_id = T2.employee_id | 
	CREATE TABLE employee
(
    employee_id INTEGER
            primary key,
    first_name  TEXT,
    last_name   TEXT,
    address     TEXT,
    city        TEXT,
    state       TEXT,
    zip         INTEGER,
    phone       TEXT,
    title       TEXT,
    salary      INTEGER,
    supervisor  INTEGER,
    foreign key (supervisor) references employee(employee_id)
);
CREATE TABLE establishment
(
    license_no    INTEGER
            primary key,
    dba_name      TEXT,
    aka_name      TEXT,
    facility_type TEXT,
    risk_level    INTEGER,
    address       TEXT,
    city          TEXT,
    state         TEXT,
    zip           INTEGER,
    latitude      REAL,
    longitude     REAL,
    ward          INTEGER
);
CREATE TABLE inspection
(
    inspection_id   INTEGER
            primary key,
    inspection_date DATE,
    inspection_type TEXT,
    results         TEXT,
    employee_id     INTEGER,
    license_no      INTEGER,
    followup_to     INTEGER,
    foreign key (employee_id) references employee(employee_id),
    foreign key (license_no) references establishment(license_no),
    foreign key (followup_to) references inspection(inspection_id)
);
CREATE TABLE inspection_point
(
    point_id    INTEGER
            primary key,
    Description TEXT,
    category    TEXT,
    code        TEXT,
    fine        INTEGER,
    point_level TEXT
);
CREATE TABLE violation
(
    inspection_id     INTEGER,
    point_id          INTEGER,
    fine              INTEGER,
    inspector_comment TEXT,
    primary key (inspection_id, point_id),
    foreign key (inspection_id) references inspection(inspection_id),
    foreign key (point_id) references inspection_point(point_id)
);
 | 
| 
	books | 
	What is the title of the most expensive book? | 
	most expensive book refers to Max(price) | 
	SELECT T1.title FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id ORDER BY T2.price DESC LIMIT 1 | 
	CREATE TABLE address_status
(
    status_id      INTEGER
            primary key,
    address_status TEXT
);
CREATE TABLE author
(
    author_id   INTEGER
            primary key,
    author_name TEXT
);
CREATE TABLE book_language
(
    language_id   INTEGER
            primary key,
    language_code TEXT,
    language_name TEXT
);
CREATE TABLE country
(
    country_id   INTEGER
            primary key,
    country_name TEXT
);
CREATE TABLE address
(
    address_id    INTEGER
            primary key,
    street_number TEXT,
    street_name   TEXT,
    city          TEXT,
    country_id    INTEGER,
    foreign key (country_id) references country(country_id)
);
CREATE TABLE customer
(
    customer_id INTEGER
            primary key,
    first_name  TEXT,
    last_name   TEXT,
    email       TEXT
);
CREATE TABLE customer_address
(
    customer_id INTEGER,
    address_id  INTEGER,
    status_id   INTEGER,
    primary key (customer_id, address_id),
    foreign key (address_id) references address(address_id),
    foreign key (customer_id) references customer(customer_id)
);
CREATE TABLE order_status
(
    status_id    INTEGER
            primary key,
    status_value TEXT
);
CREATE TABLE publisher
(
    publisher_id   INTEGER
            primary key,
    publisher_name TEXT
);
CREATE TABLE book
(
    book_id          INTEGER
            primary key,
    title            TEXT,
    isbn13           TEXT,
    language_id      INTEGER,
    num_pages        INTEGER,
    publication_date DATE,
    publisher_id     INTEGER,
    foreign key (language_id) references book_language(language_id),
    foreign key (publisher_id) references publisher(publisher_id)
);
CREATE TABLE book_author
(
    book_id   INTEGER,
    author_id INTEGER,
    primary key (book_id, author_id),
    foreign key (author_id) references author(author_id),
    foreign key (book_id) references book(book_id)
);
CREATE TABLE shipping_method
(
    method_id   INTEGER
            primary key,
    method_name TEXT,
    cost        REAL
);
CREATE TABLE IF NOT EXISTS "cust_order"
(
    order_id           INTEGER
        primary key autoincrement,
    order_date         DATETIME,
    customer_id        INTEGER
        references customer,
    shipping_method_id INTEGER
        references shipping_method,
    dest_address_id    INTEGER
        references address
);
CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE IF NOT EXISTS "order_history"
(
    history_id  INTEGER
        primary key autoincrement,
    order_id    INTEGER
        references cust_order,
    status_id   INTEGER
        references order_status,
    status_date DATETIME
);
CREATE TABLE IF NOT EXISTS "order_line"
(
    line_id  INTEGER
        primary key autoincrement,
    order_id INTEGER
        references cust_order,
    book_id  INTEGER
        references book,
    price    REAL
);
 | 
| 
	car_retails | 
	How many sales representitives are based in the offices in the USA? | 
	Sales representative refers to jobTitle = 'Sales Rep'; country = 'USA'; | 
	SELECT COUNT(t1.employeeNumber) FROM employees AS t1 INNER JOIN offices AS t2 ON t1.officeCode = t2.officeCode WHERE t2.country = 'USA' AND t1.jobTitle = 'Sales Rep' | 
	CREATE TABLE offices
(
    officeCode   TEXT not null
        primary key,
    city         TEXT not null,
    phone        TEXT not null,
    addressLine1 TEXT not null,
    addressLine2 TEXT,
    state        TEXT,
    country      TEXT not null,
    postalCode  TEXT not null,
    territory    TEXT not null
);
CREATE TABLE employees
(
    employeeNumber INTEGER      not null
        primary key,
    lastName       TEXT  not null,
    firstName      TEXT  not null,
    extension      TEXT  not null,
    email          TEXT not null,
    officeCode     TEXT  not null,
    reportsTo      INTEGER,
    jobTitle       TEXT  not null,
    foreign key (officeCode) references offices(officeCode),
    foreign key (reportsTo) references employees(employeeNumber)
);
CREATE TABLE customers
(
    customerNumber         INTEGER     not null
        primary key,
    customerName           TEXT not null,
    contactLastName        TEXT not null,
    contactFirstName       TEXT not null,
    phone                  TEXT not null,
    addressLine1           TEXT not null,
    addressLine2           TEXT,
    city                   TEXT not null,
    state                  TEXT,
    postalCode             TEXT,
    country                TEXT not null,
    salesRepEmployeeNumber INTEGER,
    creditLimit            REAL,
    foreign key (salesRepEmployeeNumber) references employees(employeeNumber)
);
CREATE TABLE orders
(
    orderNumber    INTEGER     not null
        primary key,
    orderDate      DATE        not null,
    requiredDate   DATE        not null,
    shippedDate    DATE,
    status         TEXT not null,
    comments       TEXT,
    customerNumber INTEGER     not null,
    foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE payments
(
    customerNumber INTEGER     not null,
    checkNumber    TEXT not null,
    paymentDate    DATE        not null,
    amount         REAL        not null,
    primary key (customerNumber, checkNumber),
    foreign key (customerNumber) references customers(customerNumber)
);
CREATE TABLE productlines
(
    productLine     TEXT not null
        primary key,
    textDescription TEXT,
    htmlDescription TEXT,
    image           BLOB
);
CREATE TABLE products
(
    productCode        TEXT not null
        primary key,
    productName        TEXT not null,
    productLine        TEXT not null,
    productScale      TEXT not null,
    productVendor      TEXT not null,
    productDescription TEXT        not null,
    quantityInStock    INTEGER     not null,
    buyPrice           REAL        not null,
    MSRP               REAL        not null,
    foreign key (productLine) references productlines(productLine)
);
CREATE TABLE IF NOT EXISTS "orderdetails"
(
    orderNumber     INTEGER not null
        references orders,
    productCode     TEXT    not null
        references products,
    quantityOrdered INTEGER not null,
    priceEach       REAL    not null,
    orderLineNumber INTEGER not null,
    primary key (orderNumber, productCode)
);
 | 
| 
	simpson_episodes | 
	What are the keywords of the episode which has title as Dangerous Curves? | 
	SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Dangerous Curves'; | 
	CREATE TABLE IF NOT EXISTS "Episode"
(
    episode_id       TEXT
        constraint Episode_pk
            primary key,
    season           INTEGER,
    episode          INTEGER,
    number_in_series INTEGER,
    title            TEXT,
    summary          TEXT,
    air_date         TEXT,
    episode_image    TEXT,
    rating           REAL,
    votes            INTEGER
);
CREATE TABLE Person
(
    name          TEXT
        constraint Person_pk
            primary key,
    birthdate     TEXT,
    birth_name    TEXT,
    birth_place   TEXT,
    birth_region  TEXT,
    birth_country TEXT,
    height_meters REAL,
    nickname      TEXT
);
CREATE TABLE Award
(
    award_id       INTEGER
            primary key,
    organization   TEXT,
    year           INTEGER,
    award_category TEXT,
    award          TEXT,
    person         TEXT,
    role           TEXT,
    episode_id     TEXT,
    season         TEXT,
    song           TEXT,
    result         TEXT,
    foreign key (person) references Person(name),
    foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Character_Award
(
    award_id  INTEGER,
    character TEXT,
    foreign key (award_id) references Award(award_id)
);
CREATE TABLE Credit
(
    episode_id TEXT,
    category   TEXT,
    person     TEXT,
    role       TEXT,
    credited   TEXT,
    foreign key (episode_id) references Episode(episode_id),
    foreign key (person) references Person(name)
);
CREATE TABLE Keyword
(
    episode_id TEXT,
    keyword    TEXT,
    primary key (episode_id, keyword),
    foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Vote
(
    episode_id TEXT,
    stars      INTEGER,
    votes      INTEGER,
    percent    REAL,
    foreign key (episode_id) references Episode(episode_id)
);
 | |
| 
	retail_world | 
	Provide the list of products ordered by ID 10979 and calculate its total payment. | 
	ordered by ID 10979 refers to OrderID = '10979'; total payment refers to SUM(MULTIPLY(UnitPrice, Quantity, SUBTRACT(1, Discount))) | 
	SELECT T1.ProductName , SUM(T2.UnitPrice * T2.Quantity * (1 - T2.Discount)) FROM Products AS T1 INNER JOIN `Order Details` AS T2 ON T1.ProductID = T2.ProductID WHERE T2.OrderID = 10979 GROUP BY T1.ProductName | 
	CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE Categories
(
    CategoryID INTEGER PRIMARY KEY AUTOINCREMENT,
    CategoryName TEXT,
    Description TEXT
);
CREATE TABLE Customers
(
    CustomerID INTEGER PRIMARY KEY AUTOINCREMENT,
    CustomerName TEXT,
    ContactName TEXT,
    Address TEXT,
    City TEXT,
    PostalCode TEXT,
    Country TEXT
);
CREATE TABLE Employees
(
    EmployeeID INTEGER PRIMARY KEY AUTOINCREMENT,
    LastName TEXT,
    FirstName TEXT,
    BirthDate DATE,
    Photo TEXT,
    Notes TEXT
);
CREATE TABLE Shippers(
    ShipperID INTEGER PRIMARY KEY AUTOINCREMENT,
    ShipperName TEXT,
    Phone TEXT
);
CREATE TABLE Suppliers(
    SupplierID INTEGER PRIMARY KEY AUTOINCREMENT,
    SupplierName TEXT,
    ContactName TEXT,
    Address TEXT,
    City TEXT,
    PostalCode TEXT,
    Country TEXT,
    Phone TEXT
);
CREATE TABLE Products(
    ProductID INTEGER PRIMARY KEY AUTOINCREMENT,
    ProductName TEXT,
    SupplierID INTEGER,
    CategoryID INTEGER,
    Unit TEXT,
    Price REAL DEFAULT 0,
	FOREIGN KEY (CategoryID) REFERENCES Categories (CategoryID),
	FOREIGN KEY (SupplierID) REFERENCES Suppliers (SupplierID)
);
CREATE TABLE Orders(
    OrderID INTEGER PRIMARY KEY AUTOINCREMENT,
    CustomerID INTEGER,
    EmployeeID INTEGER,
    OrderDate DATETIME,
    ShipperID INTEGER,
    FOREIGN KEY (EmployeeID) REFERENCES Employees (EmployeeID),
    FOREIGN KEY (CustomerID) REFERENCES Customers (CustomerID),
    FOREIGN KEY (ShipperID) REFERENCES Shippers (ShipperID)
);
CREATE TABLE OrderDetails(
    OrderDetailID INTEGER PRIMARY KEY AUTOINCREMENT,
    OrderID INTEGER,
    ProductID INTEGER,
    Quantity INTEGER,
	FOREIGN KEY (OrderID) REFERENCES Orders (OrderID),
	FOREIGN KEY (ProductID) REFERENCES Products (ProductID)
);
 | 
| 
	menu | 
	Which dish has the longest history? | 
	longest history refers to MAX(SUBTRACT(last_appeared, first_appeared)); | 
	SELECT name FROM Dish ORDER BY last_appeared - Dish.first_appeared DESC LIMIT 1 | 
	CREATE TABLE Dish
(
    id             INTEGER
            primary key,
    name           TEXT,
    description    TEXT,
    menus_appeared INTEGER,
    times_appeared INTEGER,
    first_appeared INTEGER,
    last_appeared  INTEGER,
    lowest_price   REAL,
    highest_price  REAL
);
CREATE TABLE Menu
(
    id                   INTEGER
            primary key,
    name                 TEXT,
    sponsor              TEXT,
    event                TEXT,
    venue                TEXT,
    place                TEXT,
    physical_description TEXT,
    occasion             TEXT,
    notes                TEXT,
    call_number          TEXT,
    keywords             TEXT,
    language             TEXT,
    date                 DATE,
    location             TEXT,
    location_type        TEXT,
    currency             TEXT,
    currency_symbol      TEXT,
    status               TEXT,
    page_count           INTEGER,
    dish_count           INTEGER
);
CREATE TABLE MenuPage
(
    id          INTEGER
            primary key,
    menu_id     INTEGER,
    page_number INTEGER,
    image_id    REAL,
    full_height INTEGER,
    full_width  INTEGER,
    uuid        TEXT,
    foreign key (menu_id) references Menu(id)
);
CREATE TABLE MenuItem
(
    id           INTEGER
            primary key,
    menu_page_id INTEGER,
    price        REAL,
    high_price   REAL,
    dish_id      INTEGER,
    created_at   TEXT,
    updated_at   TEXT,
    xpos         REAL,
    ypos         REAL,
    foreign key (dish_id) references Dish(id),
    foreign key (menu_page_id) references MenuPage(id)
);
 | 
| 
	works_cycles | 
	What is the total profit gained by the company from the product that has the highest amount of quantity ordered from online customers? Indicate the name of the product. | 
	profit = MULTIPLY(SUBTRACT(ListPrice, Standardcost)), (Quantity))); | 
	SELECT (T2.ListPrice - T2.StandardCost) * SUM(T1.Quantity), T2.Name FROM ShoppingCartItem AS T1 INNER JOIN Product AS T2 ON T1.ProductID = T2.ProductID GROUP BY T1.ProductID, T2.Name, T2.ListPrice, T2.StandardCost, T1.Quantity ORDER BY SUM(T1.Quantity) DESC LIMIT 1 | 
	CREATE TABLE sqlite_sequence(name,seq);
CREATE TABLE CountryRegion
(
    CountryRegionCode TEXT                          not null
        primary key,
    Name              TEXT                        not null
            unique,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE Culture
(
    CultureID    TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE Currency
(
    CurrencyCode TEXT                             not null
        primary key,
    Name         TEXT                        not null
            unique,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE CountryRegionCurrency
(
    CountryRegionCode TEXT                          not null,
    CurrencyCode      TEXT                             not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    primary key (CountryRegionCode, CurrencyCode),
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode),
    foreign key (CurrencyCode) references Currency(CurrencyCode)
);
CREATE TABLE Person
(
    BusinessEntityID      INTEGER                                  not null
        primary key,
    PersonType            TEXT                              not null,
    NameStyle             INTEGER default 0                 not null,
    Title                 TEXT,
    FirstName             TEXT                         not null,
    MiddleName            TEXT,
    LastName              TEXT                         not null,
    Suffix                TEXT,
    EmailPromotion        INTEGER        default 0                 not null,
    AdditionalContactInfo TEXT,
    Demographics          TEXT,
    rowguid               TEXT                          not null
            unique,
    ModifiedDate          DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE BusinessEntityContact
(
    BusinessEntityID INTEGER                                 not null,
    PersonID         INTEGER                                 not null,
    ContactTypeID    INTEGER                                 not null,
    rowguid         TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, PersonID, ContactTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (ContactTypeID) references ContactType(ContactTypeID),
    foreign key (PersonID) references Person(BusinessEntityID)
);
CREATE TABLE EmailAddress
(
    BusinessEntityID INTEGER                                 not null,
    EmailAddressID   INTEGER,
    EmailAddress     TEXT,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (EmailAddressID, BusinessEntityID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Employee
(
    BusinessEntityID  INTEGER                                 not null
        primary key,
    NationalIDNumber  TEXT                          not null
            unique,
    LoginID           TEXT                         not null
            unique,
    OrganizationNode  TEXT,
    OrganizationLevel INTEGER,
    JobTitle          TEXT                          not null,
    BirthDate         DATE                                 not null,
    MaritalStatus     TEXT                                 not null,
    Gender            TEXT                                 not null,
    HireDate          DATE                                 not null,
    SalariedFlag      INTEGER default 1                 not null,
    VacationHours     INTEGER   default 0                 not null,
    SickLeaveHours    INTEGER   default 0                 not null,
    CurrentFlag       INTEGER default 1                 not null,
    rowguid           TEXT                          not null
            unique,
    ModifiedDate      DATETIME  default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE Password
(
    BusinessEntityID INTEGER                                 not null
        primary key,
    PasswordHash     TEXT                        not null,
    PasswordSalt     TEXT                         not null,
    rowguid          TEXT                         not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE PersonCreditCard
(
    BusinessEntityID INTEGER                                 not null,
    CreditCardID     INTEGER                                 not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, CreditCardID),
    foreign key (CreditCardID) references CreditCard(CreditCardID),
    foreign key (BusinessEntityID) references Person(BusinessEntityID)
);
CREATE TABLE ProductCategory
(
    ProductCategoryID INTEGER
        primary key autoincrement,
    Name              TEXT                        not null
        unique,
    rowguid           TEXT                         not null
        unique,
    ModifiedDate      DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductDescription
(
    ProductDescriptionID INTEGER
        primary key autoincrement,
    Description          TEXT                        not null,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModel
(
    ProductModelID     INTEGER
        primary key autoincrement,
    Name               TEXT                        not null
        unique,
    CatalogDescription TEXT,
    Instructions       TEXT,
    rowguid            TEXT                         not null
        unique,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductModelProductDescriptionCulture
(
    ProductModelID       INTEGER                             not null,
    ProductDescriptionID INTEGER                             not null,
    CultureID            TEXT                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductModelID, ProductDescriptionID, CultureID),
    foreign key (ProductModelID) references ProductModel(ProductModelID),
    foreign key (ProductDescriptionID) references ProductDescription(ProductDescriptionID),
    foreign key (CultureID) references Culture(CultureID)
);
CREATE TABLE ProductPhoto
(
    ProductPhotoID         INTEGER
        primary key autoincrement,
    ThumbNailPhoto         BLOB,
    ThumbnailPhotoFileName TEXT,
    LargePhoto             BLOB,
    LargePhotoFileName     TEXT,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductSubcategory
(
    ProductSubcategoryID INTEGER
        primary key autoincrement,
    ProductCategoryID    INTEGER                             not null,
    Name                 TEXT                        not null
        unique,
    rowguid              TEXT                         not null
        unique,
    ModifiedDate        DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductCategoryID) references ProductCategory(ProductCategoryID)
);
CREATE TABLE SalesReason
(
    SalesReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null,
    ReasonType    TEXT                        not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE SalesTerritory
(
    TerritoryID       INTEGER
        primary key autoincrement,
    Name              TEXT                             not null
        unique,
    CountryRegionCode TEXT                               not null,
    "Group"           TEXT                              not null,
    SalesYTD          REAL default 0.0000            not null,
    SalesLastYear     REAL default 0.0000            not null,
    CostYTD           REAL default 0.0000            not null,
    CostLastYear      REAL default 0.0000            not null,
    rowguid           TEXT                              not null
        unique,
    ModifiedDate      DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (CountryRegionCode) references CountryRegion(CountryRegionCode)
);
CREATE TABLE SalesPerson
(
    BusinessEntityID INTEGER                                  not null
        primary key,
    TerritoryID      INTEGER,
    SalesQuota       REAL,
    Bonus            REAL default 0.0000            not null,
    CommissionPct    REAL default 0.0000            not null,
    SalesYTD         REAL default 0.0000            not null,
    SalesLastYear    REAL default 0.0000            not null,
    rowguid          TEXT                              not null
        unique,
    ModifiedDate     DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references Employee(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE SalesPersonQuotaHistory
(
    BusinessEntityID INTEGER                             not null,
    QuotaDate        DATETIME                            not null,
    SalesQuota       REAL                      not null,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, QuotaDate),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesTerritoryHistory
(
    BusinessEntityID INTEGER                             not null,
    TerritoryID      INTEGER                             not null,
    StartDate        DATETIME                            not null,
    EndDate          DATETIME,
    rowguid          TEXT                         not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (BusinessEntityID, StartDate, TerritoryID),
    foreign key (BusinessEntityID) references SalesPerson(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID)
);
CREATE TABLE ScrapReason
(
    ScrapReasonID INTEGER
        primary key autoincrement,
    Name          TEXT                        not null
        unique,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE Shift
(
    ShiftID      INTEGER
        primary key autoincrement,
    Name         TEXT                        not null
        unique,
    StartTime    TEXT                                not null,
    EndTime      TEXT                                not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    unique (StartTime, EndTime)
);
CREATE TABLE ShipMethod
(
    ShipMethodID INTEGER
        primary key autoincrement,
    Name         TEXT                             not null
        unique,
    ShipBase     REAL default 0.0000            not null,
    ShipRate    REAL default 0.0000            not null,
    rowguid      TEXT                              not null
        unique,
    ModifiedDate DATETIME      default CURRENT_TIMESTAMP not null
);
CREATE TABLE SpecialOffer
(
    SpecialOfferID INTEGER
        primary key autoincrement,
    Description    TEXT                             not null,
    DiscountPct    REAL   default 0.0000            not null,
    Type           TEXT                             not null,
    Category       TEXT                             not null,
    StartDate      DATETIME                            not null,
    EndDate        DATETIME                            not null,
    MinQty         INTEGER   default 0                 not null,
    MaxQty         INTEGER,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE BusinessEntityAddress
(
    BusinessEntityID INTEGER                                 not null,
    AddressID        INTEGER                                 not null,
    AddressTypeID    INTEGER                                 not null,
    rowguid          TEXT                         not null
            unique,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, AddressID, AddressTypeID),
    foreign key (AddressID) references Address(AddressID),
    foreign key (AddressTypeID) references AddressType(AddressTypeID),
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE SalesTaxRate
(
    SalesTaxRateID  INTEGER
        primary key autoincrement,
    StateProvinceID INTEGER                                  not null,
    TaxType         INTEGER                                  not null,
    TaxRate         REAL default 0.0000            not null,
    Name            TEXT                             not null,
    rowguid         TEXT                              not null
        unique,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    unique (StateProvinceID, TaxType),
    foreign key (StateProvinceID) references StateProvince(StateProvinceID)
);
CREATE TABLE Store
(
    BusinessEntityID INTEGER                             not null
        primary key,
    Name             TEXT                        not null,
    SalesPersonID    INTEGER,
    Demographics     TEXT,
    rowguid          TEXT                             not null
        unique,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID),
    foreign key (SalesPersonID) references SalesPerson(BusinessEntityID)
);
CREATE TABLE SalesOrderHeaderSalesReason
(
    SalesOrderID  INTEGER                             not null,
    SalesReasonID INTEGER                             not null,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SalesOrderID, SalesReasonID),
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SalesReasonID) references SalesReason(SalesReasonID)
);
CREATE TABLE TransactionHistoryArchive
(
    TransactionID        INTEGER                             not null
        primary key,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE UnitMeasure
(
    UnitMeasureCode TEXT                             not null
        primary key,
    Name            TEXT                        not null
        unique,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null
);
CREATE TABLE ProductCostHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    StandardCost REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ProductDocument
(
    ProductID    INTEGER                             not null,
    DocumentNode TEXT                        not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, DocumentNode),
    foreign key (ProductID) references Product(ProductID),
    foreign key (DocumentNode) references Document(DocumentNode)
);
CREATE TABLE ProductInventory
(
    ProductID    INTEGER                             not null,
    LocationID   INTEGER                            not null,
    Shelf        TEXT                         not null,
    Bin          INTEGER                             not null,
    Quantity     INTEGER  default 0                 not null,
    rowguid      TEXT                         not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, LocationID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE ProductProductPhoto
(
    ProductID      INTEGER                             not null,
    ProductPhotoID INTEGER                             not null,
    "Primary"      INTEGER   default 0                 not null,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, ProductPhotoID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (ProductPhotoID) references ProductPhoto(ProductPhotoID)
);
CREATE TABLE ProductReview
(
    ProductReviewID INTEGER
        primary key autoincrement,
    ProductID       INTEGER                             not null,
    ReviewerName   TEXT                        not null,
    ReviewDate      DATETIME default CURRENT_TIMESTAMP not null,
    EmailAddress    TEXT                         not null,
    Rating          INTEGER                             not null,
    Comments        TEXT,
    ModifiedDate    DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE ShoppingCartItem
(
    ShoppingCartItemID INTEGER
        primary key autoincrement,
    ShoppingCartID     TEXT                         not null,
    Quantity           INTEGER   default 1                 not null,
    ProductID          INTEGER                             not null,
    DateCreated        DATETIME default CURRENT_TIMESTAMP not null,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SpecialOfferProduct
(
    SpecialOfferID INTEGER                             not null,
    ProductID      INTEGER                             not null,
    rowguid        TEXT                             not null
        unique,
    ModifiedDate   DATETIME default CURRENT_TIMESTAMP not null,
    primary key (SpecialOfferID, ProductID),
    foreign key (SpecialOfferID) references SpecialOffer(SpecialOfferID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE SalesOrderDetail
(
    SalesOrderID          INTEGER                             not null,
    SalesOrderDetailID    INTEGER
        primary key autoincrement,
    CarrierTrackingNumber TEXT,
    OrderQty              INTEGER                             not null,
    ProductID             INTEGER                             not null,
    SpecialOfferID        INTEGER                             not null,
    UnitPrice             REAL                             not null,
    UnitPriceDiscount     REAL   default 0.0000            not null,
    LineTotal             REAL                             not null,
    rowguid               TEXT                             not null
        unique,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (SalesOrderID) references SalesOrderHeader(SalesOrderID),
    foreign key (SpecialOfferID, ProductID) references SpecialOfferProduct(SpecialOfferID, ProductID)
);
CREATE TABLE TransactionHistory
(
    TransactionID        INTEGER
        primary key autoincrement,
    ProductID            INTEGER                             not null,
    ReferenceOrderID     INTEGER                             not null,
    ReferenceOrderLineID INTEGER   default 0                 not null,
    TransactionDate      DATETIME default CURRENT_TIMESTAMP not null,
    TransactionType      TEXT                                not null,
    Quantity             INTEGER                             not null,
    ActualCost           REAL                             not null,
    ModifiedDate         DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE Vendor
(
    BusinessEntityID        INTEGER                             not null
        primary key,
    AccountNumber           TEXT                         not null
        unique,
    Name                    TEXT                        not null,
    CreditRating            INTEGER                             not null,
    PreferredVendorStatus   INTEGER   default 1                 not null,
    ActiveFlag              INTEGER   default 1                 not null,
    PurchasingWebServiceURL TEXT,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (BusinessEntityID) references BusinessEntity(BusinessEntityID)
);
CREATE TABLE ProductVendor
(
    ProductID        INTEGER                             not null,
    BusinessEntityID INTEGER                             not null,
    AverageLeadTime  INTEGER                             not null,
    StandardPrice    REAL                      not null,
    LastReceiptCost  REAL,
    LastReceiptDate  DATETIME,
    MinOrderQty      INTEGER                             not null,
    MaxOrderQty      INTEGER                             not null,
    OnOrderQty       INTEGER,
    UnitMeasureCode  TEXT                             not null,
    ModifiedDate     DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, BusinessEntityID),
    foreign key (ProductID) references Product(ProductID),
    foreign key (BusinessEntityID) references Vendor(BusinessEntityID),
    foreign key (UnitMeasureCode) references UnitMeasure(UnitMeasureCode)
);
CREATE TABLE PurchaseOrderHeader
(
    PurchaseOrderID INTEGER
        primary key autoincrement,
    RevisionNumber  INTEGER        default 0                 not null,
    Status          INTEGER        default 1                 not null,
    EmployeeID      INTEGER                                  not null,
    VendorID        INTEGER                                  not null,
    ShipMethodID    INTEGER                                  not null,
    OrderDate       DATETIME      default CURRENT_TIMESTAMP not null,
    ShipDate        DATETIME,
    SubTotal        REAL default 0.0000            not null,
    TaxAmt          REAL default 0.0000            not null,
    Freight         REAL default 0.0000            not null,
    TotalDue        REAL                          not null,
    ModifiedDate    DATETIME      default CURRENT_TIMESTAMP not null,
    foreign key (EmployeeID) references Employee(BusinessEntityID),
    foreign key (VendorID) references Vendor(BusinessEntityID),
    foreign key (ShipMethodID) references ShipMethod(ShipMethodID)
);
CREATE TABLE PurchaseOrderDetail
(
    PurchaseOrderID       INTEGER                            not null,
    PurchaseOrderDetailID INTEGER
        primary key autoincrement,
    DueDate               DATETIME                           not null,
    OrderQty              INTEGER                           not null,
    ProductID             INTEGER                            not null,
    UnitPrice             REAL                            not null,
    LineTotal             REAL                            not null,
    ReceivedQty           REAL                            not null,
    RejectedQty           REAL                            not null,
    StockedQty            REAL                            not null,
    ModifiedDate          DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (PurchaseOrderID) references PurchaseOrderHeader(PurchaseOrderID),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE WorkOrder
(
    WorkOrderID   INTEGER
        primary key autoincrement,
    ProductID     INTEGER                             not null,
    OrderQty      INTEGER                             not null,
    StockedQty    INTEGER                             not null,
    ScrappedQty   INTEGER                           not null,
    StartDate     DATETIME                            not null,
    EndDate       DATETIME,
    DueDate       DATETIME                            not null,
    ScrapReasonID INTEGER,
    ModifiedDate  DATETIME default CURRENT_TIMESTAMP not null,
    foreign key (ProductID) references Product(ProductID),
    foreign key (ScrapReasonID) references ScrapReason(ScrapReasonID)
);
CREATE TABLE WorkOrderRouting
(
    WorkOrderID        INTEGER                             not null,
    ProductID          INTEGER                             not null,
    OperationSequence  INTEGER                             not null,
    LocationID         INTEGER                             not null,
    ScheduledStartDate DATETIME                            not null,
    ScheduledEndDate   DATETIME                            not null,
    ActualStartDate    DATETIME,
    ActualEndDate      DATETIME,
    ActualResourceHrs  REAL,
    PlannedCost        REAL                      not null,
    ActualCost         REAL,
    ModifiedDate       DATETIME default CURRENT_TIMESTAMP not null,
    primary key (WorkOrderID, ProductID, OperationSequence),
    foreign key (WorkOrderID) references WorkOrder(WorkOrderID),
    foreign key (LocationID) references Location(LocationID)
);
CREATE TABLE Customer
(
    CustomerID    INTEGER
        primary key,
    PersonID      INTEGER,
    StoreID       INTEGER,
    TerritoryID   INTEGER,
    AccountNumber TEXT                         not null
            unique,
    rowguid       TEXT                         not null
            unique,
    ModifiedDate  DATETIME default current_timestamp not null,
    foreign key (PersonID) references Person(BusinessEntityID),
    foreign key (TerritoryID) references SalesTerritory(TerritoryID),
    foreign key (StoreID) references Store(BusinessEntityID)
);
CREATE TABLE ProductListPriceHistory
(
    ProductID    INTEGER                             not null,
    StartDate    DATE                                not null,
    EndDate      DATE,
    ListPrice    REAL                      not null,
    ModifiedDate DATETIME default CURRENT_TIMESTAMP not null,
    primary key (ProductID, StartDate),
    foreign key (ProductID) references Product(ProductID)
);
CREATE TABLE IF NOT EXISTS "Address"
(
    AddressID       INTEGER
        primary key autoincrement,
    AddressLine1    TEXT                               not null,
    AddressLine2    TEXT,
    City            TEXT                               not null,
    StateProvinceID INTEGER                            not null
        references StateProvince,
    PostalCode      TEXT                               not null,
    SpatialLocation TEXT,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (AddressLine1, AddressLine2, City, StateProvinceID, PostalCode)
);
CREATE TABLE IF NOT EXISTS "AddressType"
(
    AddressTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    rowguid       TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "BillOfMaterials"
(
    BillOfMaterialsID INTEGER
        primary key autoincrement,
    ProductAssemblyID INTEGER
        references Product,
    ComponentID       INTEGER                            not null
        references Product,
    StartDate         DATETIME default current_timestamp not null,
    EndDate           DATETIME,
    UnitMeasureCode   TEXT                               not null
        references UnitMeasure,
    BOMLevel          INTEGER                            not null,
    PerAssemblyQty    REAL     default 1.00              not null,
    ModifiedDate      DATETIME default current_timestamp not null,
    unique (ProductAssemblyID, ComponentID, StartDate)
);
CREATE TABLE IF NOT EXISTS "BusinessEntity"
(
    BusinessEntityID INTEGER
        primary key autoincrement,
    rowguid          TEXT                               not null
        unique,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "ContactType"
(
    ContactTypeID INTEGER
        primary key autoincrement,
    Name          TEXT                               not null
        unique,
    ModifiedDate  DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "CurrencyRate"
(
    CurrencyRateID   INTEGER
        primary key autoincrement,
    CurrencyRateDate DATETIME                           not null,
    FromCurrencyCode TEXT                               not null
        references Currency,
    ToCurrencyCode   TEXT                               not null
        references Currency,
    AverageRate      REAL                               not null,
    EndOfDayRate     REAL                               not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    unique (CurrencyRateDate, FromCurrencyCode, ToCurrencyCode)
);
CREATE TABLE IF NOT EXISTS "Department"
(
    DepartmentID INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    GroupName    TEXT                               not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "EmployeeDepartmentHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    DepartmentID     INTEGER                            not null
        references Department,
    ShiftID          INTEGER                            not null
        references Shift,
    StartDate        DATE                               not null,
    EndDate          DATE,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, StartDate, DepartmentID, ShiftID)
);
CREATE TABLE IF NOT EXISTS "EmployeePayHistory"
(
    BusinessEntityID INTEGER                            not null
        references Employee,
    RateChangeDate   DATETIME                           not null,
    Rate             REAL                               not null,
    PayFrequency     INTEGER                            not null,
    ModifiedDate     DATETIME default current_timestamp not null,
    primary key (BusinessEntityID, RateChangeDate)
);
CREATE TABLE IF NOT EXISTS "JobCandidate"
(
    JobCandidateID   INTEGER
        primary key autoincrement,
    BusinessEntityID INTEGER
        references Employee,
    Resume           TEXT,
    ModifiedDate     DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Location"
(
    LocationID   INTEGER
        primary key autoincrement,
    Name         TEXT                               not null
        unique,
    CostRate     REAL     default 0.0000            not null,
    Availability REAL     default 0.00              not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "PhoneNumberType"
(
    PhoneNumberTypeID INTEGER
        primary key autoincrement,
    Name              TEXT                               not null,
    ModifiedDate      DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Product"
(
    ProductID             INTEGER
        primary key autoincrement,
    Name                  TEXT                               not null
        unique,
    ProductNumber         TEXT                               not null
        unique,
    MakeFlag              INTEGER  default 1                 not null,
    FinishedGoodsFlag     INTEGER  default 1                 not null,
    Color                 TEXT,
    SafetyStockLevel      INTEGER                            not null,
    ReorderPoint          INTEGER                            not null,
    StandardCost          REAL                               not null,
    ListPrice             REAL                               not null,
    Size                  TEXT,
    SizeUnitMeasureCode   TEXT
        references UnitMeasure,
    WeightUnitMeasureCode TEXT
        references UnitMeasure,
    Weight                REAL,
    DaysToManufacture     INTEGER                            not null,
    ProductLine           TEXT,
    Class                 TEXT,
    Style                 TEXT,
    ProductSubcategoryID  INTEGER
        references ProductSubcategory,
    ProductModelID        INTEGER
        references ProductModel,
    SellStartDate         DATETIME                           not null,
    SellEndDate           DATETIME,
    DiscontinuedDate      DATETIME,
    rowguid               TEXT                               not null
        unique,
    ModifiedDate          DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "Document"
(
    DocumentNode    TEXT                               not null
        primary key,
    DocumentLevel   INTEGER,
    Title           TEXT                               not null,
    Owner           INTEGER                            not null
        references Employee,
    FolderFlag      INTEGER  default 0                 not null,
    FileName        TEXT                               not null,
    FileExtension   TEXT                               not null,
    Revision        TEXT                               not null,
    ChangeNumber    INTEGER  default 0                 not null,
    Status          INTEGER                            not null,
    DocumentSummary TEXT,
    Document        BLOB,
    rowguid         TEXT                               not null
        unique,
    ModifiedDate    DATETIME default current_timestamp not null,
    unique (DocumentLevel, DocumentNode)
);
CREATE TABLE IF NOT EXISTS "StateProvince"
(
    StateProvinceID         INTEGER
        primary key autoincrement,
    StateProvinceCode       TEXT                               not null,
    CountryRegionCode       TEXT                               not null
        references CountryRegion,
    IsOnlyStateProvinceFlag INTEGER  default 1                 not null,
    Name                    TEXT                               not null
        unique,
    TerritoryID             INTEGER                            not null
        references SalesTerritory,
    rowguid                 TEXT                               not null
        unique,
    ModifiedDate            DATETIME default CURRENT_TIMESTAMP not null,
    unique (StateProvinceCode, CountryRegionCode)
);
CREATE TABLE IF NOT EXISTS "CreditCard"
(
    CreditCardID INTEGER
        primary key autoincrement,
    CardType     TEXT                               not null,
    CardNumber   TEXT                               not null
        unique,
    ExpMonth     INTEGER                            not null,
    ExpYear      INTEGER                            not null,
    ModifiedDate DATETIME default current_timestamp not null
);
CREATE TABLE IF NOT EXISTS "SalesOrderHeader"
(
    SalesOrderID           INTEGER
        primary key autoincrement,
    RevisionNumber         INTEGER  default 0                 not null,
    OrderDate              DATETIME default CURRENT_TIMESTAMP not null,
    DueDate                DATETIME                           not null,
    ShipDate               DATETIME,
    Status                 INTEGER  default 1                 not null,
    OnlineOrderFlag        INTEGER  default 1                 not null,
    SalesOrderNumber       TEXT                               not null
        unique,
    PurchaseOrderNumber    TEXT,
    AccountNumber          TEXT,
    CustomerID             INTEGER                            not null
        references Customer,
    SalesPersonID          INTEGER
        references SalesPerson,
    TerritoryID            INTEGER
        references SalesTerritory,
    BillToAddressID        INTEGER                            not null
        references Address,
    ShipToAddressID        INTEGER                            not null
        references Address,
    ShipMethodID           INTEGER                            not null
        references Address,
    CreditCardID           INTEGER
        references CreditCard,
    CreditCardApprovalCode TEXT,
    CurrencyRateID         INTEGER
        references CurrencyRate,
    SubTotal               REAL     default 0.0000            not null,
    TaxAmt                 REAL     default 0.0000            not null,
    Freight                REAL     default 0.0000            not null,
    TotalDue               REAL                               not null,
    Comment                TEXT,
    rowguid                TEXT                               not null
        unique,
    ModifiedDate           DATETIME default CURRENT_TIMESTAMP not null
);
 | 
| 
	mondial_geo | 
	Which Asian country gave its agricultural sector the largest share of its gross domestic product? | 
	Gross domestic product = GDP; Largest share of GDP in agricultural sector was mentioned in economy.Agriculture | 
	SELECT T2.Country FROM continent AS T1 INNER JOIN encompasses AS T2 ON T1.Name = T2.Continent INNER JOIN country AS T3 ON T2.Country = T3.Code INNER JOIN economy AS T4 ON T4.Country = T3.Code WHERE T1.Name = 'Asia' ORDER BY T4.Agriculture DESC LIMIT 1 | 
	CREATE TABLE IF NOT EXISTS "borders"
(
    Country1 TEXT default '' not null
        constraint borders_ibfk_1
            references country,
    Country2 TEXT default '' not null
        constraint borders_ibfk_2
            references country,
    Length   REAL,
    primary key (Country1, Country2)
);
CREATE TABLE IF NOT EXISTS "city"
(
    Name       TEXT default '' not null,
    Country    TEXT default '' not null
        constraint city_ibfk_1
            references country
            on update cascade on delete cascade,
    Province   TEXT default '' not null,
    Population INTEGER,
    Longitude  REAL,
    Latitude   REAL,
    primary key (Name, Province),
    constraint city_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "continent"
(
    Name TEXT default '' not null
        primary key,
    Area REAL
);
CREATE TABLE IF NOT EXISTS "country"
(
    Name       TEXT            not null
        constraint ix_county_Name
            unique,
    Code       TEXT default '' not null
        primary key,
    Capital    TEXT,
    Province   TEXT,
    Area       REAL,
    Population INTEGER
);
CREATE TABLE IF NOT EXISTS "desert"
(
    Name      TEXT default '' not null
        primary key,
    Area      REAL,
    Longitude REAL,
    Latitude  REAL
);
CREATE TABLE IF NOT EXISTS "economy"
(
    Country     TEXT default '' not null
        primary key
        constraint economy_ibfk_1
            references country
            on update cascade on delete cascade,
    GDP         REAL,
    Agriculture REAL,
    Service     REAL,
    Industry    REAL,
    Inflation   REAL
);
CREATE TABLE IF NOT EXISTS "encompasses"
(
    Country    TEXT not null
        constraint encompasses_ibfk_1
            references country
            on update cascade on delete cascade,
    Continent  TEXT not null
        constraint encompasses_ibfk_2
            references continent
            on update cascade on delete cascade,
    Percentage REAL,
    primary key (Country, Continent)
);
CREATE TABLE IF NOT EXISTS "ethnicGroup"
(
    Country    TEXT default '' not null
        constraint ethnicGroup_ibfk_1
            references country
            on update cascade on delete cascade,
    Name       TEXT default '' not null,
    Percentage REAL,
    primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "geo_desert"
(
    Desert   TEXT default '' not null
        constraint geo_desert_ibfk_3
            references desert
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_desert_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Desert),
    constraint geo_desert_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_estuary"
(
    River    TEXT default '' not null
        constraint geo_estuary_ibfk_3
            references river
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_estuary_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, River),
    constraint geo_estuary_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_island"
(
    Island   TEXT default '' not null
        constraint geo_island_ibfk_3
            references island
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_island_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Island),
    constraint geo_island_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_lake"
(
    Lake     TEXT default '' not null
        constraint geo_lake_ibfk_3
            references lake
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_lake_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Lake),
    constraint geo_lake_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_mountain"
(
    Mountain TEXT default '' not null
        constraint geo_mountain_ibfk_3
            references mountain
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_mountain_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Mountain),
    constraint geo_mountain_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_river"
(
    River    TEXT default '' not null
        constraint geo_river_ibfk_3
            references river
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_river_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, River),
    constraint geo_river_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_sea"
(
    Sea      TEXT default '' not null
        constraint geo_sea_ibfk_3
            references sea
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_sea_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Sea),
    constraint geo_sea_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_source"
(
    River    TEXT default '' not null
        constraint geo_source_ibfk_3
            references river
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_source_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, River),
    constraint geo_source_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "island"
(
    Name      TEXT default '' not null
        primary key,
    Islands   TEXT,
    Area      REAL,
    Height    REAL,
    Type      TEXT,
    Longitude REAL,
    Latitude  REAL
);
CREATE TABLE IF NOT EXISTS "islandIn"
(
    Island TEXT
        constraint islandIn_ibfk_4
            references island
            on update cascade on delete cascade,
    Sea    TEXT
        constraint islandIn_ibfk_3
            references sea
            on update cascade on delete cascade,
    Lake   TEXT
        constraint islandIn_ibfk_1
            references lake
            on update cascade on delete cascade,
    River  TEXT
        constraint islandIn_ibfk_2
            references river
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "isMember"
(
    Country      TEXT default '' not null
        constraint isMember_ibfk_1
            references country
            on update cascade on delete cascade,
    Organization TEXT default '' not null
        constraint isMember_ibfk_2
            references organization
            on update cascade on delete cascade,
    Type         TEXT default 'member',
    primary key (Country, Organization)
);
CREATE TABLE IF NOT EXISTS "lake"
(
    Name      TEXT default '' not null
        primary key,
    Area      REAL,
    Depth     REAL,
    Altitude  REAL,
    Type      TEXT,
    River     TEXT,
    Longitude REAL,
    Latitude  REAL
);
CREATE TABLE IF NOT EXISTS "language"
(
    Country    TEXT default '' not null
        constraint language_ibfk_1
            references country
            on update cascade on delete cascade,
    Name       TEXT default '' not null,
    Percentage REAL,
    primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "located"
(
    City     TEXT,
    Province TEXT,
    Country  TEXT
        constraint located_ibfk_1
            references country
            on update cascade on delete cascade,
    River    TEXT
        constraint located_ibfk_3
            references river
            on update cascade on delete cascade,
    Lake     TEXT
        constraint located_ibfk_4
            references lake
            on update cascade on delete cascade,
    Sea      TEXT
        constraint located_ibfk_5
            references sea
            on update cascade on delete cascade,
    constraint located_ibfk_2
        foreign key (City, Province) references city
            on update cascade on delete cascade,
    constraint located_ibfk_6
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "locatedOn"
(
    City     TEXT default '' not null,
    Province TEXT default '' not null,
    Country  TEXT default '' not null
        constraint locatedOn_ibfk_1
            references country
            on update cascade on delete cascade,
    Island   TEXT default '' not null
        constraint locatedOn_ibfk_2
            references island
            on update cascade on delete cascade,
    primary key (City, Province, Country, Island),
    constraint locatedOn_ibfk_3
        foreign key (City, Province) references city
            on update cascade on delete cascade,
    constraint locatedOn_ibfk_4
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "mergesWith"
(
    Sea1 TEXT default '' not null
        constraint mergesWith_ibfk_1
            references sea
            on update cascade on delete cascade,
    Sea2 TEXT default '' not null
        constraint mergesWith_ibfk_2
            references sea
            on update cascade on delete cascade,
    primary key (Sea1, Sea2)
);
CREATE TABLE IF NOT EXISTS "mountain"
(
    Name      TEXT default '' not null
        primary key,
    Mountains TEXT,
    Height    REAL,
    Type      TEXT,
    Longitude REAL,
    Latitude  REAL
);
CREATE TABLE IF NOT EXISTS "mountainOnIsland"
(
    Mountain TEXT default '' not null
        constraint mountainOnIsland_ibfk_2
            references mountain
            on update cascade on delete cascade,
    Island   TEXT default '' not null
        constraint mountainOnIsland_ibfk_1
            references island
            on update cascade on delete cascade,
    primary key (Mountain, Island)
);
CREATE TABLE IF NOT EXISTS "organization"
(
    Abbreviation TEXT not null
        primary key,
    Name         TEXT not null
        constraint ix_organization_OrgNameUnique
            unique,
    City         TEXT,
    Country      TEXT
        constraint organization_ibfk_1
            references country
            on update cascade on delete cascade,
    Province     TEXT,
    Established  DATE,
    constraint organization_ibfk_2
        foreign key (City, Province) references city
            on update cascade on delete cascade,
    constraint organization_ibfk_3
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "politics"
(
    Country      TEXT default '' not null
        primary key
        constraint politics_ibfk_1
            references country
            on update cascade on delete cascade,
    Independence DATE,
    Dependent    TEXT
        constraint politics_ibfk_2
            references country
            on update cascade on delete cascade,
    Government   TEXT
);
CREATE TABLE IF NOT EXISTS "population"
(
    Country           TEXT default '' not null
        primary key
        constraint population_ibfk_1
            references country
            on update cascade on delete cascade,
    Population_Growth REAL,
    Infant_Mortality  REAL
);
CREATE TABLE IF NOT EXISTS "province"
(
    Name       TEXT not null,
    Country    TEXT not null
        constraint province_ibfk_1
            references country
            on update cascade on delete cascade,
    Population INTEGER,
    Area       REAL,
    Capital    TEXT,
    CapProv    TEXT,
    primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "religion"
(
    Country    TEXT default '' not null
        constraint religion_ibfk_1
            references country
            on update cascade on delete cascade,
    Name       TEXT default '' not null,
    Percentage REAL,
    primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "river"
(
    Name             TEXT default '' not null
        primary key,
    River            TEXT,
    Lake             TEXT
        constraint river_ibfk_1
            references lake
            on update cascade on delete cascade,
    Sea              TEXT,
    Length           REAL,
    SourceLongitude  REAL,
    SourceLatitude   REAL,
    Mountains        TEXT,
    SourceAltitude   REAL,
    EstuaryLongitude REAL,
    EstuaryLatitude  REAL
);
CREATE TABLE IF NOT EXISTS "sea"
(
    Name  TEXT default '' not null
        primary key,
    Depth REAL
);
CREATE TABLE IF NOT EXISTS "target"
(
    Country TEXT not null
        primary key
        constraint target_Country_fkey
            references country
            on update cascade on delete cascade,
    Target  TEXT
);
 | 
| 
	student_loan | 
	How many SMC's students that absent for 7 months? | 
	SMC's students refers to school = 'smc'; absent for 7 months refers to month = 7 | 
	SELECT COUNT(T1.name) FROM enrolled AS T1 INNER JOIN longest_absense_from_school AS T2 ON T1.name = T2.name WHERE T1.school = 'smc' AND T2.month = 7 | 
	CREATE TABLE bool
(
    "name" TEXT default '' not null
        primary key
);
CREATE TABLE person
(
    "name" TEXT default '' not null
        primary key
);
CREATE TABLE disabled
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE enlist
(
    "name"  TEXT not null,
    organ TEXT not null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE filed_for_bankrupcy
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE longest_absense_from_school
(
    "name"  TEXT default '' not null
        primary key,
    "month" INTEGER       default 0  null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE male
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE no_payment_due
(
    "name" TEXT default '' not null
        primary key,
    bool TEXT             null,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade,
        foreign key (bool) references bool ("name")
            on update cascade on delete cascade
);
CREATE TABLE unemployed
(
    "name" TEXT default '' not null
        primary key,
        foreign key ("name") references person ("name")
            on update cascade on delete cascade
);
CREATE TABLE `enrolled` (
  `name` TEXT NOT NULL,
  `school` TEXT NOT NULL,
  `month` INTEGER NOT NULL DEFAULT 0,
  PRIMARY KEY (`name`,`school`),
  FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
);
 | 
| 
	mondial_geo | 
	Which city has most population other than its capital in Bangladesh? | 
	Bangladesh is a country | 
	SELECT T3.Name FROM country AS T1 INNER JOIN province AS T2 ON T1.Code = T2.Country INNER JOIN city AS T3 ON T3.Province = T2.Name WHERE T1.Name = 'Bangladesh' AND T3.Name <> T1.Capital ORDER BY T3.Population DESC LIMIT 1 | 
	CREATE TABLE IF NOT EXISTS "borders"
(
    Country1 TEXT default '' not null
        constraint borders_ibfk_1
            references country,
    Country2 TEXT default '' not null
        constraint borders_ibfk_2
            references country,
    Length   REAL,
    primary key (Country1, Country2)
);
CREATE TABLE IF NOT EXISTS "city"
(
    Name       TEXT default '' not null,
    Country    TEXT default '' not null
        constraint city_ibfk_1
            references country
            on update cascade on delete cascade,
    Province   TEXT default '' not null,
    Population INTEGER,
    Longitude  REAL,
    Latitude   REAL,
    primary key (Name, Province),
    constraint city_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "continent"
(
    Name TEXT default '' not null
        primary key,
    Area REAL
);
CREATE TABLE IF NOT EXISTS "country"
(
    Name       TEXT            not null
        constraint ix_county_Name
            unique,
    Code       TEXT default '' not null
        primary key,
    Capital    TEXT,
    Province   TEXT,
    Area       REAL,
    Population INTEGER
);
CREATE TABLE IF NOT EXISTS "desert"
(
    Name      TEXT default '' not null
        primary key,
    Area      REAL,
    Longitude REAL,
    Latitude  REAL
);
CREATE TABLE IF NOT EXISTS "economy"
(
    Country     TEXT default '' not null
        primary key
        constraint economy_ibfk_1
            references country
            on update cascade on delete cascade,
    GDP         REAL,
    Agriculture REAL,
    Service     REAL,
    Industry    REAL,
    Inflation   REAL
);
CREATE TABLE IF NOT EXISTS "encompasses"
(
    Country    TEXT not null
        constraint encompasses_ibfk_1
            references country
            on update cascade on delete cascade,
    Continent  TEXT not null
        constraint encompasses_ibfk_2
            references continent
            on update cascade on delete cascade,
    Percentage REAL,
    primary key (Country, Continent)
);
CREATE TABLE IF NOT EXISTS "ethnicGroup"
(
    Country    TEXT default '' not null
        constraint ethnicGroup_ibfk_1
            references country
            on update cascade on delete cascade,
    Name       TEXT default '' not null,
    Percentage REAL,
    primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "geo_desert"
(
    Desert   TEXT default '' not null
        constraint geo_desert_ibfk_3
            references desert
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_desert_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Desert),
    constraint geo_desert_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_estuary"
(
    River    TEXT default '' not null
        constraint geo_estuary_ibfk_3
            references river
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_estuary_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, River),
    constraint geo_estuary_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_island"
(
    Island   TEXT default '' not null
        constraint geo_island_ibfk_3
            references island
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_island_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Island),
    constraint geo_island_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_lake"
(
    Lake     TEXT default '' not null
        constraint geo_lake_ibfk_3
            references lake
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_lake_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Lake),
    constraint geo_lake_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_mountain"
(
    Mountain TEXT default '' not null
        constraint geo_mountain_ibfk_3
            references mountain
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_mountain_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Mountain),
    constraint geo_mountain_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_river"
(
    River    TEXT default '' not null
        constraint geo_river_ibfk_3
            references river
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_river_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, River),
    constraint geo_river_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_sea"
(
    Sea      TEXT default '' not null
        constraint geo_sea_ibfk_3
            references sea
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_sea_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, Sea),
    constraint geo_sea_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "geo_source"
(
    River    TEXT default '' not null
        constraint geo_source_ibfk_3
            references river
            on update cascade on delete cascade,
    Country  TEXT default '' not null
        constraint geo_source_ibfk_1
            references country
            on update cascade on delete cascade,
    Province TEXT default '' not null,
    primary key (Province, Country, River),
    constraint geo_source_ibfk_2
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "island"
(
    Name      TEXT default '' not null
        primary key,
    Islands   TEXT,
    Area      REAL,
    Height    REAL,
    Type      TEXT,
    Longitude REAL,
    Latitude  REAL
);
CREATE TABLE IF NOT EXISTS "islandIn"
(
    Island TEXT
        constraint islandIn_ibfk_4
            references island
            on update cascade on delete cascade,
    Sea    TEXT
        constraint islandIn_ibfk_3
            references sea
            on update cascade on delete cascade,
    Lake   TEXT
        constraint islandIn_ibfk_1
            references lake
            on update cascade on delete cascade,
    River  TEXT
        constraint islandIn_ibfk_2
            references river
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "isMember"
(
    Country      TEXT default '' not null
        constraint isMember_ibfk_1
            references country
            on update cascade on delete cascade,
    Organization TEXT default '' not null
        constraint isMember_ibfk_2
            references organization
            on update cascade on delete cascade,
    Type         TEXT default 'member',
    primary key (Country, Organization)
);
CREATE TABLE IF NOT EXISTS "lake"
(
    Name      TEXT default '' not null
        primary key,
    Area      REAL,
    Depth     REAL,
    Altitude  REAL,
    Type      TEXT,
    River     TEXT,
    Longitude REAL,
    Latitude  REAL
);
CREATE TABLE IF NOT EXISTS "language"
(
    Country    TEXT default '' not null
        constraint language_ibfk_1
            references country
            on update cascade on delete cascade,
    Name       TEXT default '' not null,
    Percentage REAL,
    primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "located"
(
    City     TEXT,
    Province TEXT,
    Country  TEXT
        constraint located_ibfk_1
            references country
            on update cascade on delete cascade,
    River    TEXT
        constraint located_ibfk_3
            references river
            on update cascade on delete cascade,
    Lake     TEXT
        constraint located_ibfk_4
            references lake
            on update cascade on delete cascade,
    Sea      TEXT
        constraint located_ibfk_5
            references sea
            on update cascade on delete cascade,
    constraint located_ibfk_2
        foreign key (City, Province) references city
            on update cascade on delete cascade,
    constraint located_ibfk_6
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "locatedOn"
(
    City     TEXT default '' not null,
    Province TEXT default '' not null,
    Country  TEXT default '' not null
        constraint locatedOn_ibfk_1
            references country
            on update cascade on delete cascade,
    Island   TEXT default '' not null
        constraint locatedOn_ibfk_2
            references island
            on update cascade on delete cascade,
    primary key (City, Province, Country, Island),
    constraint locatedOn_ibfk_3
        foreign key (City, Province) references city
            on update cascade on delete cascade,
    constraint locatedOn_ibfk_4
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "mergesWith"
(
    Sea1 TEXT default '' not null
        constraint mergesWith_ibfk_1
            references sea
            on update cascade on delete cascade,
    Sea2 TEXT default '' not null
        constraint mergesWith_ibfk_2
            references sea
            on update cascade on delete cascade,
    primary key (Sea1, Sea2)
);
CREATE TABLE IF NOT EXISTS "mountain"
(
    Name      TEXT default '' not null
        primary key,
    Mountains TEXT,
    Height    REAL,
    Type      TEXT,
    Longitude REAL,
    Latitude  REAL
);
CREATE TABLE IF NOT EXISTS "mountainOnIsland"
(
    Mountain TEXT default '' not null
        constraint mountainOnIsland_ibfk_2
            references mountain
            on update cascade on delete cascade,
    Island   TEXT default '' not null
        constraint mountainOnIsland_ibfk_1
            references island
            on update cascade on delete cascade,
    primary key (Mountain, Island)
);
CREATE TABLE IF NOT EXISTS "organization"
(
    Abbreviation TEXT not null
        primary key,
    Name         TEXT not null
        constraint ix_organization_OrgNameUnique
            unique,
    City         TEXT,
    Country      TEXT
        constraint organization_ibfk_1
            references country
            on update cascade on delete cascade,
    Province     TEXT,
    Established  DATE,
    constraint organization_ibfk_2
        foreign key (City, Province) references city
            on update cascade on delete cascade,
    constraint organization_ibfk_3
        foreign key (Province, Country) references province
            on update cascade on delete cascade
);
CREATE TABLE IF NOT EXISTS "politics"
(
    Country      TEXT default '' not null
        primary key
        constraint politics_ibfk_1
            references country
            on update cascade on delete cascade,
    Independence DATE,
    Dependent    TEXT
        constraint politics_ibfk_2
            references country
            on update cascade on delete cascade,
    Government   TEXT
);
CREATE TABLE IF NOT EXISTS "population"
(
    Country           TEXT default '' not null
        primary key
        constraint population_ibfk_1
            references country
            on update cascade on delete cascade,
    Population_Growth REAL,
    Infant_Mortality  REAL
);
CREATE TABLE IF NOT EXISTS "province"
(
    Name       TEXT not null,
    Country    TEXT not null
        constraint province_ibfk_1
            references country
            on update cascade on delete cascade,
    Population INTEGER,
    Area       REAL,
    Capital    TEXT,
    CapProv    TEXT,
    primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "religion"
(
    Country    TEXT default '' not null
        constraint religion_ibfk_1
            references country
            on update cascade on delete cascade,
    Name       TEXT default '' not null,
    Percentage REAL,
    primary key (Name, Country)
);
CREATE TABLE IF NOT EXISTS "river"
(
    Name             TEXT default '' not null
        primary key,
    River            TEXT,
    Lake             TEXT
        constraint river_ibfk_1
            references lake
            on update cascade on delete cascade,
    Sea              TEXT,
    Length           REAL,
    SourceLongitude  REAL,
    SourceLatitude   REAL,
    Mountains        TEXT,
    SourceAltitude   REAL,
    EstuaryLongitude REAL,
    EstuaryLatitude  REAL
);
CREATE TABLE IF NOT EXISTS "sea"
(
    Name  TEXT default '' not null
        primary key,
    Depth REAL
);
CREATE TABLE IF NOT EXISTS "target"
(
    Country TEXT not null
        primary key
        constraint target_Country_fkey
            references country
            on update cascade on delete cascade,
    Target  TEXT
);
 | 
| 
	movie | 
	What is the MPAA rating and title of the movie starred by Leonardo DiCaprio with highest budget? | 
	starred by Leonardo DiCaprio refers to Name = 'Leonardo Dicaprio'; highest budget refers to max(Budget) | 
	SELECT T1.`MPAA Rating`, T1.Title FROM movie AS T1 INNER JOIN characters AS T2 ON T1.MovieID = T2.MovieID INNER JOIN actor AS T3 ON T3.ActorID = T2.ActorID WHERE T3.Name = 'Leonardo DiCaprio' ORDER BY T1.Budget DESC LIMIT 1 | 
	CREATE TABLE actor
(
    ActorID           INTEGER
        constraint actor_pk
            primary key,
    Name              TEXT,
    "Date of Birth"   DATE,
    "Birth City"      TEXT,
    "Birth Country"   TEXT,
    "Height (Inches)" INTEGER,
    Biography         TEXT,
    Gender            TEXT,
    Ethnicity         TEXT,
    NetWorth          TEXT
);
CREATE TABLE movie
(
    MovieID        INTEGER
        constraint movie_pk
            primary key,
    Title          TEXT,
    "MPAA Rating"  TEXT,
    Budget         INTEGER,
    Gross          INTEGER,
    "Release Date" TEXT,
    Genre          TEXT,
    Runtime        INTEGER,
    Rating         REAL,
    "Rating Count" INTEGER,
    Summary        TEXT
);
CREATE TABLE characters
(
    MovieID          INTEGER,
    ActorID          INTEGER,
    "Character Name" TEXT,
    creditOrder      INTEGER,
    pay              TEXT,
    screentime       TEXT,
    primary key (MovieID, ActorID),
    foreign key (ActorID) references actor(ActorID),
    foreign key (MovieID) references movie(MovieID)
);
 | 
| 
	bike_share_1 | 
	What is the average duration of bike trips in the city of Palo Alto? | 
	DIVIDE(SUM(duration where city = 'Palo Alto'), COUNT(start_station_id)); | 
	SELECT AVG(T1.duration) FROM trip AS T1 LEFT JOIN station AS T2 ON T2.name = T1.start_station_name WHERE T2.city = 'Palo Alto' | 
	CREATE TABLE IF NOT EXISTS "station"
(
    id                INTEGER not null
        primary key,
    name              TEXT,
    lat               REAL,
    long              REAL,
    dock_count        INTEGER,
    city              TEXT,
    installation_date TEXT
);
CREATE TABLE IF NOT EXISTS "status"
(
    station_id      INTEGER,
    bikes_available INTEGER,
    docks_available INTEGER,
    time            TEXT
);
CREATE TABLE IF NOT EXISTS "trip"
(
    id                 INTEGER not null
        primary key,
    duration           INTEGER,
    start_date         TEXT,
    start_station_name TEXT,
    start_station_id   INTEGER,
    end_date           TEXT,
    end_station_name   TEXT,
    end_station_id     INTEGER,
    bike_id            INTEGER,
    subscription_type  TEXT,
    zip_code           INTEGER
);
CREATE TABLE IF NOT EXISTS "weather"
(
    date                           TEXT,
    max_temperature_f              INTEGER,
    mean_temperature_f             INTEGER,
    min_temperature_f              INTEGER,
    max_dew_point_f                INTEGER,
    mean_dew_point_f               INTEGER,
    min_dew_point_f                INTEGER,
    max_humidity                   INTEGER,
    mean_humidity                  INTEGER,
    min_humidity                   INTEGER,
    max_sea_level_pressure_inches  REAL,
    mean_sea_level_pressure_inches REAL,
    min_sea_level_pressure_inches  REAL,
    max_visibility_miles           INTEGER,
    mean_visibility_miles          INTEGER,
    min_visibility_miles           INTEGER,
    max_wind_Speed_mph             INTEGER,
    mean_wind_speed_mph            INTEGER,
    max_gust_speed_mph             INTEGER,
    precipitation_inches           TEXT,
    cloud_cover                    INTEGER,
    events                         TEXT,
    wind_dir_degrees               INTEGER,
    zip_code                       TEXT
);
 | 
| 
	law_episode | 
	Which continent was Michael Preston born on? | 
	continent refers to birth_country | 
	SELECT birth_country FROM Person WHERE name = 'Michael Preston' | 
	CREATE TABLE Episode
(
    episode_id       TEXT
            primary key,
    series           TEXT,
    season           INTEGER,
    episode          INTEGER,
    number_in_series INTEGER,
    title            TEXT,
    summary          TEXT,
    air_date         DATE,
    episode_image    TEXT,
    rating           REAL,
    votes            INTEGER
);
CREATE TABLE Keyword
(
    episode_id TEXT,
    keyword    TEXT,
    primary key (episode_id, keyword),
    foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Person
(
    person_id     TEXT
            primary key,
    name          TEXT,
    birthdate     DATE,
    birth_name    TEXT,
    birth_place   TEXT,
    birth_region  TEXT,
    birth_country TEXT,
    height_meters REAL,
    nickname      TEXT
);
CREATE TABLE Award
(
    award_id       INTEGER
            primary key,
    organization   TEXT,
    year           INTEGER,
    award_category TEXT,
    award          TEXT,
    series         TEXT,
    episode_id     TEXT,
    person_id      TEXT,
    role           TEXT,
    result         TEXT,
    foreign key (episode_id) references Episode(episode_id),
    foreign key (person_id) references Person(person_id)
);
CREATE TABLE Credit
(
    episode_id TEXT,
    person_id  TEXT,
    category   TEXT,
    role       TEXT,
    credited   TEXT,
    primary key (episode_id, person_id),
    foreign key (episode_id) references Episode(episode_id),
    foreign key (person_id) references Person(person_id)
);
CREATE TABLE Vote
(
    episode_id TEXT,
    stars      INTEGER,
    votes      INTEGER,
    percent    REAL,
    foreign key (episode_id) references Episode(episode_id)
);
 | 
| 
	simpson_episodes | 
	Which episode id did award Outstanding Animated Program (For Programming Less Than One Hour) with an episode star score of 10? | 
	star score of 10 refers to stars = 10 | 
	SELECT DISTINCT T1.episode_id FROM Award AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T1.award = 'Outstanding Animated Program (For Programming Less Than One Hour)' AND T2.stars = 10; | 
	CREATE TABLE IF NOT EXISTS "Episode"
(
    episode_id       TEXT
        constraint Episode_pk
            primary key,
    season           INTEGER,
    episode          INTEGER,
    number_in_series INTEGER,
    title            TEXT,
    summary          TEXT,
    air_date         TEXT,
    episode_image    TEXT,
    rating           REAL,
    votes            INTEGER
);
CREATE TABLE Person
(
    name          TEXT
        constraint Person_pk
            primary key,
    birthdate     TEXT,
    birth_name    TEXT,
    birth_place   TEXT,
    birth_region  TEXT,
    birth_country TEXT,
    height_meters REAL,
    nickname      TEXT
);
CREATE TABLE Award
(
    award_id       INTEGER
            primary key,
    organization   TEXT,
    year           INTEGER,
    award_category TEXT,
    award          TEXT,
    person         TEXT,
    role           TEXT,
    episode_id     TEXT,
    season         TEXT,
    song           TEXT,
    result         TEXT,
    foreign key (person) references Person(name),
    foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Character_Award
(
    award_id  INTEGER,
    character TEXT,
    foreign key (award_id) references Award(award_id)
);
CREATE TABLE Credit
(
    episode_id TEXT,
    category   TEXT,
    person     TEXT,
    role       TEXT,
    credited   TEXT,
    foreign key (episode_id) references Episode(episode_id),
    foreign key (person) references Person(name)
);
CREATE TABLE Keyword
(
    episode_id TEXT,
    keyword    TEXT,
    primary key (episode_id, keyword),
    foreign key (episode_id) references Episode(episode_id)
);
CREATE TABLE Vote
(
    episode_id TEXT,
    stars      INTEGER,
    votes      INTEGER,
    percent    REAL,
    foreign key (episode_id) references Episode(episode_id)
);
 | 
| 
	software_company | 
	List down the customer's geographic identifier who are handlers or cleaners. | 
	geographic identifier refers to GEOID; OCCUPATION = 'Handlers-cleaners'; | 
	SELECT GEOID FROM Customers WHERE OCCUPATION = 'Handlers-cleaners' | 
	CREATE TABLE Demog
(
    GEOID         INTEGER
        constraint Demog_pk
            primary key,
    INHABITANTS_K REAL,
    INCOME_K      REAL,
    A_VAR1        REAL,
    A_VAR2        REAL,
    A_VAR3        REAL,
    A_VAR4        REAL,
    A_VAR5        REAL,
    A_VAR6        REAL,
    A_VAR7        REAL,
    A_VAR8        REAL,
    A_VAR9        REAL,
    A_VAR10       REAL,
    A_VAR11       REAL,
    A_VAR12       REAL,
    A_VAR13       REAL,
    A_VAR14       REAL,
    A_VAR15       REAL,
    A_VAR16       REAL,
    A_VAR17       REAL,
    A_VAR18       REAL
);
CREATE TABLE mailings3
(
    REFID    INTEGER
        constraint mailings3_pk
            primary key,
    REF_DATE DATETIME,
    RESPONSE TEXT
);
CREATE TABLE IF NOT EXISTS "Customers"
(
    ID             INTEGER
        constraint Customers_pk
            primary key,
    SEX            TEXT,
    MARITAL_STATUS TEXT,
    GEOID          INTEGER
        constraint Customers_Demog_GEOID_fk
            references Demog,
    EDUCATIONNUM   INTEGER,
    OCCUPATION     TEXT,
    age            INTEGER
);
CREATE TABLE IF NOT EXISTS "Mailings1_2"
(
    REFID    INTEGER
        constraint Mailings1_2_pk
            primary key
        constraint Mailings1_2_Customers_ID_fk
            references Customers,
    REF_DATE DATETIME,
    RESPONSE TEXT
);
CREATE TABLE IF NOT EXISTS "Sales"
(
    EVENTID    INTEGER
        constraint Sales_pk
            primary key,
    REFID      INTEGER
        references Customers,
    EVENT_DATE DATETIME,
    AMOUNT     REAL
);
 | 
			Subsets and Splits
				
	
				
			
				
No community queries yet
The top public SQL queries from the community will appear here once available.