text: -- phpMyAdmin SQL Dump
  -- version 4.8.2
  -- https://www.phpmyadmin.net/
  --
  -- Host: 127.0.0.1
  -- Generation Time: Oct 15, 2019 at 05:25 AM
  -- Server version: 10.1.34-MariaDB
  -- PHP Version: 7.2.7
  
  SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  SET AUTOCOMMIT = 0;
  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: `latian_ukk`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `admin`
  --
  
  CREATE TABLE `admin` (
    `id_admin` int(11) NOT NULL,
    `username` varchar(50) NOT NULL,
    `password` varchar(50) NOT NULL,
    `nama_admin` varchar(50) NOT NULL,
    `id_level` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data for table `admin`
  --
  
  INSERT INTO `admin` (`id_admin`, `username`, `password`, `nama_admin`, `id_level`) VALUES
  (1, 'teller', 'teller', 'Saya Teller', 2),
  (2, 'manager', 'manager', 'Saya Manager', 1);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `level`
  --
  
  CREATE TABLE `level` (
    `id_level` int(11) NOT NULL,
    `nama_level` varchar(10) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data for table `level`
  --
  
  INSERT INTO `level` (`id_level`, `nama_level`) VALUES
  (1, 'Manager'),
  (2, 'Teller');
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `pelanggan`
  --
  
  CREATE TABLE `pelanggan` (
    `id_pelanggan` int(11) NOT NULL,
    `username` varchar(50) NOT NULL,
    `password` varchar(50) NOT NULL,
    `nomor_kwh` varchar(50) NOT NULL,
    `nama_pelanggan` varchar(50) NOT NULL,
    `alamat` text NOT NULL,
    `id_tarif` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data for table `pelanggan`
  --
  
  INSERT INTO `pelanggan` (`id_pelanggan`, `username`, `password`, `nomor_kwh`, `nama_pelanggan`, `alamat`, `id_tarif`) VALUES
  (2, 'pel1', 'pel1', '123456789', 'Pelanggan1', 'Malang', 1),
  (5, 'pel2', 'pel2', '123456788', 'Pelanggan2', 'Malang', 2),
  (6, 'pel3', 'pel3', '123456787', 'Pelanggan3', 'Malang', 4),
  (8, 'q', 'q', 'q', 'q', 'q', 1),
  (12, 'w', 'w', '11', 'w', 'w', 1);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `pembayaran`
  --
  
  CREATE TABLE `pembayaran` (
    `id_pembayaran` int(11) NOT NULL,
    `id_tagihan` int(11) NOT NULL,
    `tanggal_pembayaran` date NOT NULL,
    `bulan_bayar` varchar(20) NOT NULL,
    `biaya_admin` int(11) NOT NULL,
    `total_bayar` int(11) NOT NULL,
    `status` varchar(20) NOT NULL,
    `bukti` varchar(100) NOT NULL,
    `id_admin` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data for table `pembayaran`
  --
  
  INSERT INTO `pembayaran` (`id_pembayaran`, `id_tagihan`, `tanggal_pembayaran`, `bulan_bayar`, `biaya_admin`, `total_bayar`, `status`, `bukti`, `id_admin`) VALUES
  (8, 9, '2019-02-11', '1-2019', 2500, 152500, 'lunas', 'tirai3.jpg', 1),
  (9, 13, '2019-04-03', '7-2020', 2500, 3500, 'lunas', '2017-18-stephen-curry-warriors-30-association-rakuten-white-jersey.jpg', 2),
  (10, 10, '2019-04-03', '1-2020', 2500, 113500, 'lunas', '90f2cdd6a2f1c30b2415b99e2bec3c9b.jpg', 2);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `penggunaan`
  --
  
  CREATE TABLE `penggunaan` (
    `id_penggunaan` int(11) NOT NULL,
    `id_pelanggan` int(11) NOT NULL,
    `bulan` varchar(20) NOT NULL,
    `tahun` varchar(20) NOT NULL,
    `meter_awal` float NOT NULL,
    `meter_akhir` float NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data for table `penggunaan`
  --
  
  INSERT INTO `penggunaan` (`id_penggunaan`, `id_pelanggan`, `bulan`, `tahun`, `meter_awal`, `meter_akhir`) VALUES
  (17, 5, '2', '2019', 0, 100),
  (18, 6, '1', '2019', 0, 100),
  (19, 8, '1', '2020', 222, 333),
  (22, 8, '7', '2020', 123, 124);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `tagihan`
  --
  
  CREATE TABLE `tagihan` (
    `id_tagihan` int(11) NOT NULL,
    `id_penggunaan` int(11) NOT NULL,
    `bulan` varchar(20) NOT NULL,
    `tahun` varchar(20) NOT NULL,
    `jumlah_meter` float NOT NULL,
    `status` varchar(50) NOT NULL DEFAULT 'belum bayar'
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data for table `tagihan`
  --
  
  INSERT INTO `tagihan` (`id_tagihan`, `id_penggunaan`, `bulan`, `tahun`, `jumlah_meter`, `status`) VALUES
  (8, 17, '2', '2019', 100, 'lunas'),
  (9, 18, '1', '2019', 100, 'lunas'),
  (10, 19, '1', '2020', 111, 'lunas'),
  (13, 22, '7', '2020', 1, 'lunas');
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `tarif`
  --
  
  CREATE TABLE `tarif` (
    `id_tarif` int(11) NOT NULL,
    `daya` varchar(10) NOT NULL,
    `tarifperkwh` float NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  
  --
  -- Dumping data for table `tarif`
  --
  
  INSERT INTO `tarif` (`id_tarif`, `daya`, `tarifperkwh`) VALUES
  (1, '450', 1000),
  (2, '900', 1200),
  (4, '1300', 1500),
  (6, '222', 2);
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `admin`
  --
  ALTER TABLE `admin`
    ADD PRIMARY KEY (`id_admin`),
    ADD KEY `id_level` (`id_level`);
  
  --
  -- Indexes for table `level`
  --
  ALTER TABLE `level`
    ADD PRIMARY KEY (`id_level`);
  
  --
  -- Indexes for table `pelanggan`
  --
  ALTER TABLE `pelanggan`
    ADD PRIMARY KEY (`id_pelanggan`),
    ADD KEY `id_tarif` (`id_tarif`);
  
  --
  -- Indexes for table `pembayaran`
  --
  ALTER TABLE `pembayaran`
    ADD PRIMARY KEY (`id_pembayaran`),
    ADD UNIQUE KEY `id_tagihan` (`id_tagihan`),
    ADD KEY `id_admin` (`id_admin`);
  
  --
  -- Indexes for table `penggunaan`
  --
  ALTER TABLE `penggunaan`
    ADD PRIMARY KEY (`id_penggunaan`),
    ADD KEY `id_pelanggan` (`id_pelanggan`);
  
  --
  -- Indexes for table `tagihan`
  --
  ALTER TABLE `tagihan`
    ADD PRIMARY KEY (`id_tagihan`),
    ADD UNIQUE KEY `id_penggunaan` (`id_penggunaan`);
  
  --
  -- Indexes for table `tarif`
  --
  ALTER TABLE `tarif`
    ADD PRIMARY KEY (`id_tarif`);
  
  --
  -- AUTO_INCREMENT for dumped tables
  --
  
  --
  -- AUTO_INCREMENT for table `admin`
  --
  ALTER TABLE `admin`
    MODIFY `id_admin` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
  
  --
  -- AUTO_INCREMENT for table `level`
  --
  ALTER TABLE `level`
    MODIFY `id_level` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
  
  --
  -- AUTO_INCREMENT for table `pelanggan`
  --
  ALTER TABLE `pelanggan`
    MODIFY `id_pelanggan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
  
  --
  -- AUTO_INCREMENT for table `pembayaran`
  --
  ALTER TABLE `pembayaran`
    MODIFY `id_pembayaran` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
  
  --
  -- AUTO_INCREMENT for table `penggunaan`
  --
  ALTER TABLE `penggunaan`
    MODIFY `id_penggunaan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;
  
  --
  -- AUTO_INCREMENT for table `tagihan`
  --
  ALTER TABLE `tagihan`
    MODIFY `id_tagihan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
  
  --
  -- AUTO_INCREMENT for table `tarif`
  --
  ALTER TABLE `tarif`
    MODIFY `id_tarif` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
  
  --
  -- Constraints for dumped tables
  --
  
  --
  -- Constraints for table `admin`
  --
  ALTER TABLE `admin`
    ADD CONSTRAINT `fk_level` FOREIGN KEY (`id_level`) REFERENCES `level` (`id_level`);
  
  --
  -- Constraints for table `pelanggan`
  --
  ALTER TABLE `pelanggan`
    ADD CONSTRAINT `fk_tarif` FOREIGN KEY (`id_tarif`) REFERENCES `tarif` (`id_tarif`);
  
  --
  -- Constraints for table `pembayaran`
  --
  ALTER TABLE `pembayaran`
    ADD CONSTRAINT `pembayaran_ibfk_1` FOREIGN KEY (`id_tagihan`) REFERENCES `tagihan` (`id_tagihan`);
  
  --
  -- Constraints for table `penggunaan`
  --
  ALTER TABLE `penggunaan`
    ADD CONSTRAINT `fk_pelanggan` FOREIGN KEY (`id_pelanggan`) REFERENCES `pelanggan` (`id_pelanggan`);
  
  --
  -- Constraints for table `tagihan`
  --
  ALTER TABLE `tagihan`
    ADD CONSTRAINT `fk_penggunaan` FOREIGN KEY (`id_penggunaan`) REFERENCES `penggunaan` (`id_penggunaan`) 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 */;
  