-- phpMyAdmin SQL Dump
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Feb 06, 2026 at 07:06 PM
-- Server version: 10.4.27-MariaDB
-- PHP Version: 7.4.33

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: `perpustakaan_man2`
--

-- --------------------------------------------------------

--
-- Table structure for table `anggota`
--

CREATE TABLE `anggota` (
  `id_anggota` int(11) NOT NULL,
  `nis` varchar(30) DEFAULT NULL,
  `nama` varchar(100) DEFAULT NULL,
  `kelas` varchar(20) DEFAULT NULL,
  `alamat` text DEFAULT NULL,
  `no_hp` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `anggota`
--

INSERT INTO `anggota` (`id_anggota`, `nis`, `nama`, `kelas`, `alamat`, `no_hp`) VALUES
(1, '5862', 'Rizki', 'XI IPA 2', 'kalasan', '87838830020'),
(2, '5861', 'Shania', 'XI IPA 2', 'gunung kidul', '882006634900'),
(16, '100', 'dimas', 'XI IPA 3', 'gunung kidul', '1234567');

-- --------------------------------------------------------

--
-- Table structure for table `buku`
--

CREATE TABLE `buku` (
  `id_buku` int(11) NOT NULL,
  `id_kategori` int(11) DEFAULT NULL,
  `judul` varchar(200) DEFAULT NULL,
  `penulis` varchar(100) DEFAULT NULL,
  `penerbit` varchar(100) DEFAULT NULL,
  `tahun` int(11) DEFAULT NULL,
  `stok` int(11) DEFAULT NULL,
  `gambar` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `buku`
--

INSERT INTO `buku` (`id_buku`, `id_kategori`, `judul`, `penulis`, `penerbit`, `tahun`, `stok`, `gambar`) VALUES
(4, 11, 'Bumi', '2018', 'Tereliye', 0, 3, '1770223219.jpg'),
(5, 11, 'Pengantar Ilmu Pengetahuan Umum', 'Sutrisno', 'Erlangga', 2018, 9, 'ipu.jpg'),
(6, 12, 'Filsafat Pendidikan', 'Ki Hajar Dewantara', 'Balai Pustaka', 2017, 5, 'filsafat_pendidikan.jpg'),
(7, 13, 'Pendidikan Agama Islam', 'Ahmad Fauzi', 'Kementerian Agama', 2020, 11, 'pai.jpg'),
(8, 14, 'Sosiologi untuk SMA', 'Soerjono Soekanto', 'Gramedia', 2019, 8, 'sosiologi.jpg'),
(9, 15, 'Bahasa Indonesia Kelas XI', 'Suherli', 'Kemendikbud', 2021, 15, 'bindo_xi.jpg'),
(10, 16, 'Matematika Wajib SMA', 'M. Cholik Adinawan', 'Erlangga', 2020, 10, 'matematika.jpg'),
(11, 17, 'Teknologi Informasi dan Komunikasi', 'Rudi Hartono', 'Informatika', 2018, 7, 'tik.jpg'),
(12, 18, 'Seni Budaya untuk SMA', 'Eko Purnomo', 'Yrama Widya', 2019, 6, 'seni_budaya.jpg'),
(13, 20, 'Sejarah Indonesia', 'Sardiman AM', 'Yudhistira', 2021, 9, 'sejarah.jpg'),
(14, 24, 'Kumpulan Karya Ilmiah Siswa MAN 2 Sleman', 'Tim Guru MAN 2 Sleman', 'Perpustakaan MAN 2 Sleman', 2022, 4, 'karya_siswa.jpg');

-- --------------------------------------------------------

--
-- Table structure for table `detail_peminjaman`
--

CREATE TABLE `detail_peminjaman` (
  `id_detail` int(11) NOT NULL,
  `id_peminjaman` int(11) DEFAULT NULL,
  `id_buku` int(11) DEFAULT NULL,
  `jumlah` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `detail_peminjaman`
--

INSERT INTO `detail_peminjaman` (`id_detail`, `id_peminjaman`, `id_buku`, `jumlah`) VALUES
(15, 17, 4, 1),
(17, 19, 8, 1),
(18, 20, 9, 1),
(19, 21, 6, 1),
(20, 22, 4, 1),
(21, 23, 7, 1),
(22, 24, 5, 1);

-- --------------------------------------------------------

--
-- Table structure for table `favorit`
--

CREATE TABLE `favorit` (
  `id_favorit` int(11) NOT NULL,
  `id_anggota` int(11) DEFAULT NULL,
  `id_buku` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `favorit`
--

INSERT INTO `favorit` (`id_favorit`, `id_anggota`, `id_buku`, `created_at`) VALUES
(1, 1, 2, '2026-02-04 15:13:40'),
(5, 2, 4, '2026-02-04 16:47:16'),
(6, 2, 4, '2026-02-04 16:47:17'),
(7, 1, 4, '2026-02-05 05:04:38'),
(8, 1, 5, '2026-02-05 05:04:42');

-- --------------------------------------------------------

--
-- Table structure for table `kategori`
--

CREATE TABLE `kategori` (
  `id_kategori` int(11) NOT NULL,
  `nama_kategori` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `kategori`
--

INSERT INTO `kategori` (`id_kategori`, `nama_kategori`) VALUES
(10, 'Buku Referensi'),
(11, 'Karya Umum'),
(12, 'Filsafat'),
(13, 'Keagamaan'),
(14, 'Ilmu Sosial'),
(15, 'Bahasa'),
(16, 'Ilmu Alam dan Matematika'),
(17, 'Teknologi dan Ilmu Terapan'),
(18, 'Kesenian, Hiburan dan Olahraga'),
(19, 'Kesusastraan'),
(20, 'Sejarah'),
(21, 'Geografi'),
(22, 'Majalah'),
(23, 'Koleksi Braille'),
(24, 'Buku Karya Siswa');

-- --------------------------------------------------------

--
-- Table structure for table `peminjaman`
--

CREATE TABLE `peminjaman` (
  `id_peminjaman` int(11) NOT NULL,
  `id_anggota` int(11) DEFAULT NULL,
  `id_petugas` int(11) DEFAULT NULL,
  `tanggal_pinjam` date DEFAULT NULL,
  `tanggal_kembali` date DEFAULT NULL,
  `status` enum('dipinjam','dikembalikan') DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `peminjaman`
--

INSERT INTO `peminjaman` (`id_peminjaman`, `id_anggota`, `id_petugas`, `tanggal_pinjam`, `tanggal_kembali`, `status`) VALUES
(17, 2, 3, '2025-12-26', '2026-02-07', 'dipinjam'),
(19, 1, 3, '2026-01-24', '2026-02-08', 'dikembalikan'),
(20, 1, 3, '2026-02-04', '2026-02-18', 'dikembalikan'),
(21, 1, 1, '2026-02-05', '2026-02-19', 'dikembalikan'),
(22, 1, 1, '2026-02-05', '2026-02-19', 'dipinjam'),
(23, 1, 1, '2026-02-05', '2026-02-19', 'dipinjam'),
(24, 2, 3, '2026-02-05', '2026-02-19', 'dipinjam');

-- --------------------------------------------------------

--
-- Table structure for table `pengunjung`
--

CREATE TABLE `pengunjung` (
  `id_pengunjung` int(11) NOT NULL,
  `nama_pengunjung` varchar(100) DEFAULT NULL,
  `tanggal` date DEFAULT NULL,
  `keperluan` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `pengunjung`
--

INSERT INTO `pengunjung` (`id_pengunjung`, `nama_pengunjung`, `tanggal`, `keperluan`) VALUES
(1, 'Rizki', '2026-01-27', 'Berkunjung'),
(2, 'Rizki', '2026-01-27', 'Berkunjung'),
(3, 'Rizki', '2026-01-27', 'Berkunjung'),
(4, 'Rizki', '2026-01-27', 'Berkunjung'),
(5, 'dimas', '2026-01-27', 'Berkunjung'),
(6, 'Shania', '2026-01-27', 'Berkunjung'),
(7, 'Rizki', '2026-01-28', 'Berkunjung'),
(8, 'dimas', '2026-01-28', 'Berkunjung'),
(9, 'Rizki', '2026-01-30', 'Berkunjung'),
(10, 'Rizki', '2026-02-04', 'Berkunjung'),
(11, 'Rizki', '2026-02-05', 'Berkunjung'),
(12, 'Rizki', '2026-02-05', 'Berkunjung');

-- --------------------------------------------------------

--
-- Table structure for table `petugas`
--

CREATE TABLE `petugas` (
  `id_petugas` int(11) NOT NULL,
  `nama_petugas` varchar(100) DEFAULT NULL,
  `username` varchar(50) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  `level` enum('superadmin','petugas') DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;

--
-- Dumping data for table `petugas`
--

INSERT INTO `petugas` (`id_petugas`, `nama_petugas`, `username`, `password`, `level`) VALUES
(1, 'Admin', 'admin', '21232f297a57a5a743894a0e4a801fc3', 'petugas'),
(3, 'Super Admin', 'SuperAdmin', 'e10adc3949ba59abbe56e057f20f883e', 'superadmin');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `anggota`
--
ALTER TABLE `anggota`
  ADD PRIMARY KEY (`id_anggota`);

--
-- Indexes for table `buku`
--
ALTER TABLE `buku`
  ADD PRIMARY KEY (`id_buku`),
  ADD KEY `id_kategori` (`id_kategori`);

--
-- Indexes for table `detail_peminjaman`
--
ALTER TABLE `detail_peminjaman`
  ADD PRIMARY KEY (`id_detail`),
  ADD KEY `id_peminjaman` (`id_peminjaman`),
  ADD KEY `id_buku` (`id_buku`);

--
-- Indexes for table `favorit`
--
ALTER TABLE `favorit`
  ADD PRIMARY KEY (`id_favorit`);

--
-- Indexes for table `kategori`
--
ALTER TABLE `kategori`
  ADD PRIMARY KEY (`id_kategori`);

--
-- Indexes for table `peminjaman`
--
ALTER TABLE `peminjaman`
  ADD PRIMARY KEY (`id_peminjaman`),
  ADD KEY `id_anggota` (`id_anggota`),
  ADD KEY `id_petugas` (`id_petugas`);

--
-- Indexes for table `pengunjung`
--
ALTER TABLE `pengunjung`
  ADD PRIMARY KEY (`id_pengunjung`);

--
-- Indexes for table `petugas`
--
ALTER TABLE `petugas`
  ADD PRIMARY KEY (`id_petugas`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `anggota`
--
ALTER TABLE `anggota`
  MODIFY `id_anggota` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;

--
-- AUTO_INCREMENT for table `buku`
--
ALTER TABLE `buku`
  MODIFY `id_buku` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;

--
-- AUTO_INCREMENT for table `detail_peminjaman`
--
ALTER TABLE `detail_peminjaman`
  MODIFY `id_detail` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;

--
-- AUTO_INCREMENT for table `favorit`
--
ALTER TABLE `favorit`
  MODIFY `id_favorit` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT for table `kategori`
--
ALTER TABLE `kategori`
  MODIFY `id_kategori` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;

--
-- AUTO_INCREMENT for table `peminjaman`
--
ALTER TABLE `peminjaman`
  MODIFY `id_peminjaman` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;

--
-- AUTO_INCREMENT for table `pengunjung`
--
ALTER TABLE `pengunjung`
  MODIFY `id_pengunjung` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;

--
-- AUTO_INCREMENT for table `petugas`
--
ALTER TABLE `petugas`
  MODIFY `id_petugas` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `buku`
--
ALTER TABLE `buku`
  ADD CONSTRAINT `buku_ibfk_1` FOREIGN KEY (`id_kategori`) REFERENCES `kategori` (`id_kategori`);

--
-- Constraints for table `detail_peminjaman`
--
ALTER TABLE `detail_peminjaman`
  ADD CONSTRAINT `detail_peminjaman_ibfk_1` FOREIGN KEY (`id_peminjaman`) REFERENCES `peminjaman` (`id_peminjaman`),
  ADD CONSTRAINT `detail_peminjaman_ibfk_2` FOREIGN KEY (`id_buku`) REFERENCES `buku` (`id_buku`);

--
-- Constraints for table `peminjaman`
--
ALTER TABLE `peminjaman`
  ADD CONSTRAINT `peminjaman_ibfk_1` FOREIGN KEY (`id_anggota`) REFERENCES `anggota` (`id_anggota`),
  ADD CONSTRAINT `peminjaman_ibfk_2` FOREIGN KEY (`id_petugas`) REFERENCES `petugas` (`id_petugas`);
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 */;
