diff --git a/database/ukk_perpus.sql b/database/ukk_perpus.sql new file mode 100644 index 0000000..974fa8e --- /dev/null +++ b/database/ukk_perpus.sql @@ -0,0 +1,266 @@ +-- phpMyAdmin SQL Dump +-- version 5.2.1 +-- https://www.phpmyadmin.net/ +-- +-- Host: 127.0.0.1 +-- Generation Time: Mar 08, 2024 at 05:17 PM +-- Server version: 10.4.32-MariaDB +-- PHP Version: 8.2.12 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!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 */; + +-- +-- Database: `ukk_perpus` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `book` +-- + +CREATE TABLE `book` ( + `id` int(11) NOT NULL, + `title` varchar(255) DEFAULT NULL, + `author` varchar(255) DEFAULT NULL, + `publisher` varchar(255) DEFAULT NULL, + `publication_year` varchar(255) DEFAULT NULL, + `description` text DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `book_category` +-- + +CREATE TABLE `book_category` ( + `id` int(11) NOT NULL, + `book_id` int(11) NOT NULL, + `category_id` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `book_loan` +-- + +CREATE TABLE `book_loan` ( + `id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `book_id` int(11) NOT NULL, + `loan_date` date DEFAULT NULL, + `return_date` date DEFAULT NULL, + `status` enum('dipinjam','dikembalikan') DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `category` +-- + +CREATE TABLE `category` ( + `id` int(11) NOT NULL, + `category` varchar(255) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `favorite` +-- + +CREATE TABLE `favorite` ( + `id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `book_id` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `review` +-- + +CREATE TABLE `review` ( + `id` int(11) NOT NULL, + `user_id` int(11) NOT NULL, + `book_id` int(11) NOT NULL, + `review` text DEFAULT NULL, + `rating` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user` +-- + +CREATE TABLE `user` ( + `id` int(11) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `username` varchar(255) DEFAULT NULL, + `password` varchar(255) DEFAULT NULL, + `email` varchar(255) DEFAULT NULL, + `address` text DEFAULT NULL, + `level` enum('administrator','petugas','peminjam') DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +-- +-- Dumping data for table `user` +-- + +INSERT INTO `user` (`id`, `name`, `username`, `password`, `email`, `address`, `level`) VALUES +(1, 'admin', 'admin', '21232f297a57a5a743894a0e4a801fc3', 'admin@example.com', 'Batam Center', 'administrator'), +(2, 'Andi', 'andi', 'ce0e5bf55e4f71749eade7a8b95c4e46', 'andi@example.com', 'Batu Aji', 'petugas'), +(3, 'Budi', 'budi', '00dfc53ee86af02e742515cdcf075ed3', 'budi@example.com', 'Bengkong', 'peminjam'), +(4, 'badu', 'badu', '40a3de3b98856879b19943f7e93a0375', 'badu@example.com', 'Marina', 'administrator'), +(5, 'andre', 'andre', '19984dcaea13176bbb694f62ba6b5b35', 'andre@example.com', 'marina', 'administrator'), +(6, 'baru', 'baru', '5ef035d11d74713fcb36f2df26aa7c3d', 'baru@example.com', 'baru', 'peminjam'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `book` +-- +ALTER TABLE `book` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `book_category` +-- +ALTER TABLE `book_category` + ADD PRIMARY KEY (`id`), + ADD KEY `book_id` (`book_id`,`category_id`), + ADD KEY `category_id` (`category_id`); + +-- +-- Indexes for table `book_loan` +-- +ALTER TABLE `book_loan` + ADD PRIMARY KEY (`id`), + ADD KEY `user_id` (`user_id`,`book_id`), + ADD KEY `book_id` (`book_id`); + +-- +-- Indexes for table `category` +-- +ALTER TABLE `category` + ADD PRIMARY KEY (`id`); + +-- +-- Indexes for table `favorite` +-- +ALTER TABLE `favorite` + ADD PRIMARY KEY (`id`), + ADD KEY `user_id` (`user_id`), + ADD KEY `book_id` (`book_id`); + +-- +-- Indexes for table `review` +-- +ALTER TABLE `review` + ADD PRIMARY KEY (`id`), + ADD KEY `user_id` (`user_id`,`book_id`), + ADD KEY `book_id` (`book_id`); + +-- +-- Indexes for table `user` +-- +ALTER TABLE `user` + ADD PRIMARY KEY (`id`); + +-- +-- AUTO_INCREMENT for dumped tables +-- + +-- +-- AUTO_INCREMENT for table `book` +-- +ALTER TABLE `book` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `book_category` +-- +ALTER TABLE `book_category` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `book_loan` +-- +ALTER TABLE `book_loan` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `category` +-- +ALTER TABLE `category` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23; + +-- +-- AUTO_INCREMENT for table `favorite` +-- +ALTER TABLE `favorite` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `review` +-- +ALTER TABLE `review` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; + +-- +-- AUTO_INCREMENT for table `user` +-- +ALTER TABLE `user` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; + +-- +-- Constraints for dumped tables +-- + +-- +-- Constraints for table `book_category` +-- +ALTER TABLE `book_category` + ADD CONSTRAINT `book_category_ibfk_1` FOREIGN KEY (`book_id`) REFERENCES `book` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + ADD CONSTRAINT `book_category_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `book_loan` +-- +ALTER TABLE `book_loan` + ADD CONSTRAINT `book_loan_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`), + ADD CONSTRAINT `book_loan_ibfk_2` FOREIGN KEY (`book_id`) REFERENCES `book` (`id`); + +-- +-- Constraints for table `favorite` +-- +ALTER TABLE `favorite` + ADD CONSTRAINT `favorite_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`), + ADD CONSTRAINT `favorite_ibfk_2` FOREIGN KEY (`book_id`) REFERENCES `book` (`id`); + +-- +-- Constraints for table `review` +-- +ALTER TABLE `review` + ADD CONSTRAINT `review_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`), + ADD CONSTRAINT `review_ibfk_2` FOREIGN KEY (`book_id`) REFERENCES `book` (`id`); +COMMIT; + +/*!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 */;