diff --git a/db.sql b/db.sql new file mode 100644 index 0000000..c9941b9 --- /dev/null +++ b/db.sql @@ -0,0 +1,155 @@ +-- MariaDB dump 10.19-11.3.2-MariaDB, for Linux (x86_64) +-- +-- Host: 127.0.0.1 Database: brief_05 +-- ------------------------------------------------------ +-- Server version 10.3.39-MariaDB-1:10.3.39+maria~ubu2004 + +/*!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 */; +/*!40101 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 */; + +-- +-- Table structure for table `brands` +-- + +DROP TABLE IF EXISTS `brands`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `brands` ( + `id` varchar(36) NOT NULL, + `slug_name` varchar(32) NOT NULL, + `display_name` varchar(32) NOT NULL DEFAULT `slug_name`, + `image_blob` blob DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `slug_name` (`slug_name`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `categories` +-- + +DROP TABLE IF EXISTS `categories`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `categories` ( + `id` varchar(36) NOT NULL, + `slug_name` varchar(32) NOT NULL, + `display_name` varchar(32) NOT NULL DEFAULT `slug_name`, + PRIMARY KEY (`id`), + UNIQUE KEY `categories_pk` (`slug_name`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `models` +-- + +DROP TABLE IF EXISTS `models`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `models` ( + `id` varchar(36) NOT NULL, + `slug_name` varchar(32) NOT NULL, + `display_name` varchar(32) NOT NULL DEFAULT `slug_name`, + `brand_id` varchar(36) DEFAULT NULL, + `category_id` varchar(36) DEFAULT NULL, + `image_blob` blob DEFAULT NULL, + `is_trending` tinyint(1) DEFAULT 0, + `base_price` float NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `slug_name` (`slug_name`), + KEY `models_brands_id_fk` (`brand_id`), + KEY `models_categories_id_fk` (`category_id`), + CONSTRAINT `models_brands_id_fk` FOREIGN KEY (`brand_id`) REFERENCES `brands` (`id`) ON UPDATE CASCADE, + CONSTRAINT `models_categories_id_fk` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `rent` +-- + +DROP TABLE IF EXISTS `rent`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `rent` ( + `vehicle_id` varchar(36) NOT NULL, + `user_id` varchar(36) NOT NULL, + `active` tinyint(1) NOT NULL, + `iat` date NOT NULL, + `eat` date NOT NULL, + `need_survey` tinyint(1) DEFAULT NULL, + `km_at_start` int(11) DEFAULT NULL, + `id` tinyint(1) NOT NULL, + PRIMARY KEY (`id`), + KEY `rent_vehicles_id_fk` (`vehicle_id`), + KEY `rent_users_id_fk` (`user_id`), + CONSTRAINT `rent_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON UPDATE CASCADE, + CONSTRAINT `rent_vehicles_id_fk` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `users` +-- + +DROP TABLE IF EXISTS `users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `users` ( + `id` varchar(36) NOT NULL, + `username` varchar(12) NOT NULL, + `firstname` varchar(16) DEFAULT NULL, + `lastname` varchar(16) DEFAULT NULL, + `dob` date DEFAULT NULL, + `email` varchar(32) NOT NULL, + `is_admin` tinyint(1) NOT NULL DEFAULT 0, + `gdpr` date NOT NULL, + `hash` varchar(97) NOT NULL, + `is_email_verified` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + UNIQUE KEY `users_pk` (`id`), + UNIQUE KEY `users_pk_2` (`id`), + UNIQUE KEY `username` (`username`), + UNIQUE KEY `email` (`email`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `vehicles` +-- + +DROP TABLE IF EXISTS `vehicles`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `vehicles` ( + `id` varchar(36) NOT NULL, + `plate_number` varchar(8) DEFAULT NULL, + `model_id` varchar(36) NOT NULL, + `odometer` int(11) NOT NULL DEFAULT 0, + `health_state` float NOT NULL, + `isAvailable` tinyint(1) NOT NULL DEFAULT 1, + PRIMARY KEY (`id`), + KEY `vehicles_models_id_fk` (`model_id`), + CONSTRAINT `vehicles_models_id_fk` FOREIGN KEY (`model_id`) REFERENCES `models` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +/*!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 2024-04-29 14:54:00 diff --git a/schema-db.png b/schema-db.png new file mode 100644 index 0000000..fd09de2 Binary files /dev/null and b/schema-db.png differ