Schema sakila
(1/4)
DDL script
CREATE SCHEMA IF NOT EXISTS `sakila` 
Table actor
(1/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK actor_id SMALLINT Yes
first_name VARCHAR(45) Yes
last_name VARCHAR(45) Yes
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
idx_actor_last_name
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_film_actor_actor Non-Identifying actor film_actor 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`actor` (
`actor_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
`first_name` VARCHAR(45) NOT NULL,
`last_name` VARCHAR(45) NOT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`actor_id`),
INDEX `idx_actor_last_name` (`last_name` ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table address
(2/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK address_id SMALLINT Yes
address VARCHAR(50) Yes
address2 VARCHAR(50) No NULL
district VARCHAR(20) Yes
city_id SMALLINT Yes
postal_code VARCHAR(10) No NULL
phone VARCHAR(20) Yes
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
idx_fk_city_id
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_address_city Non-Identifying city address 1:n
fk_customer_address Non-Identifying address customer 1:n
fk_staff_address Non-Identifying address staff 1:n
fk_store_address Non-Identifying address store 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`address` (
`address_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
`address` VARCHAR(50) NOT NULL,
`address2` VARCHAR(50) NULL DEFAULT NULL,
`district` VARCHAR(20) NOT NULL,
`city_id` SMALLINT UNSIGNED NOT NULL,
`postal_code` VARCHAR(10) NULL DEFAULT NULL,
`phone` VARCHAR(20) NOT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`address_id`),
INDEX `idx_fk_city_id` (`city_id` ASC),
CONSTRAINT `fk_address_city`
FOREIGN KEY (`city_id`)
REFERENCES `sakila`.`city` (`city_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table category
(3/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK category_id TINYINT Yes
name VARCHAR(25) Yes
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_film_category_category Non-Identifying category film_category 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`category` (
`category_id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(25) NOT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`category_id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table city
(4/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK city_id SMALLINT Yes
city VARCHAR(50) Yes
country_id SMALLINT Yes
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
idx_fk_country_id
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_city_country Non-Identifying country city 1:n
fk_address_city Non-Identifying city address 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`city` (
`city_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
`city` VARCHAR(50) NOT NULL,
`country_id` SMALLINT UNSIGNED NOT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`city_id`),
INDEX `idx_fk_country_id` (`country_id` ASC),
CONSTRAINT `fk_city_country`
FOREIGN KEY (`country_id`)
REFERENCES `sakila`.`country` (`country_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table country
(5/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK country_id SMALLINT Yes
country VARCHAR(50) Yes
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_city_country Non-Identifying country city 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`country` (
`country_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
`country` VARCHAR(50) NOT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`country_id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table customer
(6/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK customer_id SMALLINT Yes
store_id TINYINT Yes
first_name VARCHAR(45) Yes
last_name VARCHAR(45) Yes
email VARCHAR(50) No NULL
address_id SMALLINT Yes
active BOOLEAN Yes TRUE
create_date DATETIME Yes
last_update TIMESTAMP No CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
idx_fk_store_id
No No INDEX
idx_fk_address_id
No No INDEX
idx_last_name
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_customer_address Non-Identifying address customer 1:n
fk_customer_store Non-Identifying store customer 1:n
fk_payment_customer Non-Identifying customer payment 1:n
fk_rental_customer Non-Identifying customer rental 1:n
Table Comments
Table storing all customers. Holds foreign keys to the address table and the store table where this customer is registered. Basic information about the customer like first and last name are stored in the table itself. Same for the date the record was created and when the information was last updated.
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`customer` (
`customer_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
`store_id` TINYINT UNSIGNED NOT NULL,
`first_name` VARCHAR(45) NOT NULL,
`last_name` VARCHAR(45) NOT NULL,
`email` VARCHAR(50) NULL DEFAULT NULL,
`address_id` SMALLINT UNSIGNED NOT NULL,
`active` TINYINT(1) NOT NULL DEFAULT TRUE,
`create_date` DATETIME NOT NULL,
`last_update` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`customer_id`),
INDEX `idx_fk_store_id` (`store_id` ASC),
INDEX `idx_fk_address_id` (`address_id` ASC),
INDEX `idx_last_name` (`last_name` ASC),
CONSTRAINT `fk_customer_address`
FOREIGN KEY (`address_id`)
REFERENCES `sakila`.`address` (`address_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_customer_store`
FOREIGN KEY (`store_id`)
REFERENCES `sakila`.`store` (`store_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COMMENT = 'Table storing all customers. Holds foreign keys to the addre /* comment truncated */ /*ss table and the store table where this customer is registered.

Basic information about the customer like first and last name are stored in the table itself. Same for the date the record was created and when the information was last updated.*/'
Table film
(7/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK film_id SMALLINT Yes
title VARCHAR(255) Yes
description TEXT No NULL
release_year YEAR No NULL
language_id TINYINT Yes
original_language_id TINYINT No NULL
rental_duration TINYINT Yes 3
rental_rate DECIMAL(4,2) Yes 4.99
length SMALLINT No NULL
replacement_cost DECIMAL(5,2) Yes 19.99
rating ENUM('G','PG','PG-13','R','NC-17') No 'G'
special_features SET('Trailers','Commentaries','Deleted Scenes','Behind the Scenes') No NULL
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
idx_title
No No INDEX
idx_fk_language_id
No No INDEX
idx_fk_original_language_id
No No INDEX
PRIMARY
Yes No PRIMARY
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_film_language Non-Identifying language film 1:n
fk_film_language_original Non-Identifying language film 1:n
fk_film_actor_film Non-Identifying film film_actor 1:n
fk_film_category_film Non-Identifying film film_category 1:n
fk_inventory_film Non-Identifying film inventory 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`film` (
`film_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
`title` VARCHAR(255) NOT NULL,
`description` TEXT NULL DEFAULT NULL,
`release_year` YEAR NULL DEFAULT NULL,
`language_id` TINYINT UNSIGNED NOT NULL,
`original_language_id` TINYINT UNSIGNED NULL DEFAULT NULL,
`rental_duration` TINYINT UNSIGNED NOT NULL DEFAULT 3,
`rental_rate` DECIMAL(4,2) NOT NULL DEFAULT 4.99,
`length` SMALLINT UNSIGNED NULL DEFAULT NULL,
`replacement_cost` DECIMAL(5,2) NOT NULL DEFAULT 19.99,
`rating` ENUM('G','PG','PG-13','R','NC-17') NULL DEFAULT 'G',
`special_features` SET('Trailers','Commentaries','Deleted Scenes','Behind the Scenes') NULL DEFAULT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
INDEX `idx_title` (`title` ASC),
INDEX `idx_fk_language_id` (`language_id` ASC),
INDEX `idx_fk_original_language_id` (`original_language_id` ASC),
PRIMARY KEY (`film_id`),
CONSTRAINT `fk_film_language`
FOREIGN KEY (`language_id`)
REFERENCES `sakila`.`language` (`language_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_film_language_original`
FOREIGN KEY (`original_language_id`)
REFERENCES `sakila`.`language` (`language_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table film_actor
(8/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
FK actor_id SMALLINT Yes
FK film_id SMALLINT Yes
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
idx_fk_film_id
No No INDEX
fk_film_actor_actor_idx
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_film_actor_actor Identifying actor film_actor 1:n
fk_film_actor_film Identifying film film_actor 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`film_actor` (
`actor_id` SMALLINT UNSIGNED NOT NULL,
`film_id` SMALLINT UNSIGNED NOT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`actor_id`, `film_id`),
INDEX `idx_fk_film_id` (`film_id` ASC),
INDEX `fk_film_actor_actor_idx` (`actor_id` ASC),
CONSTRAINT `fk_film_actor_actor`
FOREIGN KEY (`actor_id`)
REFERENCES `sakila`.`actor` (`actor_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_film_actor_film`
FOREIGN KEY (`film_id`)
REFERENCES `sakila`.`film` (`film_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table film_category
(9/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
FK film_id SMALLINT Yes
FK category_id TINYINT Yes
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
fk_film_category_category_idx
No No INDEX
fk_film_category_film_idx
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_film_category_film Identifying film film_category 1:n
fk_film_category_category Identifying category film_category 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`film_category` (
`film_id` SMALLINT UNSIGNED NOT NULL,
`category_id` TINYINT UNSIGNED NOT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`film_id`, `category_id`),
INDEX `fk_film_category_category_idx` (`category_id` ASC),
INDEX `fk_film_category_film_idx` (`film_id` ASC),
CONSTRAINT `fk_film_category_film`
FOREIGN KEY (`film_id`)
REFERENCES `sakila`.`film` (`film_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_film_category_category`
FOREIGN KEY (`category_id`)
REFERENCES `sakila`.`category` (`category_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table film_text
(10/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set n/a
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine MyISAM Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
FK film_id SMALLINT Yes
title VARCHAR(255) Yes
description TEXT No NULL
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
idx_title_description
No No FULLTEXT
fk_film_text_idx
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_film_text Identifying inventory film_text 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`film_text` (
`film_id` SMALLINT UNSIGNED NOT NULL,
`title` VARCHAR(255) NOT NULL,
`description` TEXT NULL DEFAULT NULL,
PRIMARY KEY (`film_id`),
FULLTEXT INDEX `idx_title_description` (`title` ASC, `description` ASC))
ENGINE = MyISAM
Table inventory
(11/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK inventory_id MEDIUMINT Yes
film_id SMALLINT Yes
store_id TINYINT Yes
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
idx_fk_film_id
No No INDEX
idx_store_id_film_id
No No INDEX
fk_inventory_store_idx
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_inventory_store Non-Identifying store inventory 1:n
fk_inventory_film Non-Identifying film inventory 1:n
fk_film_text Non-Identifying inventory film_text 1:n
fk_rental_inventory Non-Identifying inventory rental 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`inventory` (
`inventory_id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
`film_id` SMALLINT UNSIGNED NOT NULL,
`store_id` TINYINT UNSIGNED NOT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`inventory_id`),
INDEX `idx_fk_film_id` (`film_id` ASC),
INDEX `idx_store_id_film_id` (`store_id` ASC, `film_id` ASC),
INDEX `fk_inventory_store_idx` (`store_id` ASC),
CONSTRAINT `fk_inventory_store`
FOREIGN KEY (`store_id`)
REFERENCES `sakila`.`store` (`store_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_inventory_film`
FOREIGN KEY (`film_id`)
REFERENCES `sakila`.`film` (`film_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table language
(12/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK language_id TINYINT Yes
name CHAR(20) Yes
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_film_language Non-Identifying language film 1:n
fk_film_language_original Non-Identifying language film 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`language` (
`language_id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
`name` CHAR(20) NOT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`language_id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table payment
(13/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK payment_id SMALLINT Yes
customer_id SMALLINT Yes
staff_id TINYINT Yes
rental_id INT No NULL
amount DECIMAL(5,2) Yes
payment_date DATETIME Yes
last_update TIMESTAMP No CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
idx_fk_staff_id
No No INDEX
idx_fk_customer_id
No No INDEX
fk_payment_rental_idx
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_payment_rental Non-Identifying rental payment 1:n
fk_payment_customer Non-Identifying customer payment 1:n
fk_payment_staff Non-Identifying staff payment 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`payment` (
`payment_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
`customer_id` SMALLINT UNSIGNED NOT NULL,
`staff_id` TINYINT UNSIGNED NOT NULL,
`rental_id` INT NULL DEFAULT NULL,
`amount` DECIMAL(5,2) NOT NULL,
`payment_date` DATETIME NOT NULL,
`last_update` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`payment_id`),
INDEX `idx_fk_staff_id` (`staff_id` ASC),
INDEX `idx_fk_customer_id` (`customer_id` ASC),
INDEX `fk_payment_rental_idx` (`rental_id` ASC),
CONSTRAINT `fk_payment_rental`
FOREIGN KEY (`rental_id`)
REFERENCES `sakila`.`rental` (`rental_id`)
ON DELETE SET NULL
ON UPDATE CASCADE,
CONSTRAINT `fk_payment_customer`
FOREIGN KEY (`customer_id`)
REFERENCES `sakila`.`customer` (`customer_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_payment_staff`
FOREIGN KEY (`staff_id`)
REFERENCES `sakila`.`staff` (`staff_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table rental
(14/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK rental_id INT Yes
rental_date DATETIME Yes
inventory_id MEDIUMINT Yes
customer_id SMALLINT Yes
return_date DATETIME No NULL
staff_id TINYINT Yes
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
No Yes UNIQUE
idx_fk_inventory_id
No No INDEX
idx_fk_customer_id
No No INDEX
idx_fk_staff_id
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_rental_staff Non-Identifying staff rental 1:n
fk_rental_inventory Non-Identifying inventory rental 1:n
fk_rental_customer Non-Identifying customer rental 1:n
fk_payment_rental Non-Identifying rental payment 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`rental` (
`rental_id` INT NOT NULL AUTO_INCREMENT,
`rental_date` DATETIME NOT NULL,
`inventory_id` MEDIUMINT UNSIGNED NOT NULL,
`customer_id` SMALLINT UNSIGNED NOT NULL,
`return_date` DATETIME NULL DEFAULT NULL,
`staff_id` TINYINT UNSIGNED NOT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`rental_id`),
UNIQUE INDEX (`rental_date` ASC, `inventory_id` ASC, `customer_id` ASC),
INDEX `idx_fk_inventory_id` (`inventory_id` ASC),
INDEX `idx_fk_customer_id` (`customer_id` ASC),
INDEX `idx_fk_staff_id` (`staff_id` ASC),
CONSTRAINT `fk_rental_staff`
FOREIGN KEY (`staff_id`)
REFERENCES `sakila`.`staff` (`staff_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_rental_inventory`
FOREIGN KEY (`inventory_id`)
REFERENCES `sakila`.`inventory` (`inventory_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_rental_customer`
FOREIGN KEY (`customer_id`)
REFERENCES `sakila`.`customer` (`customer_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table staff
(15/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK staff_id TINYINT Yes
first_name VARCHAR(45) Yes
last_name VARCHAR(45) Yes
address_id SMALLINT Yes
picture BLOB No NULL
email VARCHAR(50) No NULL
store_id TINYINT Yes
active BOOLEAN Yes TRUE
username VARCHAR(16) Yes
password VARCHAR(40) No NULL
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
idx_fk_store_id
No No INDEX
idx_fk_address_id
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_staff_store Non-Identifying store staff 1:n
fk_staff_address Non-Identifying address staff 1:n
fk_payment_staff Non-Identifying staff payment 1:n
fk_rental_staff Non-Identifying staff rental 1:n
fk_store_staff Non-Identifying staff store 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`staff` (
`staff_id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
`first_name` VARCHAR(45) NOT NULL,
`last_name` VARCHAR(45) NOT NULL,
`address_id` SMALLINT UNSIGNED NOT NULL,
`picture` BLOB NULL DEFAULT NULL,
`email` VARCHAR(50) NULL DEFAULT NULL,
`store_id` TINYINT UNSIGNED NOT NULL,
`active` TINYINT(1) NOT NULL DEFAULT TRUE,
`username` VARCHAR(16) NOT NULL,
`password` VARCHAR(40) BINARY NULL DEFAULT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`staff_id`),
INDEX `idx_fk_store_id` (`store_id` ASC),
INDEX `idx_fk_address_id` (`address_id` ASC),
CONSTRAINT `fk_staff_store`
FOREIGN KEY (`store_id`)
REFERENCES `sakila`.`store` (`store_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_staff_address`
FOREIGN KEY (`address_id`)
REFERENCES `sakila`.`address` (`address_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Table store
(16/16)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set utf8
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK store_id TINYINT Yes
manager_staff_id TINYINT Yes
address_id SMALLINT Yes
last_update TIMESTAMP Yes CURRENT_TIMESTAMP
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
idx_unique_manager
No Yes UNIQUE
idx_fk_address_id
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
fk_store_staff Non-Identifying staff store 1:n
fk_store_address Non-Identifying address store 1:n
fk_customer_store Non-Identifying store customer 1:n
fk_inventory_store Non-Identifying store inventory 1:n
fk_staff_store Non-Identifying store staff 1:n
DDL script
CREATE TABLE IF NOT EXISTS `sakila`.`store` (
`store_id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,
`manager_staff_id` TINYINT UNSIGNED NOT NULL,
`address_id` SMALLINT UNSIGNED NOT NULL,
`last_update` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`store_id`),
UNIQUE INDEX `idx_unique_manager` (`manager_staff_id` ASC),
INDEX `idx_fk_address_id` (`address_id` ASC),
CONSTRAINT `fk_store_staff`
FOREIGN KEY (`manager_staff_id`)
REFERENCES `sakila`.`staff` (`staff_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT `fk_store_address`
FOREIGN KEY (`address_id`)
REFERENCES `sakila`.`address` (`address_id`)
ON DELETE RESTRICT
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
Schema test
(2/4)
DDL script
CREATE SCHEMA IF NOT EXISTS `test` DEFAULT CHARACTER SET latin1 
Table t
(1/1)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set latin1
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK id INT(11) Yes
col1 CHAR(20) No NULL
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
DDL script
CREATE TABLE IF NOT EXISTS `test`.`t` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`col1` CHAR(20) NULL DEFAULT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB
AUTO_INCREMENT = 7
DEFAULT CHARACTER SET = latin1
Schema world
(3/4)
DDL script
CREATE SCHEMA IF NOT EXISTS `world` DEFAULT CHARACTER SET utf8mb4 
Table city
(1/3)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set latin1
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK ID INT(11) Yes
Name CHAR(35) Yes ''
CountryCode CHAR(3) Yes ''
District CHAR(20) Yes ''
Population INT(11) Yes '0'
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
CountryCode
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
city_ibfk_1 Non-Identifying country city 1:n
DDL script
CREATE TABLE IF NOT EXISTS `world`.`city` (
`ID` INT(11) NOT NULL AUTO_INCREMENT,
`Name` CHAR(35) NOT NULL DEFAULT '',
`CountryCode` CHAR(3) NOT NULL DEFAULT '',
`District` CHAR(20) NOT NULL DEFAULT '',
`Population` INT(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
INDEX `CountryCode` (`CountryCode` ASC),
CONSTRAINT `city_ibfk_1`
FOREIGN KEY (`CountryCode`)
REFERENCES `world`.`country` (`Code`))
ENGINE = InnoDB
AUTO_INCREMENT = 4080
DEFAULT CHARACTER SET = latin1
Table country
(2/3)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set latin1
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK Code CHAR(3) Yes ''
Name CHAR(52) Yes ''
Continent ENUM('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') Yes 'Asia'
Region CHAR(26) Yes ''
SurfaceArea FLOAT(10,2) Yes '0.00'
IndepYear SMALLINT(6) No NULL
Population INT(11) Yes '0'
LifeExpectancy FLOAT(3,1) No NULL
GNP FLOAT(10,2) No NULL
GNPOld FLOAT(10,2) No NULL
LocalName CHAR(45) Yes ''
GovernmentForm CHAR(45) Yes ''
HeadOfState CHAR(60) No NULL
Capital INT(11) No NULL
Code2 CHAR(2) Yes ''
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
city_ibfk_1 Non-Identifying country city 1:n
countryLanguage_ibfk_1 Non-Identifying country countrylanguage 1:n
DDL script
CREATE TABLE IF NOT EXISTS `world`.`country` (
`Code` CHAR(3) NOT NULL DEFAULT '',
`Name` CHAR(52) NOT NULL DEFAULT '',
`Continent` ENUM('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia',
`Region` CHAR(26) NOT NULL DEFAULT '',
`SurfaceArea` FLOAT(10,2) NOT NULL DEFAULT '0.00',
`IndepYear` SMALLINT(6) NULL DEFAULT NULL,
`Population` INT(11) NOT NULL DEFAULT '0',
`LifeExpectancy` FLOAT(3,1) NULL DEFAULT NULL,
`GNP` FLOAT(10,2) NULL DEFAULT NULL,
`GNPOld` FLOAT(10,2) NULL DEFAULT NULL,
`LocalName` CHAR(45) NOT NULL DEFAULT '',
`GovernmentForm` CHAR(45) NOT NULL DEFAULT '',
`HeadOfState` CHAR(60) NULL DEFAULT NULL,
`Capital` INT(11) NULL DEFAULT NULL,
`Code2` CHAR(2) NOT NULL DEFAULT '',
PRIMARY KEY (`Code`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
Table countrylanguage
(3/3)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set latin1
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
FK CountryCode CHAR(3) Yes ''
PK Language CHAR(30) Yes ''
IsOfficial ENUM('T','F') Yes 'F'
Percentage FLOAT(4,1) Yes '0.0'
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
CountryCode
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
countryLanguage_ibfk_1 Identifying country countrylanguage 1:n
DDL script
CREATE TABLE IF NOT EXISTS `world`.`countrylanguage` (
`CountryCode` CHAR(3) NOT NULL DEFAULT '',
`Language` CHAR(30) NOT NULL DEFAULT '',
`IsOfficial` ENUM('T','F') NOT NULL DEFAULT 'F',
`Percentage` FLOAT(4,1) NOT NULL DEFAULT '0.0',
PRIMARY KEY (`CountryCode`, `Language`),
INDEX `CountryCode` (`CountryCode` ASC),
CONSTRAINT `countryLanguage_ibfk_1`
FOREIGN KEY (`CountryCode`)
REFERENCES `world`.`country` (`Code`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
Schema world2
(4/4)
DDL script
CREATE SCHEMA IF NOT EXISTS `world2` DEFAULT CHARACTER SET utf8mb4 
Table city
(1/3)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set latin1
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK ID INT(11) Yes
Name CHAR(35) Yes ''
CountryCode CHAR(3) Yes ''
District CHAR(20) Yes ''
Population INT(11) Yes '0'
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
CountryCode
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
city_ibfk_1 Non-Identifying country city 1:n
DDL script
CREATE TABLE IF NOT EXISTS `world2`.`city` (
`ID` INT(11) NOT NULL AUTO_INCREMENT,
`Name` CHAR(35) NOT NULL DEFAULT '',
`CountryCode` CHAR(3) NOT NULL DEFAULT '',
`District` CHAR(20) NOT NULL DEFAULT '',
`Population` INT(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
INDEX `CountryCode` (`CountryCode` ASC),
CONSTRAINT `city_ibfk_1`
FOREIGN KEY (`CountryCode`)
REFERENCES `world2`.`country` (`Code`))
ENGINE = InnoDB
AUTO_INCREMENT = 4080
DEFAULT CHARACTER SET = latin1
Table country
(2/3)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set latin1
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
PK Code CHAR(3) Yes ''
Name CHAR(52) Yes ''
Continent ENUM('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') Yes 'Asia'
Region CHAR(26) Yes ''
SurfaceArea FLOAT(10,2) Yes '0.00'
IndepYear SMALLINT(6) No NULL
Population INT(11) Yes '0'
LifeExpectancy FLOAT(3,1) No NULL
GNP FLOAT(10,2) No NULL
GNPOld FLOAT(10,2) No NULL
LocalName CHAR(45) Yes ''
GovernmentForm CHAR(45) Yes ''
HeadOfState CHAR(60) No NULL
Capital INT(11) No NULL
Code2 CHAR(2) Yes ''
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
city_ibfk_1 Non-Identifying country city 1:n
countryLanguage_ibfk_1 Non-Identifying country countrylanguage 1:n
DDL script
CREATE TABLE IF NOT EXISTS `world2`.`country` (
`Code` CHAR(3) NOT NULL DEFAULT '',
`Name` CHAR(52) NOT NULL DEFAULT '',
`Continent` ENUM('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia',
`Region` CHAR(26) NOT NULL DEFAULT '',
`SurfaceArea` FLOAT(10,2) NOT NULL DEFAULT '0.00',
`IndepYear` SMALLINT(6) NULL DEFAULT NULL,
`Population` INT(11) NOT NULL DEFAULT '0',
`LifeExpectancy` FLOAT(3,1) NULL DEFAULT NULL,
`GNP` FLOAT(10,2) NULL DEFAULT NULL,
`GNPOld` FLOAT(10,2) NULL DEFAULT NULL,
`LocalName` CHAR(45) NOT NULL DEFAULT '',
`GovernmentForm` CHAR(45) NOT NULL DEFAULT '',
`HeadOfState` CHAR(60) NULL DEFAULT NULL,
`Capital` INT(11) NULL DEFAULT NULL,
`Code2` CHAR(2) NOT NULL DEFAULT '',
PRIMARY KEY (`Code`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1
Table countrylanguage
(3/3)
Table Properties
Average Row Length n/a Use Check Sum no
Connection String n/a Default Character Set latin1
Default Collation n/a Delay Key Updates no
Minimal Row Count n/a Maximum Row Count n/a
Union Tables n/a Merge Method n/a
Pack Keys n/a Has Password no
Data Directory n/a Index Directory n/a
Engine InnoDB Row Format n/a
Columns
Key Column Name Datatype Not Null Default Comment
FK CountryCode CHAR(3) Yes ''
PK Language CHAR(30) Yes ''
IsOfficial ENUM('T','F') Yes 'F'
Percentage FLOAT(4,1) Yes '0.0'
Indices
Index Name Columns Primary Unique Type Kind Comment
PRIMARY
Yes No PRIMARY
CountryCode
No No INDEX
Relationships
Relationship Name Relationship Type Parent Table Child Table Card.
countryLanguage_ibfk_1 Identifying country countrylanguage 1:n
DDL script
CREATE TABLE IF NOT EXISTS `world2`.`countrylanguage` (
`CountryCode` CHAR(3) NOT NULL DEFAULT '',
`Language` CHAR(30) NOT NULL DEFAULT '',
`IsOfficial` ENUM('T','F') NOT NULL DEFAULT 'F',
`Percentage` FLOAT(4,1) NOT NULL DEFAULT '0.0',
PRIMARY KEY (`CountryCode`, `Language`),
INDEX `CountryCode` (`CountryCode` ASC),
CONSTRAINT `countryLanguage_ibfk_1`
FOREIGN KEY (`CountryCode`)
REFERENCES `world2`.`country` (`Code`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1