-- --------------------------------------------------------
-- Server OS:                    Win64
-- HeidiSQL Version:             12.8.0.6908
-- --------------------------------------------------------



-- Dumping database structure for filmu_sistema
CREATE DATABASE IF NOT EXISTS `filmu_sistema` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */;
USE `filmu_sistema`;

-- Dumping structure for table filmu_sistema.favorites
CREATE TABLE IF NOT EXISTS `favorites` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `movie_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `movie_id` (`movie_id`),
  CONSTRAINT `favorites_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `favorites_ibfk_2` FOREIGN KEY (`movie_id`) REFERENCES `movies` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table filmu_sistema.favorites: ~1 rows (approximately)
INSERT INTO `favorites` (`id`, `user_id`, `movie_id`) VALUES
	(13, 7, 11);

-- Dumping structure for table filmu_sistema.movies
CREATE TABLE IF NOT EXISTS `movies` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `title` varchar(255) NOT NULL,
  `genre` varchar(100) DEFAULT NULL,
  `year` year(4) DEFAULT NULL,
  `director` varchar(150) DEFAULT NULL,
  `rating` decimal(3,1) DEFAULT NULL,
  `status` varchar(20) DEFAULT 'Plānots',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  CONSTRAINT `movies_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table filmu_sistema.movies: ~3 rows (approximately)
INSERT INTO `movies` (`id`, `user_id`, `title`, `genre`, `year`, `director`, `rating`, `status`, `created_at`) VALUES
	(10, 7, 'test1', 'test1', '2001', 'test1', 5.0, 'Plānots', '2026-05-27 21:30:23'),
	(11, 7, 'test2', 'test2', '2002', 'test2', 8.0, 'Plānots', '2026-05-27 21:30:38');

-- Dumping structure for table filmu_sistema.watchlist
CREATE TABLE IF NOT EXISTS `watchlist` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `movie_id` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `movie_id` (`movie_id`),
  CONSTRAINT `watchlist_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `watchlist_ibfk_2` FOREIGN KEY (`movie_id`) REFERENCES `movies` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table filmu_sistema.watchlist: ~2 rows (approximately)
INSERT INTO `watchlist` (`id`, `user_id`, `movie_id`, `created_at`) VALUES
	(9, 9, 11, '2026-06-04 20:56:31'),
	(11, 7, 10, '2026-06-04 22:21:28');

