text: -- phpMyAdmin SQL Dump
  -- version 5.0.2
  -- https://www.phpmyadmin.net/
  --
  -- Host: 127.0.0.1
  -- Generation Time: Aug 02, 2020 at 04:35 AM
  -- Server version: 10.4.11-MariaDB
  -- PHP Version: 7.4.6
  
  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: `sipus`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `anggota`
  --
  
  CREATE TABLE `anggota` (
    `id` varchar(20) NOT NULL,
    `nama` varchar(20) NOT NULL,
    `alamat` text NOT NULL,
    `no_telp` int(20) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `anggota`
  --
  
  INSERT INTO `anggota` (`id`, `nama`, `alamat`, `no_telp`) VALUES
  ('1', 'Rizki Fitra Rahman', 'Pandawangi', 858);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `buku`
  --
  
  CREATE TABLE `buku` (
    `id` varchar(20) NOT NULL,
    `judul_buku` varchar(20) NOT NULL,
    `tahun_buku` int(10) NOT NULL,
    `penerbit_id` varchar(20) NOT NULL,
    `pengarang_id` varchar(20) NOT NULL,
    `rak_id` varchar(20) NOT NULL,
    `jumlah_buku` int(100) NOT NULL,
    `tanggal_pengadaan` date DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `buku`
  --
  
  INSERT INTO `buku` (`id`, `judul_buku`, `tahun_buku`, `penerbit_id`, `pengarang_id`, `rak_id`, `jumlah_buku`, `tanggal_pengadaan`) VALUES
  ('20200706', 'Kelabu', 2020, '2', '2', 'rak-1', 5, NULL),
  ('20200801', 'Pudar', 2002, '1', '1', 'rak-1', 1, NULL);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `peminjaman`
  --
  
  CREATE TABLE `peminjaman` (
    `id` int(11) NOT NULL,
    `anggota_id` varchar(20) NOT NULL,
    `buku_id` varchar(20) NOT NULL,
    `is_kembali` char(1) NOT NULL DEFAULT '0',
    `tanggal_pinjam` date DEFAULT NULL,
    `tanggal_kembali` date DEFAULT NULL,
    `denda` tinytext DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `peminjaman`
  --
  
  INSERT INTO `peminjaman` (`id`, `anggota_id`, `buku_id`, `is_kembali`, `tanggal_pinjam`, `tanggal_kembali`, `denda`) VALUES
  (1, '1', '20200706', '1', NULL, NULL, NULL);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `penerbit`
  --
  
  CREATE TABLE `penerbit` (
    `id` varchar(20) NOT NULL,
    `nama_penerbit` varchar(20) NOT NULL,
    `alamat` tinytext DEFAULT NULL,
    `no_telp` int(20) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `penerbit`
  --
  
  INSERT INTO `penerbit` (`id`, `nama_penerbit`, `alamat`, `no_telp`) VALUES
  ('1', 'Rizki', 'Pandanwangi', 0),
  ('2', 'rahman', 'Pandanwangi', 10);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `pengarang`
  --
  
  CREATE TABLE `pengarang` (
    `id` varchar(20) NOT NULL,
    `nama_pengarang` varchar(20) NOT NULL,
    `alamat` tinytext DEFAULT NULL,
    `no_telp` int(20) DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `pengarang`
  --
  
  INSERT INTO `pengarang` (`id`, `nama_pengarang`, `alamat`, `no_telp`) VALUES
  ('1', 'rizki', 'Pandanwangi', 123),
  ('2', 'fitra', 'Pandanwangi', 111);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `rak`
  --
  
  CREATE TABLE `rak` (
    `id` varchar(20) NOT NULL,
    `lokasi` tinytext NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  --
  -- Dumping data for table `rak`
  --
  
  INSERT INTO `rak` (`id`, `lokasi`) VALUES
  ('rak-1', 'Rak bawah'),
  ('rak-2', 'Rak Atas');
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `anggota`
  --
  ALTER TABLE `anggota`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `buku`
  --
  ALTER TABLE `buku`
    ADD PRIMARY KEY (`id`),
    ADD KEY `foreign_penerbit` (`penerbit_id`),
    ADD KEY `foreign_pengarang` (`pengarang_id`) USING BTREE,
    ADD KEY `fk_buku_rak_1` (`rak_id`);
  
  --
  -- Indexes for table `peminjaman`
  --
  ALTER TABLE `peminjaman`
    ADD PRIMARY KEY (`id`),
    ADD KEY `foreign_anggota` (`anggota_id`),
    ADD KEY `foreign_buku` (`buku_id`);
  
  --
  -- Indexes for table `penerbit`
  --
  ALTER TABLE `penerbit`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `pengarang`
  --
  ALTER TABLE `pengarang`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `rak`
  --
  ALTER TABLE `rak`
    ADD PRIMARY KEY (`id`);
  
  --
  -- AUTO_INCREMENT for dumped tables
  --
  
  --
  -- AUTO_INCREMENT for table `peminjaman`
  --
  ALTER TABLE `peminjaman`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
  
  --
  -- Constraints for dumped tables
  --
  
  --
  -- Constraints for table `buku`
  --
  ALTER TABLE `buku`
    ADD CONSTRAINT `buku_ibfk_1` FOREIGN KEY (`penerbit_id`) REFERENCES `penerbit` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `buku_ibfk_2` FOREIGN KEY (`pengarang_id`) REFERENCES `pengarang` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `fk_buku_rak_1` FOREIGN KEY (`rak_id`) REFERENCES `rak` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  --
  -- Constraints for table `peminjaman`
  --
  ALTER TABLE `peminjaman`
    ADD CONSTRAINT `fk_peminjaman_anggota_1` FOREIGN KEY (`anggota_id`) REFERENCES `anggota` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `fk_peminjaman_buku_1` FOREIGN KEY (`buku_id`) REFERENCES `buku` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
  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 */;
  