Dludora/DAIL-BIRD huggingface dataset:
/* Given the following database schema: */
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`)
)

/* Answer the following: How many events did the device ID "3915082290673130000" join? */
SELECT 
SELECT COUNT(event_id) FROM events WHERE device_id = 3915082290673130000
/* Given the following database schema: */
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`)
)

/* Answer the following: How many events were participated by the users at longitude of "-156"? */
SELECT 
SELECT COUNT(event_id) FROM events WHERE longitude = -156
/* Given the following database schema: */
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`)
)

/* Answer the following: How many app users belong to label ID of "48"? */
SELECT 
SELECT COUNT(app_id) FROM app_labels WHERE label_id = 48
/* Given the following database schema: */
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`)
)

/* Answer the following: List out the time of the event id 12. time refers to timestamp; */
SELECT 
SELECT timestamp FROM events WHERE event_id = 12
/* Given the following database schema: */
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`)
)

/* Answer the following: How many active users are there in the event? active refers to is_active = 1; */
SELECT 
SELECT COUNT(app_id) FROM app_events WHERE is_active = 1
/* Given the following database schema: */
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`)
)

/* Answer the following: How many apps are labeled 7? labeled 7 refers to label_id = 7; */
SELECT 
SELECT COUNT(app_id) FROM app_labels WHERE label_id = 7
/* Given the following database schema: */
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`)
)

/* Answer the following: How many events does the device "4069764298338760000" have? */
SELECT 
SELECT COUNT(event_id) FROM events WHERE device_id = 4069764298338760000
/* Given the following database schema: */
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)
)

/* Answer the following: Please list all the keywords of the episode "Refuge: Part 1". episode "Refuge: Part 1" refers to title = 'Refuge: Part 1' */
SELECT 
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Refuge: Part 1'
/* Given the following database schema: */
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)
)

/* Answer the following: How many keywords are there for season 9, episode 23 of law_and_order? */
SELECT 
SELECT COUNT(T2.keyword) FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.season = 9 AND T1.episode = 23
/* Given the following database schema: */
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)
)

/* Answer the following: What is the title of the episode with the keyword "laundering money"? keyword "laundering money" refers to keyword = 'laundering money' */
SELECT 
SELECT T1.title FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T2.keyword = 'laundering money'
/* Given the following database schema: */
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)
)

/* Answer the following: Please list all the keywords for the episodes with a rating of over 8. a rating of over 8 refers to rating > 8 */
SELECT 
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.rating > 8
/* Given the following database schema: */
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)
)

/* Answer the following: How many 10-star votes were given to the episode titled "Cherished"? 10-star vote refers to stars = 10; titled "Cherished" refers to title = 'Cherished' */
SELECT 
SELECT T2.votes FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Cherished' AND T2.stars = 10
/* Given the following database schema: */
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)
)

/* Answer the following: How many votes did the episode titled "Cherished" get in total? titled "Cherished" refers to title = 'Cherished' */
SELECT 
SELECT SUM(T2.votes) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Cherished'
/* Given the following database schema: */
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)
)

/* Answer the following: What is the title of the episode that got the most 10-star votes? the most refers to max(votes); 10-star refers to stars = 10 */
SELECT 
SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 10 ORDER BY T2.votes DESC LIMIT 1
/* Given the following database schema: */
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)
)

/* Answer the following: Park Dietz was credited in which role in the episode titled "Cherished"? credited refers to credited = 'true'; titled "Cherished" refers to title = 'Cherished' */
SELECT 
SELECT T2.role FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.title = 'Cherished' AND T3.name = 'Park Dietz' AND T2.credited = 'true'
/* Given the following database schema: */
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)
)

/* Answer the following: How many people had filled a role in the episode titled "Cherished", but did not show up in the on-screen credits? titled "Cherished" refers to title = 'Cherished'; did not show up in the on-screen credits refers to credited = '' */
SELECT 
SELECT COUNT(T1.episode_id) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Cherished' AND T2.credited = 'false'
/* Given the following database schema: */
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)
)

/* Answer the following: Who was credited as "technical advisor" in the episode titled "Cherished"? who refers to name; credited refers to credited = 'true'; as "technical advisor" refers to role = 'technical advisor'; titled "Cherished" refers to title = 'Cherished' */
SELECT 
SELECT T3.name FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.title = 'Cherished' AND T2.credited = 'true' AND T2.role = 'technical advisor'
/* Given the following database schema: */
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)
)

/* Answer the following: For how many times was Park Dietz credited? credited refers to credited = 'true' */
SELECT 
SELECT COUNT(T3.person_id) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T2.credited = 'true' AND T3.name = 'Park Dietz'
/* Given the following database schema: */
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)
)

/* Answer the following: Please list the titles of all the episodes in which Park Dietz was credited. credited refers to credited = 'true' */
SELECT 
SELECT T1.title FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T2.credited = 'true' AND T3.name = 'Park Dietz'
/* Given the following database schema: */
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)
)

/* Answer the following: Was Anthony Azzara's role in episode tt0629204 displayed in the credits at the end of the episode? episode tt0629204 refers to episode_id = 'tt0629204'; credited refers to credited = 'true'; not credited refers to credited = '' */
SELECT 
SELECT T1.credited FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Anthony Azzara' AND T1.episode_id = 'tt0629204'