text: -- phpMyAdmin SQL Dump
  -- version 5.0.4
  -- https://www.phpmyadmin.net/
  --
  -- Host: 127.0.0.1
  -- Waktu pembuatan: 01 Jan 2022 pada 16.28
  -- Versi server: 10.4.17-MariaDB
  -- Versi PHP: 8.0.2
  
  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: `aneka_olshop`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `tb_barang`
  --
  
  CREATE TABLE `tb_barang` (
    `id_brg` int(11) NOT NULL,
    `nama_brg` varchar(120) NOT NULL,
    `keterangan` varchar(225) NOT NULL,
    `kategori` varchar(60) NOT NULL,
    `harga` int(11) NOT NULL,
    `stok` int(4) NOT NULL,
    `gambar` text NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  --
  -- Dumping data untuk tabel `tb_barang`
  --
  
  INSERT INTO `tb_barang` (`id_brg`, `nama_brg`, `keterangan`, `kategori`, `harga`, `stok`, `gambar`) VALUES
  (1, 'Sepatu', 'Sepatu Merk All Star', 'Pakaian Pria', 600000, 15, 'sepatu.jpg'),
  (2, 'Kamera', 'Camera Canon EOS 700d', 'Elektronik', 6500000, 9, 'kamera.jpg'),
  (3, 'Samsung Galaxy A20', 'Samsung Galaxy A20', 'Elektronik', 3500000, 33, 'hp.jpg'),
  (4, 'Laptop Toshiba', 'Laptop ASUS RAM 2 gb', 'Elektronik', 6500000, 46, 'laptop.jpg');
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `tb_invoice`
  --
  
  CREATE TABLE `tb_invoice` (
    `id` int(11) NOT NULL,
    `nama` varchar(56) NOT NULL,
    `alamat` varchar(225) NOT NULL,
    `tgl_pesan` datetime NOT NULL,
    `batas_bayar` datetime NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `tb_pesanan`
  --
  
  CREATE TABLE `tb_pesanan` (
    `id` int(11) NOT NULL,
    `id_invoice` int(11) NOT NULL,
    `id_brg` int(11) NOT NULL,
    `nama_brg` varchar(50) NOT NULL,
    `jumlah` int(3) NOT NULL,
    `harga` int(10) NOT NULL,
    `pilihan` text NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  --
  -- Trigger `tb_pesanan`
  --
  DELIMITER $$
  CREATE TRIGGER `pesanan_penjualan` AFTER INSERT ON `tb_pesanan` FOR EACH ROW BEGIN
  	UPDATE tb_barang SET stok = stok-NEW.jumlah
      WHERE id_brg = NEW.id_brg;
  END
  $$
  DELIMITER ;
  
  -- --------------------------------------------------------
  
  --
  -- Struktur dari tabel `tb_user`
  --
  
  CREATE TABLE `tb_user` (
    `id` int(11) NOT NULL,
    `nama` varchar(50) NOT NULL,
    `username` varchar(50) NOT NULL,
    `password` varchar(50) NOT NULL,
    `role_id` tinyint(1) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  --
  -- Dumping data untuk tabel `tb_user`
  --
  
  INSERT INTO `tb_user` (`id`, `nama`, `username`, `password`, `role_id`) VALUES
  (1, 'admin', 'admin', '123', 1),
  (2, 'user', 'user', '123', 2),
  (3, 'wanda', 'wandayani', '123', 2);
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indeks untuk tabel `tb_barang`
  --
  ALTER TABLE `tb_barang`
    ADD PRIMARY KEY (`id_brg`);
  
  --
  -- Indeks untuk tabel `tb_invoice`
  --
  ALTER TABLE `tb_invoice`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indeks untuk tabel `tb_pesanan`
  --
  ALTER TABLE `tb_pesanan`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indeks untuk tabel `tb_user`
  --
  ALTER TABLE `tb_user`
    ADD PRIMARY KEY (`id`);
  
  --
  -- AUTO_INCREMENT untuk tabel yang dibuang
  --
  
  --
  -- AUTO_INCREMENT untuk tabel `tb_barang`
  --
  ALTER TABLE `tb_barang`
    MODIFY `id_brg` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
  
  --
  -- AUTO_INCREMENT untuk tabel `tb_invoice`
  --
  ALTER TABLE `tb_invoice`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT untuk tabel `tb_pesanan`
  --
  ALTER TABLE `tb_pesanan`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT untuk tabel `tb_user`
  --
  ALTER TABLE `tb_user`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
  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 */;
  