DROP TABLE IF EXISTS `movies`;
CREATE TABLE `movies` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `movies` (`title`)
VALUES ('Les tuche'), ('Les tuche 2'), ('Les tuche 3');

INSERT INTO `movies`(`title`) 
VALUES ('Saw'), ('Saw 2'), ('Saw 3'), ('Saw 4'), ('Saw 5'), ('Saw 6'), ('Saw 3D');

DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `categories` (`name`) VALUES ('Horreur'), ('Comédie');

ALTER TABLE movies
ADD COLUMN category_id INT AFTER title;

UPDATE `movies` SET `category_id` = '2' WHERE `movies`.`id` = 1;
UPDATE `movies` SET `category_id` = '2' WHERE `movies`.`id` = 2;
UPDATE `movies` SET `category_id` = '2' WHERE `movies`.`id` = 3;
UPDATE `movies` SET `category_id` = '1' WHERE `movies`.`id` = 4;
UPDATE `movies` SET `category_id` = '1' WHERE `movies`.`id` = 5;
UPDATE `movies` SET `category_id` = '1' WHERE `movies`.`id` = 6;
UPDATE `movies` SET `category_id` = '1' WHERE `movies`.`id` = 7;
UPDATE `movies` SET `category_id` = '1' WHERE `movies`.`id` = 8;
UPDATE `movies` SET `category_id` = '1' WHERE `movies`.`id` = 9;
UPDATE `movies` SET `category_id` = '1' WHERE `movies`.`id` = 10;