Files
sql_advanced/lab2-1/CarRental.sql
T
Vitalii Litvinchuk 6deed0469a first commit
2026-05-04 23:15:09 +03:00

405 lines
14 KiB
SQL
Executable File

-- MySQL dump 10.13 Distrib 9.6.0, for Linux (x86_64)
--
-- Host: localhost Database: CarRental
-- ------------------------------------------------------
-- Server version 9.6.0
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
SET @MYSQLDUMP_TEMP_LOG_BIN = @@SESSION.SQL_LOG_BIN;
SET @@SESSION.SQL_LOG_BIN= 0;
--
-- GTID state at the beginning of the backup
--
SET @@GLOBAL.GTID_PURGED=/*!80000 '+'*/ '8e6de61c-253f-11f1-be75-0242ac130002:1-141';
--
-- Table structure for table `Car_Classes`
--
DROP TABLE IF EXISTS `Car_Classes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `Car_Classes` (
`id` int NOT NULL AUTO_INCREMENT,
`Class` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Car_Classes`
--
LOCK TABLES `Car_Classes` WRITE;
/*!40000 ALTER TABLE `Car_Classes` DISABLE KEYS */;
INSERT INTO `Car_Classes` VALUES (1,'Luxury'),(2,'Midsize'),(3,'Compact'),(4,'Compact'),(5,'SUV');
/*!40000 ALTER TABLE `Car_Classes` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Car_Infos`
--
DROP TABLE IF EXISTS `Car_Infos`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `Car_Infos` (
`id` int NOT NULL AUTO_INCREMENT,
`Fuel` int DEFAULT NULL,
`Mileage` int DEFAULT NULL,
`Class` int DEFAULT NULL,
`Model` int DEFAULT NULL,
`Manufacturer` int DEFAULT NULL,
`Year` int DEFAULT NULL,
`VIN_code` varchar(255) DEFAULT NULL,
`Number` varchar(255) DEFAULT NULL,
`CoS` int DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `VIN_code` (`VIN_code`),
KEY `Fuel` (`Fuel`),
KEY `Class` (`Class`),
KEY `Model` (`Model`),
KEY `Manufacturer` (`Manufacturer`),
CONSTRAINT `Car_Infos_ibfk_1` FOREIGN KEY (`Fuel`) REFERENCES `FuelTypes` (`id`),
CONSTRAINT `Car_Infos_ibfk_2` FOREIGN KEY (`Class`) REFERENCES `Car_Classes` (`id`),
CONSTRAINT `Car_Infos_ibfk_3` FOREIGN KEY (`Model`) REFERENCES `Models` (`id`),
CONSTRAINT `Car_Infos_ibfk_4` FOREIGN KEY (`Manufacturer`) REFERENCES `Manufacturers` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Car_Infos`
--
LOCK TABLES `Car_Infos` WRITE;
/*!40000 ALTER TABLE `Car_Infos` DISABLE KEYS */;
INSERT INTO `Car_Infos` VALUES (1,1,10000,1,1,1,2022,'ABC123','12345',1),(2,2,20000,2,2,2,2021,'DEF456','67890',2),(3,3,30000,3,3,3,2020,'GHI789','ABCDE',3),(4,4,40000,4,4,4,2019,'JKL012','FGHIJ',4),(5,5,50000,5,5,5,2018,'MNO345','KLMNO',5);
/*!40000 ALTER TABLE `Car_Infos` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Cars`
--
DROP TABLE IF EXISTS `Cars`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `Cars` (
`id` int NOT NULL AUTO_INCREMENT,
`Owner_Id` int DEFAULT NULL,
`Name` varchar(255) DEFAULT NULL,
`Price` float DEFAULT NULL,
`Rating` int DEFAULT NULL,
`Number_Of_leases` int DEFAULT NULL,
`Car_info` int DEFAULT NULL,
`City` int DEFAULT NULL,
`Country` int DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `Rating` (`Rating`),
KEY `Car_info` (`Car_info`),
KEY `City` (`City`),
KEY `Country` (`Country`),
CONSTRAINT `Cars_ibfk_1` FOREIGN KEY (`Rating`) REFERENCES `Ratings` (`id`),
CONSTRAINT `Cars_ibfk_2` FOREIGN KEY (`Car_info`) REFERENCES `Car_Infos` (`id`),
CONSTRAINT `Cars_ibfk_3` FOREIGN KEY (`City`) REFERENCES `Cities` (`id`),
CONSTRAINT `Cars_ibfk_4` FOREIGN KEY (`Country`) REFERENCES `Countries` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Cars`
--
LOCK TABLES `Cars` WRITE;
/*!40000 ALTER TABLE `Cars` DISABLE KEYS */;
INSERT INTO `Cars` VALUES (1,1,'Mercedes A-Class',100,1,0,1,1,1),(2,2,'Toyota RAV4',150,2,0,2,2,2),(3,3,'BMW 3 Series',200,3,0,3,3,3),(4,4,'Ford Focus',250,4,0,4,4,4),(5,5,'Honda CR-V',300,5,0,5,5,5);
/*!40000 ALTER TABLE `Cars` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Cities`
--
DROP TABLE IF EXISTS `Cities`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `Cities` (
`id` int NOT NULL AUTO_INCREMENT,
`City` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Cities`
--
LOCK TABLES `Cities` WRITE;
/*!40000 ALTER TABLE `Cities` DISABLE KEYS */;
INSERT INTO `Cities` VALUES (1,'New York'),(2,'Tokyo'),(3,'Berlin'),(4,'Detroit'),(5,'Tokyo');
/*!40000 ALTER TABLE `Cities` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Countries`
--
DROP TABLE IF EXISTS `Countries`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `Countries` (
`id` int NOT NULL AUTO_INCREMENT,
`Country` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Countries`
--
LOCK TABLES `Countries` WRITE;
/*!40000 ALTER TABLE `Countries` DISABLE KEYS */;
INSERT INTO `Countries` VALUES (1,'USA'),(2,'Japan'),(3,'Germany'),(4,'USA'),(5,'Japan');
/*!40000 ALTER TABLE `Countries` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `CustomerRatings`
--
DROP TABLE IF EXISTS `CustomerRatings`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `CustomerRatings` (
`id` int NOT NULL AUTO_INCREMENT,
`Customer_id` int DEFAULT NULL,
`Rating_id` int DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `Customer_id` (`Customer_id`,`Rating_id`),
KEY `Rating_id` (`Rating_id`),
CONSTRAINT `CustomerRatings_ibfk_1` FOREIGN KEY (`Customer_id`) REFERENCES `Customers` (`id`),
CONSTRAINT `CustomerRatings_ibfk_2` FOREIGN KEY (`Rating_id`) REFERENCES `Ratings` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `CustomerRatings`
--
LOCK TABLES `CustomerRatings` WRITE;
/*!40000 ALTER TABLE `CustomerRatings` DISABLE KEYS */;
INSERT INTO `CustomerRatings` VALUES (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5);
/*!40000 ALTER TABLE `CustomerRatings` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Customers`
--
DROP TABLE IF EXISTS `Customers`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `Customers` (
`id` int NOT NULL AUTO_INCREMENT,
`Passport_id` varchar(255) DEFAULT NULL,
`F_Name` varchar(255) DEFAULT NULL,
`S_Name` varchar(255) DEFAULT NULL,
`Email` varchar(255) DEFAULT NULL,
`PhoneNumber` varchar(20) DEFAULT NULL,
`City` int DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `Passport_id` (`Passport_id`),
UNIQUE KEY `PhoneNumber` (`PhoneNumber`),
UNIQUE KEY `PhoneNumber_2` (`PhoneNumber`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Customers`
--
LOCK TABLES `Customers` WRITE;
/*!40000 ALTER TABLE `Customers` DISABLE KEYS */;
INSERT INTO `Customers` VALUES (1,'ID123','John','Doe','john.doe@email.com','1234567890',1),(2,'ID456','Jane','Smith','jane.smith@email.com','9876543210',2),(3,'ID789','Alice','Johnson','alice.johnson@email.com','5555555555',3),(4,'IDABC','Bob','Williams','bob.williams@email.com','1111111111',4),(5,'IDDEF','Eva','Brown','eva.brown@email.com','9999999999',5);
/*!40000 ALTER TABLE `Customers` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `FuelTypes`
--
DROP TABLE IF EXISTS `FuelTypes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `FuelTypes` (
`id` int NOT NULL AUTO_INCREMENT,
`Type` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `FuelTypes`
--
LOCK TABLES `FuelTypes` WRITE;
/*!40000 ALTER TABLE `FuelTypes` DISABLE KEYS */;
INSERT INTO `FuelTypes` VALUES (1,'Gasoline'),(2,'Gasoline'),(3,'Diesel'),(4,'Gasoline'),(5,'Hybrid');
/*!40000 ALTER TABLE `FuelTypes` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Manufacturers`
--
DROP TABLE IF EXISTS `Manufacturers`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `Manufacturers` (
`id` int NOT NULL AUTO_INCREMENT,
`Name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Manufacturers`
--
LOCK TABLES `Manufacturers` WRITE;
/*!40000 ALTER TABLE `Manufacturers` DISABLE KEYS */;
INSERT INTO `Manufacturers` VALUES (1,'Mercedes'),(2,'Toyota'),(3,'BMW'),(4,'Ford'),(5,'Honda');
/*!40000 ALTER TABLE `Manufacturers` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Models`
--
DROP TABLE IF EXISTS `Models`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `Models` (
`id` int NOT NULL AUTO_INCREMENT,
`Model` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Models`
--
LOCK TABLES `Models` WRITE;
/*!40000 ALTER TABLE `Models` DISABLE KEYS */;
INSERT INTO `Models` VALUES (1,'S-Class'),(2,'Camry'),(3,'3 Series'),(4,'Focus'),(5,'CR-V');
/*!40000 ALTER TABLE `Models` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Orders`
--
DROP TABLE IF EXISTS `Orders`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `Orders` (
`id` int NOT NULL AUTO_INCREMENT,
`StartDate` date DEFAULT NULL,
`EndDate` date DEFAULT NULL,
`Customers` int DEFAULT NULL,
`Car` int DEFAULT NULL,
`Status` int DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `Customers` (`Customers`),
KEY `Car` (`Car`),
KEY `Status` (`Status`),
CONSTRAINT `Orders_ibfk_1` FOREIGN KEY (`Customers`) REFERENCES `Customers` (`id`),
CONSTRAINT `Orders_ibfk_2` FOREIGN KEY (`Car`) REFERENCES `Cars` (`id`),
CONSTRAINT `Orders_ibfk_3` FOREIGN KEY (`Status`) REFERENCES `Statuses` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Orders`
--
LOCK TABLES `Orders` WRITE;
/*!40000 ALTER TABLE `Orders` DISABLE KEYS */;
INSERT INTO `Orders` VALUES (1,'2023-01-01','2023-01-10',1,1,1),(2,'2023-02-01','2023-02-15',2,2,2),(3,'2023-03-01','2023-03-20',3,3,3),(4,'2023-04-01','2023-04-25',4,4,4),(5,'2023-05-01','2023-05-30',5,5,5);
/*!40000 ALTER TABLE `Orders` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Ratings`
--
DROP TABLE IF EXISTS `Ratings`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `Ratings` (
`id` int NOT NULL AUTO_INCREMENT,
`Rating` int DEFAULT NULL,
`DescriptionRate` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Ratings`
--
LOCK TABLES `Ratings` WRITE;
/*!40000 ALTER TABLE `Ratings` DISABLE KEYS */;
INSERT INTO `Ratings` VALUES (1,1,'Poor'),(2,2,'Fair'),(3,3,'Average'),(4,4,'Good'),(5,5,'Excellent');
/*!40000 ALTER TABLE `Ratings` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `Statuses`
--
DROP TABLE IF EXISTS `Statuses`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `Statuses` (
`id` int NOT NULL AUTO_INCREMENT,
`Type` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `Statuses`
--
LOCK TABLES `Statuses` WRITE;
/*!40000 ALTER TABLE `Statuses` DISABLE KEYS */;
INSERT INTO `Statuses` VALUES (1,'Available'),(2,'Booked'),(3,'Rented'),(4,'In Maintenance'),(5,'Available');
/*!40000 ALTER TABLE `Statuses` ENABLE KEYS */;
UNLOCK TABLES;
SET @@SESSION.SQL_LOG_BIN = @MYSQLDUMP_TEMP_LOG_BIN;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2026-03-25 14:38:18