-- create a table `libro`
CREATE TABLE film (
id_film INT NOT NULL,
titolo VARCHAR(45) NOT NULL,
anno_pubblicazione INT NULL,
PRIMARY KEY (id_film)
);
CREATE TABLE attore (
id_attore INT NOT NULL,
nome VARCHAR(45) NOT NULL,
cognome VARCHAR(45) NOT NULL,
sesso CHAR(1) NULL,
PRIMARY KEY (id_attore)
);
CREATE TABLE categoria (
id_categoria INT NOT NULL,
nome VARCHAR(45) NOT NULL,
PRIMARY KEY (id_categoria)
);
CREATE TABLE attore_film (
id_attore INT NOT NULL,
id_film INT NOT NULL,
personaggio VARCHAR(45) NULL,
sesso_personaggio CHAR(1) NULL,
CONSTRAINT fk_attore_film_attore
FOREIGN KEY (id_attore) REFERENCES attore (id_attore),
CONSTRAINT fk_autore_film_film
FOREIGN KEY (id_film) REFERENCES film (id_film)
);
CREATE TABLE categoria_film (
id_categoria INT NOT NULL,
id_film INT NOT NULL,
CONSTRAINT fk_categoria_film_categoria
FOREIGN KEY (id_categoria) REFERENCES categoria (id_categoria),
CONSTRAINT fk_categoria_film_film
FOREIGN KEY (id_film) REFERENCES film (id_film)
);
-- insert value
INSERT INTO film VALUES ('1', 'L\'attimo fuggente', '1989'),
('2', 'Mrs. Doubtfire', '1993'),('3', 'Matrix', '1999'),('4', 'Boys Don\'t Cry', '1999'),
('5', 'Ritorno al futuro', '1985'),('6', 'Matrix Reloaded', '2003');
INSERT INTO attore VALUES ('1', 'Dustin', 'Hoffman', 'M'),('3', 'Robin', 'Williams', 'M'),
('5', 'Keanu', 'Reeves', 'M'),('6', 'Laurence', 'Fishburne', 'M'),('7', 'Carrie-Anne', 'Moss', 'F'),
('8', 'Hilary', 'Swank', 'F'),('9', 'Micheal J.', 'Fox', 'M'),('10', 'Christopher', 'Lloyd', 'M');
INSERT INTO categoria VALUES ('1', 'COMMEDIA'),('2', 'DRAMMATICO'),('3', 'FANTASCIENZA'),
('4', 'AZIONE'),('5', 'BIOGRAFICO'), ('6', 'AVVENTURA');
INSERT INTO categoria_film VALUES (2, 1),(1, 2),(2, 2),(3, 3),(4, 3),(5, 4),(2, 4),(6, 5),(1, 5),(3, 5),(3, 6),(4, 6);
INSERT INTO attore_film VALUES (1,1,'Prof. John Keating','M');
INSERT INTO attore_film VALUES (3,2,'Daniel Hillard','M'),(3,2,'Mrs. Doubtfire','F');
INSERT INTO attore_film VALUES (5,3,'Neo','M'),(6,3,'Morpeus','M'),(7,3,'Trinity','F');
INSERT INTO attore_film VALUES (8,4,'Brandon Teena','M'),(8,4,'Teena Brandon','F');
INSERT INTO attore_film VALUES (9,5,'Marty McFly','M'),(10,5,'Doc','M');
INSERT INTO attore_film VALUES (5,6,'Neo','M'),(6,6,'Morpeus','M'),(7,6,'Trinity','F');
-- query
To embed this project on your website, copy the following code and paste it into your website's HTML: