-- --------------------------------------------------------
-- Host:                         127.0.0.1
-- Server version:               10.4.22-MariaDB - mariadb.org binary distribution
-- Server OS:                    Win64
-- HeidiSQL Version:             11.3.0.6295
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!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 database structure for lasitava_db
CREATE DATABASE IF NOT EXISTS `lasitava_db` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
USE `lasitava_db`;

-- Dumping structure for table lasitava_db.access
CREATE TABLE IF NOT EXISTS `access` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `permissions` varchar(5) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4;

-- Dumping data for table lasitava_db.access: ~2 rows (approximately)
/*!40000 ALTER TABLE `access` DISABLE KEYS */;
INSERT INTO `access` (`id`, `permissions`) VALUES
	(1, 'true'),
	(2, 'false');
/*!40000 ALTER TABLE `access` ENABLE KEYS */;

-- Dumping structure for table lasitava_db.books
CREATE TABLE IF NOT EXISTS `books` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `title` varchar(200) NOT NULL,
  `author` varchar(200) NOT NULL,
  `year` smallint(4) unsigned NOT NULL DEFAULT 0,
  `description` varchar(2000) NOT NULL,
  `image` varchar(2000) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `title` (`title`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4;

-- Dumping data for table lasitava_db.books: ~1 rows (approximately)
/*!40000 ALTER TABLE `books` DISABLE KEYS */;
INSERT INTO `books` (`id`, `title`, `author`, `year`, `description`, `image`) VALUES
	(17, 'Mātes piens. Mēs. Latvija, XX gadsimts', 'Nora Ikstena', 2015, 'Noras Ikstenas romāns “Mātes piens” aptver laika posmu no Otrā pasaules kara beigām un vēsta par triju paaudžu sieviešu likteņiem, bet vēstījuma centrā ir 20. gadsimta 70. un 80. gadi. Visu romāna tekstu caurauž atteikšanās – no vīra un tēva, no sapņiem un iecerēm, no darba un uzskatiem, no draugiem un tiem, kurus mīlam. Šajā visu paaudžu sieviešu sāpju ceļā ļoti spēcīgs ir piedošanas motīvs. Tas kopš mazotnes ir nepārtraukts uzdevums meitai, lai turētu pie dzīvības māti, kura apzināti viņai liegusi savu pienu, lai neļautu mantot savas sāpes un izmisumu. Vāka dizains: Jānis Esītis. Levana Beridzes vāka fotogrāfija.', '65d45d56e75bb_9789934546013_291.jpg');
/*!40000 ALTER TABLE `books` ENABLE KEYS */;

-- Dumping structure for table lasitava_db.reviews
CREATE TABLE IF NOT EXISTS `reviews` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `rating` decimal(2,1) unsigned NOT NULL,
  `description` varchar(10000) DEFAULT NULL,
  `id_user` int(10) unsigned DEFAULT NULL,
  `id_book` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FK_reviews_users` (`id_user`),
  KEY `FK_reviews_books` (`id_book`),
  CONSTRAINT `FK_reviews_books` FOREIGN KEY (`id_book`) REFERENCES `books` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_reviews_users` FOREIGN KEY (`id_user`) REFERENCES `users` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4;

-- Dumping data for table lasitava_db.reviews: ~0 rows (approximately)
/*!40000 ALTER TABLE `reviews` DISABLE KEYS */;
/*!40000 ALTER TABLE `reviews` ENABLE KEYS */;

-- Dumping structure for table lasitava_db.users
CREATE TABLE IF NOT EXISTS `users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `email` varchar(250) NOT NULL,
  `username` varchar(16) NOT NULL,
  `password_hash` varchar(255) NOT NULL,
  `id_access` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`),
  UNIQUE KEY `username` (`username`),
  KEY `FK_users_access` (`id_access`),
  CONSTRAINT `FK_users_access` FOREIGN KEY (`id_access`) REFERENCES `access` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4;

-- Dumping data for table lasitava_db.users: ~0 rows (approximately)
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
/*!40000 ALTER TABLE `users` ENABLE KEYS */;

/*!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) */;
