CREATE DATABASE  IF NOT EXISTS `ExamenDic2024` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `ExamenDic2024`;
--
-- Host: 51.222.107.16    Database: ExamenDic2024
-- ------------------------------------------------------


--
-- Table structure for table `cinemas`
--

CREATE TABLE `cinemas` (
  `idCinema` int NOT NULL AUTO_INCREMENT,
  `name` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  PRIMARY KEY (`idCinema`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `cinemas`
--

INSERT INTO `cinemas` VALUES (1,'Yelmo Cines','Rincón de la Victoria, Málaga'),(2,'Mk2 CineSur Málaga Nostrum','Calle Jaen, 1, 29004, Málaga'),(3,'Cine Yelmo Vialia Málaga','Explanada De La Estacion 29002, Málaga');

--
-- Table structure for table `movies`
--

CREATE TABLE `movies` (
  `idMovie` int NOT NULL AUTO_INCREMENT,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `year` int NOT NULL,
  `nationality` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `cover` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  `tickets` int unsigned DEFAULT '0',
  `cinema` int NOT NULL,
  PRIMARY KEY (`idMovie`),
  KEY `category_idx` (`cinema`),
  CONSTRAINT `cinema` FOREIGN KEY (`cinema`) REFERENCES `cinemas` (`idCinema`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `movies`
--

INSERT INTO `movies` VALUES (1,'Friends, la Película',2020,'EEUU','https://cdn.hobbyconsolas.com/sites/navi.axelspringer.es/public/media/image/2016/07/poster-friends.jpg?tf=256x',5,1),(2,'Gladiator 2',2024,'EEUU','https://pics.filmaffinity.com/Gladiator_II-821316540-large.jpg',6,1),(3,'Moana 2',2024,'Gran Bretaña','https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRRBulekkIqapPs5_QbHNG2G1zYTMYUftSOFglrjbvnCVTqKOm0',0,1),(4,'El Señor de los Anillos',2016,'EEUU','https://pics.filmaffinity.com/the_lord_of_the_rings_the_war_of_the_rohirrim-563726775-mmed.jpg',3,2),(5,'Los Simpsons, la película',2019,'EEUU','https://i.pinimg.com/originals/c7/b4/b0/c7b4b0c0265a5bc34089e305f507492f.jpg',60,1),(6,'Al otro barrio',2024,'España','https://pics.filmaffinity.com/al_otro_barrio-964004322-large.jpg',44,2),(7,'Wicked',2024,'EEUU','https://pics.filmaffinity.com/wicked_part_one-562940006-mmed.jpg',3,1),(8,'¿Quién es quién?',2024,'España','https://pics.filmaffinity.com/quien_es_quien-972466781-mmed.jpg',4,2),(9,'SuperKlaus',2024,'España','https://pics.filmaffinity.com/superklaus-261042416-mmed.jpg',0,3),(10,'Venom: El último baile',2024,'EEUU','https://pics.filmaffinity.com/venom_the_last_dance-379990903-mmed.jpg',60,3);

--
-- Table structure for table `purchases`
--

CREATE TABLE `purchases` (
  `idCustomer` int NOT NULL,
  `idMovie` int NOT NULL,
  `date` date NOT NULL,
  `numTickets` int DEFAULT '1',
  PRIMARY KEY (`idCustomer`,`idMovie`,`date`),
  KEY `movie_idx` (`idMovie`),
  CONSTRAINT `customer` FOREIGN KEY (`idCustomer`) REFERENCES `customers` (`idCustomer`) ON DELETE RESTRICT ON UPDATE RESTRICT,
  CONSTRAINT `movie` FOREIGN KEY (`idMovie`) REFERENCES `movies` (`idMovie`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `purchases`
--

INSERT INTO `purchases` VALUES (1,1,'2024-12-07',20),(1,2,'2024-12-07',2),(1,3,'2024-12-07',56),(1,4,'2024-12-07',1),(1,6,'2024-12-07',10),(1,10,'2024-12-07',5),(2,6,'2024-12-08',4),(2,10,'2024-12-07',4),(2,10,'2024-12-08',3),(3,2,'2024-12-08',2),(3,5,'2024-12-08',7),(3,6,'2024-12-08',2),(3,8,'2024-12-08',1),(3,10,'2024-12-08',5);


