text: -- phpMyAdmin SQL Dump
  -- version 4.5.1
  -- http://www.phpmyadmin.net
  --
  -- Host: 127.0.0.1
  -- Generation Time: 25 Mei 2018 pada 11.58
  -- Versi Server: 10.1.13-MariaDB
  -- PHP Version: 5.5.35
  
  SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  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: `db_apotik`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `barang`
  --
  
  CREATE TABLE `barang` (
    `id_barang` int(11) NOT NULL,
    `nama_barang` varchar(100) NOT NULL,
    `expired` date NOT NULL,
    `id_kategori` int(11) NOT NULL,
    `harga` int(100) NOT NULL,
    `foto_cover` varchar(100) NOT NULL,
    `produsen` varchar(100) NOT NULL,
    `stok` int(10) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data untuk tabel `barang`
  --
  
  INSERT INTO `barang` (`id_barang`, `nama_barang`, `expired`, `id_kategori`, `harga`, `foto_cover`, `produsen`, `stok`) VALUES
  (42, 'Obat Maag', '2020-06-01', 22, 1000, 'user2.png', 'Kimia Farma', 0),
  (43, 'Blabla', '2001-03-19', 22, 10000, 'Capture.PNG', 'sdfghjk', 0);
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `detail_transaksi`
  --
  
  CREATE TABLE `detail_transaksi` (
    `id_detail` int(11) NOT NULL,
    `id_transaksi` int(11) NOT NULL,
    `jumlah` int(10) NOT NULL,
    `id_barang` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data untuk tabel `detail_transaksi`
  --
  
  INSERT INTO `detail_transaksi` (`id_detail`, `id_transaksi`, `jumlah`, `id_barang`) VALUES
  (1, 13, 10, 42),
  (2, 14, 3, 43);
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `kategori`
  --
  
  CREATE TABLE `kategori` (
    `id_kategori` int(11) NOT NULL,
    `nama_kategori` varchar(100) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data untuk tabel `kategori`
  --
  
  INSERT INTO `kategori` (`id_kategori`, `nama_kategori`) VALUES
  (22, 'Obat Perut'),
  (23, 'Obat Sariawan');
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `transaksi`
  --
  
  CREATE TABLE `transaksi` (
    `id_transaksi` int(11) NOT NULL,
    `id_user` int(11) NOT NULL,
    `nama_pembeli` varchar(100) NOT NULL,
    `total` int(10) NOT NULL,
    `tanggal_beli` date NOT NULL,
    `bayar` int(11) NOT NULL,
    `uang` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data untuk tabel `transaksi`
  --
  
  INSERT INTO `transaksi` (`id_transaksi`, `id_user`, `nama_pembeli`, `total`, `tanggal_beli`, `bayar`, `uang`) VALUES
  (13, 9, 'umar', 10000, '2018-05-18', 0, 10000),
  (14, 9, 'umar', 30000, '2018-05-18', 0, 30000);
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `user`
  --
  
  CREATE TABLE `user` (
    `id_user` int(11) NOT NULL,
    `nama_user` varchar(100) NOT NULL,
    `username` varchar(100) NOT NULL,
    `password` varchar(100) NOT NULL,
    `level` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data untuk tabel `user`
  --
  
  INSERT INTO `user` (`id_user`, `nama_user`, `username`, `password`, `level`) VALUES
  (9, 'admin', 'admin', 'admin', 1),
  (10, 'kuy', 'kuy', 'kuy', 2);
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `barang`
  --
  ALTER TABLE `barang`
    ADD PRIMARY KEY (`id_barang`),
    ADD KEY `id_kategori` (`id_kategori`);
  
  --
  -- Indexes for table `detail_transaksi`
  --
  ALTER TABLE `detail_transaksi`
    ADD PRIMARY KEY (`id_detail`),
    ADD KEY `id_transaksi` (`id_transaksi`),
    ADD KEY `id_buku` (`id_barang`);
  
  --
  -- Indexes for table `kategori`
  --
  ALTER TABLE `kategori`
    ADD PRIMARY KEY (`id_kategori`);
  
  --
  -- Indexes for table `transaksi`
  --
  ALTER TABLE `transaksi`
    ADD PRIMARY KEY (`id_transaksi`),
    ADD KEY `id_user` (`id_user`);
  
  --
  -- Indexes for table `user`
  --
  ALTER TABLE `user`
    ADD PRIMARY KEY (`id_user`);
  
  --
  -- AUTO_INCREMENT for dumped tables
  --
  
  --
  -- AUTO_INCREMENT for table `barang`
  --
  ALTER TABLE `barang`
    MODIFY `id_barang` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=44;
  --
  -- AUTO_INCREMENT for table `detail_transaksi`
  --
  ALTER TABLE `detail_transaksi`
    MODIFY `id_detail` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
  --
  -- AUTO_INCREMENT for table `kategori`
  --
  ALTER TABLE `kategori`
    MODIFY `id_kategori` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;
  --
  -- AUTO_INCREMENT for table `transaksi`
  --
  ALTER TABLE `transaksi`
    MODIFY `id_transaksi` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
  --
  -- AUTO_INCREMENT for table `user`
  --
  ALTER TABLE `user`
    MODIFY `id_user` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
  --
  -- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables)
  --
  
  --
  -- Ketidakleluasaan untuk tabel `barang`
  --
  ALTER TABLE `barang`
    ADD CONSTRAINT `barang_ibfk_1` FOREIGN KEY (`id_kategori`) REFERENCES `kategori` (`id_kategori`) ON UPDATE CASCADE;
  
  --
  -- Ketidakleluasaan untuk tabel `detail_transaksi`
  --
  ALTER TABLE `detail_transaksi`
    ADD CONSTRAINT `detail_transaksi_ibfk_4` FOREIGN KEY (`id_barang`) REFERENCES `barang` (`id_barang`) ON DELETE CASCADE ON UPDATE CASCADE,
    ADD CONSTRAINT `detail_transaksi_ibfk_5` FOREIGN KEY (`id_transaksi`) REFERENCES `transaksi` (`id_transaksi`) ON DELETE CASCADE ON UPDATE CASCADE;
  
  --
  -- Ketidakleluasaan untuk tabel `transaksi`
  --
  ALTER TABLE `transaksi`
    ADD CONSTRAINT `transaksi_ibfk_1` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`) ON UPDATE CASCADE;
  
  /*!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 */;
  