Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE SCHEMA movies;
- CREATE TABLE directors (
- id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
- director_name VARCHAR(45),
- notes TEXT
- );
- CREATE TABLE genres (
- id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
- genre_name VARCHAR(45),
- notes TEXT
- );
- CREATE TABLE categories (
- id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
- category_name VARCHAR(45),
- notes TEXT
- );
- CREATE TABLE movies (
- id INT PRIMARY KEY NOT NULL AUTO_INCREMENT,
- title VARCHAR(45),
- director_id INT NOT NULL,
- copyright_year DATE NOT NULL,
- length DOUBLE,
- genre_id INT NOT NULL,
- category_id INT NOT NULL,
- rating DOUBLE,
- notes TEXT
- );
- ALTER TABLE movies
- ADD CONSTRAINT director_fk FOREIGN KEY (director_id) REFERENCES directors(id);
- ALTER TABLE movies
- ADD CONSTRAINT genre_fk FOREIGN KEY (genre_id) REFERENCES genres(id);
- ALTER TABLE movies
- ADD CONSTRAINT category_fk FOREIGN KEY (category_id) REFERENCES categories(id);
- INSERT INTO directors (id, director_name, notes)
- VALUES(1, "Daglov", "Strict Director"),
- (2, "Pashov", "Gentle Director"),
- (3, "Manol", "Good"),
- (4, "Stamat", "Excellent"),
- (5, "Granat", "BOMB");
- INSERT INTO genres (id, genre_name, notes)
- VALUES(10, "drama", "notes"),
- (11, "comedy", "notes"),
- (12, "action", "notes"),
- (13, "fantasy", "notes"),
- (14, "horror", "notes");
- INSERT INTO categories (id, category_name, notes)
- VALUES(20, "Thriller", "notes"),
- (21, "Science Fiction", "notes"),
- (22, "Romance", "notes"),
- (23, "Adventure", "notes"),
- (24, "Documentary", "notes");
- INSERT INTO movies (id, title, director_id, copyright_year, length, genre_id, category_id, rating, notes)
- VALUES(100, "Curious Case Of Benjamin Button", 1, '2013-01-01', 120, 10, 22, 10, "Very good movie"),
- (101, "Avengers", 2, '2018-01-01', 180, 12, 21, 10, "Best Movie"),
- (102, "Game of Thrones", 3, '2019-01-01', 100, 13, 23, 100, "My favourite series"),
- (103, "LOTR", 4, '2002-02-02', 220, 13, 23, 10, "All time best"),
- (104, "Matrix", 1, '2002-03-03', 180, 12, 21, 10, "WOW");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement