-- --------------------------------------------------------
-- Host:                         127.0.0.1
-- Server version:               10.4.32-MariaDB - mariadb.org binary distribution
-- Server OS:                    Win64
-- HeidiSQL Version:             12.11.0.7065
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!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 */;

-- Dumping structure for table auto_web_dv.brands
CREATE TABLE IF NOT EXISTS `brands` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Brand ID',
  `name` varchar(50) NOT NULL COMMENT 'Brand name',
  `description` text NOT NULL COMMENT 'Info about brand',
  `views` int(11) NOT NULL DEFAULT 0 COMMENT 'How many users viewed this brand',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Stores all car brands';

-- Dumping data for table auto_web_dv.brands: ~2 rows (approximately)
INSERT INTO `brands` (`id`, `name`, `description`, `views`, `created_at`) VALUES
	(1, 'BMW', 'German performance brand', 0, '2026-02-01 19:10:49'),
	(2, 'Audi', 'Premium German automaker', 0, '2026-02-01 19:11:02'),
	(3, '	Mercedes', 'Luxury German manufacturer', 0, '2026-02-01 19:11:08');

-- Dumping structure for table auto_web_dv.comments
CREATE TABLE IF NOT EXISTS `comments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brand_id` int(11) NOT NULL COMMENT 'Which brand is the comment meant for',
  `model_id` int(11) NOT NULL COMMENT 'Which model is the comment meant for',
  `image_url` varchar(255) DEFAULT NULL COMMENT 'Image of the provided vechicle',
  `username` varchar(50) DEFAULT NULL,
  `comment_text` text NOT NULL COMMENT 'User provided comment',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `FK_comments_brands` (`brand_id`),
  KEY `FK_comments_models` (`model_id`),
  CONSTRAINT `FK_comments_brands` FOREIGN KEY (`brand_id`) REFERENCES `brands` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_comments_models` FOREIGN KEY (`model_id`) REFERENCES `models` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='User submited comments with their posted images';

-- Dumping data for table auto_web_dv.comments: ~5 rows (approximately)
INSERT INTO `comments` (`id`, `brand_id`, `model_id`, `image_url`, `username`, `comment_text`, `created_at`) VALUES
	(2, 1, 1, 'NULL', 'Janis', 'Ļoti labs auto!', '2026-02-01 19:15:50'),
	(3, 2, 1, NULL, 'Laura', 'RS6 ir zvērs', '2026-02-01 19:16:12'),
	(4, 3, 4, NULL, 'Andris', 'AMG skaņa ir neprātīga', '2026-02-01 19:17:01'),
	(7, 2, 3, NULL, 'Anonīms', 'Kruts', '2026-03-30 20:28:53'),
	(8, 1, 2, NULL, 'Laura', 'Kruts', '2026-03-30 20:29:08');

-- Dumping structure for table auto_web_dv.featured_cars
CREATE TABLE IF NOT EXISTS `featured_cars` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `model_id` int(11) NOT NULL COMMENT 'Which specific car was chosen',
  `added_by` varchar(50) NOT NULL COMMENT 'Person/Manager who chose the vechicle',
  `reason` text DEFAULT NULL COMMENT 'Why the person/manager chose this specific car',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `FK__models` (`model_id`),
  CONSTRAINT `FK__models` FOREIGN KEY (`model_id`) REFERENCES `models` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Cars chosen by one of the website managers';

-- Dumping data for table auto_web_dv.featured_cars: ~2 rows (approximately)
INSERT INTO `featured_cars` (`id`, `model_id`, `added_by`, `reason`, `created_at`) VALUES
	(1, 1, 'Admin', '	Legendary performance', '2026-02-01 19:12:48'),
	(2, 3, 'Admin', 'Brutal acceleration', '2026-02-01 19:13:03');

-- Dumping structure for table auto_web_dv.home_highlights
CREATE TABLE IF NOT EXISTS `home_highlights` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `model_id` int(11) NOT NULL COMMENT 'Car shown on the main/home page',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `FK_home_highlights_models` (`model_id`),
  CONSTRAINT `FK_home_highlights_models` FOREIGN KEY (`model_id`) REFERENCES `models` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Shows which cars/vechicles are currently shown on the main page';

-- Dumping data for table auto_web_dv.home_highlights: ~2 rows (approximately)
INSERT INTO `home_highlights` (`id`, `model_id`, `created_at`) VALUES
	(1, 1, '2026-02-01 19:12:48'),
	(2, 3, '2026-02-01 19:32:48');

-- Dumping structure for table auto_web_dv.models
CREATE TABLE IF NOT EXISTS `models` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Model ID',
  `brand_id` int(11) NOT NULL COMMENT 'Brand name',
  `name` varchar(50) NOT NULL COMMENT 'Model name',
  `year` int(11) NOT NULL COMMENT 'Release year',
  `description` text DEFAULT NULL COMMENT 'Description about the model',
  `image_url` varchar(255) NOT NULL COMMENT 'Car model image',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `FK__brands` (`brand_id`),
  CONSTRAINT `FK__brands` FOREIGN KEY (`brand_id`) REFERENCES `brands` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Models for each car brand';

-- Dumping data for table auto_web_dv.models: ~4 rows (approximately)
INSERT INTO `models` (`id`, `brand_id`, `name`, `year`, `description`, `image_url`, `created_at`) VALUES
	(1, 1, 'BMW M3', 2020, 'High‑performance sedan', '/uploads/bmw_m3.webp', '2026-02-01 19:11:36'),
	(2, 1, 'BMW X5', 2019, 'Luxury SUV', '/uploads/bmw_x5.avif', '2026-02-01 19:11:52'),
	(3, 2, 'Audi RS6', 2021, 'Powerful family wagon', '/uploads/audi_rs6.jpg', '2026-02-01 19:12:07'),
	(4, 3, '	Mercedes C63', 2018, 'AMG performance sedan', '/uploads/mercedes_c63.avif', '2026-02-01 19:12:22');

-- Dumping structure for table auto_web_dv.models_views
CREATE TABLE IF NOT EXISTS `models_views` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `model_id` int(11) NOT NULL COMMENT 'Which model was looked at',
  `viewed_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `FK_models_views_models` (`model_id`),
  CONSTRAINT `FK_models_views_models` FOREIGN KEY (`model_id`) REFERENCES `models` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Used to see user activity';

-- Dumping data for table auto_web_dv.models_views: ~12 rows (approximately)
INSERT INTO `models_views` (`id`, `model_id`, `viewed_at`) VALUES
	(1, 1, '2026-02-01 19:17:11'),
	(2, 3, '2026-02-01 19:17:17'),
	(3, 3, '2026-02-01 19:17:22'),
	(4, 4, '2026-03-30 21:12:19'),
	(5, 4, '2026-03-30 21:12:19'),
	(6, 4, '2026-03-30 21:13:02'),
	(7, 4, '2026-03-30 21:22:07'),
	(8, 4, '2026-03-30 21:22:07'),
	(9, 2, '2026-03-30 21:22:15'),
	(10, 1, '2026-03-30 21:24:38'),
	(11, 2, '2026-03-30 22:44:15'),
	(12, 2, '2026-03-30 22:44:16'),
	(13, 2, '2026-03-30 22:44:16');

/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;
