-- --------------------------------------------------------
-- Server OS:                    Win64
-- HeidiSQL Version:             12.6.0.6765
-- --------------------------------------------------------



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

-- Dumping structure for table notepad.categories
CREATE TABLE IF NOT EXISTS `categories` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Publicētā faila kategorijas id',
  `name` varchar(50) NOT NULL COMMENT 'Publicētā faila kategorijas nosaukums',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Publicētā faila kategorijas';

-- Dumping data for table notepad.categories: ~8 rows (approximately)
INSERT INTO `categories` (`id`, `name`) VALUES
	(1, 'mango'),
	(2, 'juice'),
	(3, 'writing'),
	(4, 'asking'),
	(5, 'limbo'),
	(6, 'jigsaw'),
	(7, 'kitchen'),
	(8, 'food'),
	(9, 'luna'),
	(10, 'moon');

-- Dumping structure for table notepad.comments
CREATE TABLE IF NOT EXISTS `comments` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Publicētā faila komentāra id',
  `published_file_id` int(11) unsigned NOT NULL COMMENT 'Publicētā faila id',
  `user_id` int(11) unsigned NOT NULL COMMENT 'Lietotāja id',
  `text` text NOT NULL COMMENT 'Komentāra saturs',
  `date` date NOT NULL COMMENT 'Komentāra publicēšanas datums',
  `time` time NOT NULL COMMENT 'Komentāra publicēšanas laiks',
  PRIMARY KEY (`id`),
  KEY `FK_comments_published_files` (`published_file_id`),
  KEY `FK_comments_users` (`user_id`),
  CONSTRAINT `FK_comments_published_files` FOREIGN KEY (`published_file_id`) REFERENCES `published_files` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_comments_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Lietotāja pievienotie komentāri publicētiem failiem';

-- Dumping data for table notepad.comments: ~0 rows (approximately)

-- Dumping structure for table notepad.favourites
CREATE TABLE IF NOT EXISTS `favourites` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Lietotāja iemīļotākie publicētie faili id',
  `published_file_id` int(11) unsigned NOT NULL COMMENT 'Publicēto faila id',
  `user_id` int(11) unsigned NOT NULL COMMENT 'Lietotāja id',
  PRIMARY KEY (`id`),
  KEY `FK_favourites_published_files` (`published_file_id`),
  KEY `FK_favourites_users` (`user_id`),
  CONSTRAINT `FK_favourites_published_files` FOREIGN KEY (`published_file_id`) REFERENCES `published_files` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_favourites_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Lietotāja iemīļotākie publicētie faili';

-- Dumping data for table notepad.favourites: ~0 rows (approximately)

-- Dumping structure for table notepad.files
CREATE TABLE IF NOT EXISTS `files` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Faila id',
  `name` varchar(255) NOT NULL COMMENT 'Faila nosaukums',
  `text` text NOT NULL COMMENT 'Faila teksts, kuru lietotājs bija sarakstījis',
  `description` text NOT NULL COMMENT 'Faila apraksts, kuru lietotājs var pievienot vēlāk savā failu sarakstā',
  `image` mediumblob NOT NULL COMMENT 'Faila attēls, kuru lietotājs var pievienot vēlāk savā failu sarakstā',
  `date` date NOT NULL COMMENT 'Datums, kad fails tika izveidots',
  `time` time NOT NULL COMMENT 'Laiks, kad fails tika izveidots',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Tabula, kura glabā lietotāja izveidotos failus.';

-- Dumping data for table notepad.files: ~27 rows (approximately)
INSERT INTO `files` (`id`, `name`, `text`, `description`, `image`, `date`, `time`) VALUES
	(1, 'Mango Juice testing 2', 'Mango juice is best juice', 'This is where my mango juice recipe lies 22342ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg', _binary '', '2025-04-01', '17:41:44'),
	(2, 'TestBold Mango', '<font face="Times New Roman"><b>\n            Testing</b></font>', 'Hmahajaw\r\nMango', _binary '', '2025-04-01', '17:43:16'),
	(3, 'Test2', '<b><i>\n            T</i></b><font face="Verdana">e<font size="4">s</font>t2 </font>t<u>est</u>', '', _binary '', '2025-04-01', '17:45:09'),
	(4, 'TesttingTestTrest', 'Testing test trest', '', _binary '', '2025-04-01', '17:49:21'),
	(5, 'Modal Testing', 'Testing the modal', '', _binary '', '2025-04-01', '17:51:18'),
	(6, 'Modal testing part 2', 'Testing the modal once again boy', '', _binary '', '2025-04-01', '17:53:19'),
	(7, 'Modal testing part 3', 'Testing the modal thingy once more..', '', _binary '', '2025-04-01', '17:55:49'),
	(8, 'Modal testing 4', 'Testing... The modal damn it...', '', _binary '', '2025-04-01', '18:00:10'),
	(9, 'Modals mmm', 'Modals mmmmmm...', '', _binary '', '2025-04-01', '18:03:16'),
	(10, 'Modals like!', 'Modals, me like!', '', _binary '', '2025-04-01', '18:05:30'),
	(11, 'Modals haha', 'Start writing here... Modals haha', '', _binary '', '2025-04-01', '18:07:20'),
	(12, 'Modal works?', 'Modal works?', '', _binary '', '2025-04-01', '18:07:59'),
	(13, 'Modalsssss', 'Modal maybe not need to work', '', _binary '', '2025-04-01', '18:08:57'),
	(14, 'mangoses', 'Start writing here... mangoses', '', _binary '', '2025-04-01', '18:12:02'),
	(15, 'Mangeosgr', 'Mngoes?1', '', _binary '', '2025-04-01', '18:12:57'),
	(16, 'Modal workings?', 'Modal workings?', '', _binary '', '2025-04-01', '18:16:10'),
	(17, 'Pls work', 'Pls work', '', _binary '', '2025-04-01', '18:18:56'),
	(18, 'Waorkgin', '<b>\r\n            Wokring agrv</b>rbv', '', _binary '', '2025-04-01', '18:21:44'),
	(19, 'It works', 'Wo<i><font face="Times New Roman">rks</font></i>?', '', _binary '', '2025-04-01', '18:24:16'),
	(20, 'Testingersings', 'Testingers', 'Testingersings once again', _binary '', '2025-04-01', '18:47:24'),
	(21, 'Start writing here bro', 'Start writing here...', '', _binary '', '2025-04-01', '18:47:53'),
	(22, 'Mango OS', '<font size="5">\r\n            The mango OS</font>', '', _binary '', '2025-04-02', '10:58:56'),
	(23, 'adams prasija', 'Start writing here...', '', _binary '', '2025-04-02', '11:15:35'),
	(24, 'Testing Fonts View', '<div style="text-align: center;"><span style="font-family: &quot;Times New Roman&quot;; font-size: xx-large;"><b>Test</b></span></div><div style="text-align: left;"><font size="3"><font face="Courier New" style="">Thi<b>s is </b></font><font face="Arial" style="font-weight: bold;"><u>a</u></font><font face="Georgia" style="font-weight: bold;"><u> tes</u>t for t<i>h</i></font><font face="Verdana" style=""><i style=""><b>e fo</b>nts and stuff</i></font></font></div><div style="text-align: right;"><font size="3"><font face="Verdana" style=""><i style="">Mango</i></font></font></div>', '', _binary '', '2025-06-07', '11:12:58'),
	(25, 'Testing autosave', 'Mango j<b><i>uice</i></b>', '', _binary '', '2025-06-07', '11:24:14'),
	(26, 'Test Fail Piemers', 'Mango j<b><i>uice</i></b>', '', _binary '', '2025-06-07', '11:28:22'),
	(27, 'Testing Autosave Again', 'Start wM<b><u>ango juceio</u></b>', '', _binary '', '2025-06-07', '11:31:03'),
	(28, 'Testing once again', 'Start wM<b><u>ango juceio</u></b>', '', _binary '', '2025-06-07', '11:34:01');

-- Dumping structure for table notepad.file_likes
CREATE TABLE IF NOT EXISTS `file_likes` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Lietotāja patīk vai nepatīk faila id',
  `published_file_id` int(11) unsigned NOT NULL COMMENT 'Publicētā faila id',
  `user_id` int(11) unsigned NOT NULL COMMENT 'Lietotāja id',
  `is_like` tinyint(1) unsigned NOT NULL COMMENT '1=patīk, 0=nepatīk fails',
  PRIMARY KEY (`id`),
  KEY `FK_file_likes_published_files` (`published_file_id`),
  KEY `FK_file_likes_users` (`user_id`),
  CONSTRAINT `FK_file_likes_published_files` FOREIGN KEY (`published_file_id`) REFERENCES `published_files` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_file_likes_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Lietotāja atzīmētās "patīk" vai "nepatīk" faili';

-- Dumping data for table notepad.file_likes: ~0 rows (approximately)

-- Dumping structure for table notepad.file_users
CREATE TABLE IF NOT EXISTS `file_users` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Sasaistīto lietotāju un failu id',
  `files_id` int(11) unsigned NOT NULL COMMENT 'Failu id',
  `users_id` int(11) unsigned NOT NULL COMMENT 'Lietotāju id',
  PRIMARY KEY (`id`),
  KEY `FK_file_users_files` (`files_id`),
  KEY `FK_file_users_users` (`users_id`),
  CONSTRAINT `FK_file_users_files` FOREIGN KEY (`files_id`) REFERENCES `files` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_file_users_users` FOREIGN KEY (`users_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Tabula, kura sasaista lietotājus pie saviem failiem.';

-- Dumping data for table notepad.file_users: ~27 rows (approximately)
INSERT INTO `file_users` (`id`, `files_id`, `users_id`) VALUES
	(1, 1, 1),
	(2, 2, 1),
	(3, 3, 2),
	(4, 4, 2),
	(5, 5, 2),
	(6, 6, 2),
	(7, 7, 2),
	(8, 8, 2),
	(9, 9, 2),
	(10, 10, 2),
	(11, 11, 2),
	(12, 12, 2),
	(13, 13, 2),
	(14, 14, 2),
	(15, 15, 2),
	(16, 16, 2),
	(17, 17, 2),
	(18, 18, 2),
	(19, 19, 2),
	(20, 20, 1),
	(21, 21, 1),
	(22, 22, 1),
	(23, 23, 2),
	(24, 24, 2),
	(25, 25, 2),
	(26, 26, 2),
	(27, 27, 2),
	(28, 28, 2);

-- Dumping structure for table notepad.published_files
CREATE TABLE IF NOT EXISTS `published_files` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Publicētā faila id',
  `file_id` int(11) unsigned NOT NULL COMMENT 'Failu id',
  `user_id` int(11) unsigned NOT NULL COMMENT 'Lietotāju id',
  `title` varchar(255) NOT NULL COMMENT 'Publicētā faila nosaukums',
  `description` text NOT NULL COMMENT 'Publicētā faila apraksts',
  `text` text NOT NULL COMMENT 'Lietotāja izvēlētā faila teksts',
  `thumbnail` mediumblob NOT NULL COMMENT 'Publicētā faila bilde',
  `date` date NOT NULL COMMENT 'Publicētā faila publicēšanās datums',
  `time` time NOT NULL COMMENT 'Publicētā faila publicēšanās laiks',
  PRIMARY KEY (`id`),
  KEY `FK__files` (`file_id`),
  KEY `FK__users` (`user_id`),
  CONSTRAINT `FK__files` FOREIGN KEY (`file_id`) REFERENCES `files` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK__users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Publicēti faili priekš browse.php';

-- Dumping data for table notepad.published_files: ~12 rows (approximately)
INSERT INTO `published_files` (`id`, `file_id`, `user_id`, `title`, `description`, `text`, `thumbnail`, `date`, `time`) VALUES
	(1, 22, 1, 'Testing Post 1', 'This is the first test of posts using the text from file "Mango OS"!', '<font size="5">\r\n            The mango OS</font>', _binary 0x[BLOB], '2025-06-09', '15:36:53'),
	(2, 2, 1, 'Post Test 2', 'This is the 2nd post test with categories and text from file "TestBold Mango"', '<font face="Times New Roman"><b>\n            Testing</b></font>', _binary 0x[BLOB], '2025-06-09', '15:49:15'),
	(3, 20, 1, 'Testingersings Post 3', 'Yessir, te notiekas lietas', 'Testingers', _binary 0x[BLOB], '2025-06-09', '15:56:20');
INSERT INTO `published_files` (`id`, `file_id`, `user_id`, `title`, `description`, `text`, `thumbnail`, `date`, `time`) VALUES
	(4, 21, 1, 'Start Testing Here Bro 4', 'Test 4', 'Start writing here...', _binary 0x[BLOB]