Професионална програма
Loading...
+ Нов въпрос
MartinMitov avatar MartinMitov 0 Точки

11. Movies Database от Exercises: Data Definition and Data Types

Здравейте гърми ми тест 4 дава ми 90/100

CREATE TABLE `directors`(
`id` INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
`director_name` VARCHAR(50) NOT NULL,
`notes` TEXT 
);
INSERT INTO `directors`(`id`,`director_name`, `notes`)
VALUES
('1','Pesho',NULL), 
('2','Ivan',NULL), 
('3','Gosho',NULL), 
('4','Tapata',NULL), 
('5','Ali',NULL) 
;

CREATE TABLE `genres`(
`id` INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
`genre_name` VARCHAR(50) NOT NULL,
`notes` TEXT
);

INSERT INTO `genres` (`id`, `genre_name`, `notes`)
VALUES
('1','Parody',NULL),
('2','Comedy',NULL),
('3','Drama',NULL),
('4','Action',NULL),
('5','Animation',NULL)
;

CREATE TABLE `categories`(
`id` INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
`category_name` VARCHAR(50) NOT NULL,
`notes` TEXT
);

INSERT INTO `categories` (`id`, `category_name`, `notes`)
VALUES
('1', '+0', NULL),
('2', '+6', NULL),
('3', '+12', NULL),
('4', '+16', NULL),
('5', '+18', NULL)
;

CREATE TABLE `movies`(
`id` INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
`title` VARCHAR(50) NOT NULL,
`director_id` INT ,
CONSTRAINT fk_director_id
FOREIGN KEY (`director_id`)
REFERENCES `directors`(`id`),
`copyright_year` YEAR,
`lenght` TIME,
`genre_id` INT,
CONSTRAINT fk_genre_id
FOREIGN KEY (`genre_id`)
REFERENCES `genres`(`id`),
`category_id` INT,
CONSTRAINT fk_category_id
FOREIGN KEY (`category_id`)
REFERENCES `categories`(`id`),
`rating` DECIMAL(2,1),
`notes` TEXT
);

INSERT INTO `movies`(`id`, `title`, `director_id`, `copyright_year`,`lenght`, `genre_id`,`category_id`, `rating`, `notes`)
VALUES
('1', 'No comment', '1', '1991', '00:05:00', '1','1', NULL, NULL),
('2', 'No comment', '2', '1992', '00:04:00', '2','5', NULL, NULL),
('3', 'No comment', '3', '1993', '00:03:00', '5','4', NULL, NULL),
('4', 'No comment', '4', '1994', '00:02:00', '4', '3', NULL, NULL),
('5', 'No comment', '4', '1995', '00:01:00', '3','2', NULL, NULL)
;

0
Databases Basics - MySQL
icowwww avatar icowwww 1153 Точки
Best Answer

Здравей,

Полето lenght в таблица movies е изписано грешно, но не е заради това грешката. Премахни constaint-ите и ще мине.

https://pastebin.com/336P3f76

 

 

0
MartinMitov avatar MartinMitov 0 Точки

Благодаря

0