{"actor": {"columns": [[0, "actor_id", "SMALLINT UNSIGNED", 1, null, 1], [1, "first_name", "VARCHAR(45)", 1, null, 0], [2, "last_name", "VARCHAR(45)", 1, null, 0], [3, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["actor_id"], "foreign_keys": [], "unique_constraints": [[[0, 0, "actor_id"]]], "check_constraints": []}, "address": {"columns": [[0, "address_id", "SMALLINT UNSIGNED", 1, null, 1], [1, "address", "VARCHAR(50)", 1, null, 0], [2, "address2", "VARCHAR(50)", 0, "NULL", 0], [3, "district", "VARCHAR(20)", 1, null, 0], [4, "city_id", "SMALLINT UNSIGNED", 1, null, 0], [5, "postal_code", "VARCHAR(10)", 0, "NULL", 0], [6, "phone", "VARCHAR(20)", 1, null, 0], [7, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["address_id"], "foreign_keys": [[0, 0, "city", "city_id", "city_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "address_id"]]], "check_constraints": []}, "category": {"columns": [[0, "category_id", "TINYINT UNSIGNED", 1, null, 1], [1, "name", "VARCHAR(25)", 1, null, 0], [2, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["category_id"], "foreign_keys": [], "unique_constraints": [[[0, 0, "category_id"]]], "check_constraints": []}, "city": {"columns": [[0, "city_id", "SMALLINT UNSIGNED", 1, null, 1], [1, "city", "VARCHAR(50)", 1, null, 0], [2, "country_id", "SMALLINT UNSIGNED", 1, null, 0], [3, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["city_id"], "foreign_keys": [[0, 0, "country", "country_id", "country_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "city_id"]]], "check_constraints": []}, "country": {"columns": [[0, "country_id", "SMALLINT UNSIGNED", 1, null, 1], [1, "country", "VARCHAR(50)", 1, null, 0], [2, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["country_id"], "foreign_keys": [], "unique_constraints": [[[0, 0, "country_id"]]], "check_constraints": []}, "customer": {"columns": [[0, "customer_id", "SMALLINT UNSIGNED", 1, null, 1], [1, "store_id", "TINYINT UNSIGNED", 1, null, 0], [2, "first_name", "VARCHAR(45)", 1, null, 0], [3, "last_name", "VARCHAR(45)", 1, null, 0], [4, "email", "VARCHAR(50)", 0, "NULL", 0], [5, "address_id", "SMALLINT UNSIGNED", 1, null, 0], [6, "active", "BOOLEAN", 1, "TRUE", 0], [7, "create_date", "DATETIME", 1, null, 0], [8, "last_update", "TIMESTAMP", 0, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["customer_id"], "foreign_keys": [[0, 0, "store", "store_id", "store_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "address", "address_id", "address_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "customer_id"]]], "check_constraints": []}, "film": {"columns": [[0, "film_id", "SMALLINT UNSIGNED", 1, null, 1], [1, "title", "VARCHAR(255)", 1, null, 0], [2, "description", "TEXT", 0, "NULL", 0], [3, "release_year", "YEAR", 0, "NULL", 0], [4, "language_id", "TINYINT UNSIGNED", 1, null, 0], [5, "original_language_id", "TINYINT UNSIGNED", 0, "NULL", 0], [6, "rental_duration", "TINYINT UNSIGNED", 1, "3", 0], [7, "rental_rate", "DECIMAL(4,2)", 1, "4.99", 0], [8, "length", "SMALLINT UNSIGNED", 0, "NULL", 0], [9, "replacement_cost", "DECIMAL(5,2)", 1, "19.99", 0], [10, "rating", "", 0, "'G'", 0], [11, "special_features", "", 0, "NULL", 0], [12, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["film_id"], "foreign_keys": [[0, 0, "language", "original_language_id", "language_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "language", "language_id", "language_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "film_id"]]], "check_constraints": []}, "film_actor": {"columns": [[0, "actor_id", "SMALLINT UNSIGNED", 1, null, 1], [1, "film_id", "SMALLINT UNSIGNED", 1, null, 2], [2, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["actor_id", "film_id"], "foreign_keys": [[0, 0, "film", "film_id", "film_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "actor", "actor_id", "actor_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "actor_id"], [1, 1, "film_id"]]], "check_constraints": []}, "film_category": {"columns": [[0, "film_id", "SMALLINT UNSIGNED", 1, null, 1], [1, "category_id", "TINYINT UNSIGNED", 1, null, 2], [2, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["film_id", "category_id"], "foreign_keys": [[0, 0, "category", "category_id", "category_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "film", "film_id", "film_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "film_id"], [1, 1, "category_id"]]], "check_constraints": []}, "film_text": {"columns": [[0, "film_id", "SMALLINT", 1, null, 1], [1, "title", "VARCHAR(255)", 1, null, 0], [2, "description", "TEXT", 0, null, 0]], "primary_keys": ["film_id"], "foreign_keys": [], "unique_constraints": [[[0, 0, "film_id"]]], "check_constraints": []}, "inventory": {"columns": [[0, "inventory_id", "MEDIUMINT UNSIGNED", 1, null, 1], [1, "film_id", "SMALLINT UNSIGNED", 1, null, 0], [2, "store_id", "TINYINT UNSIGNED", 1, null, 0], [3, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["inventory_id"], "foreign_keys": [[0, 0, "film", "film_id", "film_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "store", "store_id", "store_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "inventory_id"]]], "check_constraints": []}, "language": {"columns": [[0, "language_id", "TINYINT UNSIGNED", 1, null, 1], [1, "name", "CHAR(20)", 1, null, 0], [2, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["language_id"], "foreign_keys": [], "unique_constraints": [[[0, 0, "language_id"]]], "check_constraints": []}, "payment": {"columns": [[0, "payment_id", "SMALLINT UNSIGNED", 1, null, 1], [1, "customer_id", "SMALLINT UNSIGNED", 1, null, 0], [2, "staff_id", "TINYINT UNSIGNED", 1, null, 0], [3, "rental_id", "INT", 0, "NULL", 0], [4, "amount", "DECIMAL(5,2)", 1, null, 0], [5, "payment_date", "DATETIME", 1, null, 0], [6, "last_update", "TIMESTAMP", 0, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["payment_id"], "foreign_keys": [[0, 0, "staff", "staff_id", "staff_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "customer", "customer_id", "customer_id", "NO ACTION", "NO ACTION", "NONE"], [2, 0, "rental", "rental_id", "rental_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "payment_id"]]], "check_constraints": []}, "rental": {"columns": [[0, "rental_id", "INT", 1, null, 1], [1, "rental_date", "DATETIME", 1, null, 0], [2, "inventory_id", "MEDIUMINT UNSIGNED", 1, null, 0], [3, "customer_id", "SMALLINT UNSIGNED", 1, null, 0], [4, "return_date", "DATETIME", 0, "NULL", 0], [5, "staff_id", "TINYINT UNSIGNED", 1, null, 0], [6, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["rental_id"], "foreign_keys": [[0, 0, "customer", "customer_id", "customer_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "inventory", "inventory_id", "inventory_id", "NO ACTION", "NO ACTION", "NONE"], [2, 0, "staff", "staff_id", "staff_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "rental_id"]]], "check_constraints": []}, "staff": {"columns": [[0, "staff_id", "TINYINT UNSIGNED", 1, null, 1], [1, "first_name", "VARCHAR(45)", 1, null, 0], [2, "last_name", "VARCHAR(45)", 1, null, 0], [3, "address_id", "SMALLINT UNSIGNED", 1, null, 0], [4, "picture", "BLOB", 0, "NULL", 0], [5, "email", "VARCHAR(50)", 0, "NULL", 0], [6, "store_id", "TINYINT UNSIGNED", 1, null, 0], [7, "active", "BOOLEAN", 1, "TRUE", 0], [8, "username", "VARCHAR(16)", 1, null, 0], [9, "password", "VARCHAR(40)", 0, "NULL", 0], [10, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["staff_id"], "foreign_keys": [[0, 0, "address", "address_id", "address_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "staff_id"]]], "check_constraints": []}, "store": {"columns": [[0, "store_id", "TINYINT UNSIGNED", 1, null, 1], [1, "manager_staff_id", "TINYINT UNSIGNED", 1, null, 0], [2, "address_id", "SMALLINT UNSIGNED", 1, null, 0], [3, "last_update", "TIMESTAMP", 1, "CURRENT_TIMESTAMP", 0]], "primary_keys": ["store_id"], "foreign_keys": [[0, 0, "address", "address_id", "address_id", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "staff", "manager_staff_id", "staff_id", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "store_id"]]], "check_constraints": []}}
CREATE TABLE actor (
    actor_id SMALLINT UNSIGNED NOT NULL  PRIMARY KEY,
    first_name VARCHAR(45) NOT NULL,
    last_name VARCHAR(45) NOT NULL,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (actor_id)
);

CREATE TABLE address (
    address_id SMALLINT UNSIGNED NOT NULL  PRIMARY KEY,
    address VARCHAR(50) NOT NULL,
    address2 VARCHAR(50)  DEFAULT NULL,
    district VARCHAR(20) NOT NULL,
    city_id SMALLINT UNSIGNED NOT NULL,
    postal_code VARCHAR(10)  DEFAULT NULL,
    phone VARCHAR(20) NOT NULL,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (address_id),
    FOREIGN KEY (city_id) REFERENCES city(city_id)
);

CREATE TABLE category (
    category_id TINYINT UNSIGNED NOT NULL  PRIMARY KEY,
    name VARCHAR(25) NOT NULL,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (category_id)
);

CREATE TABLE city (
    city_id SMALLINT UNSIGNED NOT NULL  PRIMARY KEY,
    city VARCHAR(50) NOT NULL,
    country_id SMALLINT UNSIGNED NOT NULL,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (city_id),
    FOREIGN KEY (country_id) REFERENCES country(country_id)
);

CREATE TABLE country (
    country_id SMALLINT UNSIGNED NOT NULL  PRIMARY KEY,
    country VARCHAR(50) NOT NULL,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (country_id)
);

CREATE TABLE customer (
    customer_id SMALLINT UNSIGNED NOT NULL  PRIMARY KEY,
    store_id TINYINT UNSIGNED NOT NULL,
    first_name VARCHAR(45) NOT NULL,
    last_name VARCHAR(45) NOT NULL,
    email VARCHAR(50)  DEFAULT NULL,
    address_id SMALLINT UNSIGNED NOT NULL,
    active BOOLEAN NOT NULL DEFAULT TRUE,
    create_date DATETIME NOT NULL,
    last_update TIMESTAMP  DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (customer_id),
    FOREIGN KEY (store_id) REFERENCES store(store_id),
    FOREIGN KEY (address_id) REFERENCES address(address_id)
);

CREATE TABLE film (
    film_id SMALLINT UNSIGNED NOT NULL  PRIMARY KEY,
    title VARCHAR(255) NOT NULL,
    description TEXT  DEFAULT NULL,
    release_year YEAR  DEFAULT NULL,
    language_id TINYINT UNSIGNED NOT NULL,
    original_language_id TINYINT UNSIGNED  DEFAULT NULL,
    rental_duration TINYINT UNSIGNED NOT NULL DEFAULT 3,
    rental_rate DECIMAL(4,2) NOT NULL DEFAULT 4.99,
    length SMALLINT UNSIGNED  DEFAULT NULL,
    replacement_cost DECIMAL(5,2) NOT NULL DEFAULT 19.99,
    rating   DEFAULT 'G',
    special_features   DEFAULT NULL,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (film_id),
    FOREIGN KEY (original_language_id) REFERENCES language(language_id),
    FOREIGN KEY (language_id) REFERENCES language(language_id)
);

CREATE TABLE film_actor (
    actor_id SMALLINT UNSIGNED NOT NULL  PRIMARY KEY,
    film_id SMALLINT UNSIGNED NOT NULL  PRIMARY KEY,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (actor_id, film_id),
    UNIQUE (actor_id, film_id),
    FOREIGN KEY (film_id) REFERENCES film(film_id),
    FOREIGN KEY (actor_id) REFERENCES actor(actor_id)
);

CREATE TABLE film_category (
    film_id SMALLINT UNSIGNED NOT NULL  PRIMARY KEY,
    category_id TINYINT UNSIGNED NOT NULL  PRIMARY KEY,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (film_id, category_id),
    UNIQUE (film_id, category_id),
    FOREIGN KEY (category_id) REFERENCES category(category_id),
    FOREIGN KEY (film_id) REFERENCES film(film_id)
);

CREATE TABLE film_text (
    film_id SMALLINT NOT NULL  PRIMARY KEY,
    title VARCHAR(255) NOT NULL,
    description TEXT,
    UNIQUE (film_id)
);

CREATE TABLE inventory (
    inventory_id MEDIUMINT UNSIGNED NOT NULL  PRIMARY KEY,
    film_id SMALLINT UNSIGNED NOT NULL,
    store_id TINYINT UNSIGNED NOT NULL,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (inventory_id),
    FOREIGN KEY (film_id) REFERENCES film(film_id),
    FOREIGN KEY (store_id) REFERENCES store(store_id)
);

CREATE TABLE language (
    language_id TINYINT UNSIGNED NOT NULL  PRIMARY KEY,
    name CHAR(20) NOT NULL,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (language_id)
);

CREATE TABLE payment (
    payment_id SMALLINT UNSIGNED NOT NULL  PRIMARY KEY,
    customer_id SMALLINT UNSIGNED NOT NULL,
    staff_id TINYINT UNSIGNED NOT NULL,
    rental_id INT  DEFAULT NULL,
    amount DECIMAL(5,2) NOT NULL,
    payment_date DATETIME NOT NULL,
    last_update TIMESTAMP  DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (payment_id),
    FOREIGN KEY (staff_id) REFERENCES staff(staff_id),
    FOREIGN KEY (customer_id) REFERENCES customer(customer_id),
    FOREIGN KEY (rental_id) REFERENCES rental(rental_id)
);

CREATE TABLE rental (
    rental_id INT NOT NULL  PRIMARY KEY,
    rental_date DATETIME NOT NULL,
    inventory_id MEDIUMINT UNSIGNED NOT NULL,
    customer_id SMALLINT UNSIGNED NOT NULL,
    return_date DATETIME  DEFAULT NULL,
    staff_id TINYINT UNSIGNED NOT NULL,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (rental_id),
    FOREIGN KEY (customer_id) REFERENCES customer(customer_id),
    FOREIGN KEY (inventory_id) REFERENCES inventory(inventory_id),
    FOREIGN KEY (staff_id) REFERENCES staff(staff_id)
);

CREATE TABLE staff (
    staff_id TINYINT UNSIGNED NOT NULL  PRIMARY KEY,
    first_name VARCHAR(45) NOT NULL,
    last_name VARCHAR(45) NOT NULL,
    address_id SMALLINT UNSIGNED NOT NULL,
    picture BLOB  DEFAULT NULL,
    email VARCHAR(50)  DEFAULT NULL,
    store_id TINYINT UNSIGNED NOT NULL,
    active BOOLEAN NOT NULL DEFAULT TRUE,
    username VARCHAR(16) NOT NULL,
    password VARCHAR(40)  DEFAULT NULL,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (staff_id),
    FOREIGN KEY (address_id) REFERENCES address(address_id)
);

CREATE TABLE store (
    store_id TINYINT UNSIGNED NOT NULL  PRIMARY KEY,
    manager_staff_id TINYINT UNSIGNED NOT NULL,
    address_id SMALLINT UNSIGNED NOT NULL,
    last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE (store_id),
    FOREIGN KEY (address_id) REFERENCES address(address_id),
    FOREIGN KEY (manager_staff_id) REFERENCES staff(staff_id)
);