text: -- phpMyAdmin SQL Dump
  -- version 4.5.2
  -- http://www.phpmyadmin.net
  --
  -- Host: localhost:3306
  -- Generation Time: May 13, 2016 at 07:16 AM
  -- Server version: 5.6.26
  -- PHP Version: 7.0.0
  
  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: `siakad`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `fakultas`
  --
  
  CREATE TABLE `fakultas` (
    `id` int(11) NOT NULL,
    `name` varchar(255) NOT NULL,
    `jenjang` enum('D3','S1','S2','S3') NOT NULL DEFAULT 'S1'
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  --
  -- Dumping data for table `fakultas`
  --
  
  INSERT INTO `fakultas` (`id`, `name`, `jenjang`) VALUES
  (1, 'Ilmu Komputer', 'S1'),
  (2, 'Elektro & Telekomunikasi', 'S1');
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `jurusan`
  --
  
  CREATE TABLE `jurusan` (
    `id` int(11) NOT NULL,
    `fakultas_id` int(11) NOT NULL,
    `name` varchar(255) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  --
  -- Dumping data for table `jurusan`
  --
  
  INSERT INTO `jurusan` (`id`, `fakultas_id`, `name`) VALUES
  (1, 1, 'Teknik Informatika');
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `mahasiswa`
  --
  
  CREATE TABLE `mahasiswa` (
    `id` int(11) NOT NULL,
    `nim` varchar(15) NOT NULL,
    `name` varchar(255) NOT NULL,
    `jurusan_id` int(11) NOT NULL,
    `tahun` year(4) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  --
  -- Dumping data for table `mahasiswa`
  --
  
  INSERT INTO `mahasiswa` (`id`, `nim`, `name`, `jurusan_id`, `tahun`) VALUES
  (1, '123', 'Budi', 1, 2016),
  (2, '124', 'Fuad', 1, 2016);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `matakuliah`
  --
  
  CREATE TABLE `matakuliah` (
    `id` int(11) NOT NULL,
    `kode` varchar(15) NOT NULL,
    `name` varchar(150) NOT NULL,
    `sks` int(2) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  --
  -- Dumping data for table `matakuliah`
  --
  
  INSERT INTO `matakuliah` (`id`, `kode`, `name`, `sks`) VALUES
  (1, '001', 'Database', 3),
  (2, '002', 'Programming', 4);
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `nilai`
  --
  
  CREATE TABLE `nilai` (
    `id` int(11) NOT NULL,
    `mahasiswa_id` int(11) NOT NULL,
    `ijazah` varchar(50) NOT NULL,
    `skripsi` varchar(255) NOT NULL,
    `sks` int(5) NOT NULL,
    `nilai` decimal(5,2) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  --
  -- Dumping data for table `nilai`
  --
  
  INSERT INTO `nilai` (`id`, `mahasiswa_id`, `ijazah`, `skripsi`, `sks`, `nilai`) VALUES
  (1, 1, 'ABC123', 'Membangun XYZ', 40, '99.99'),
  (2, 2, 'DEF456', 'Evaluasi Aplikasi ..', 42, '99.99');
  
  -- --------------------------------------------------------
  
  --
  -- Table structure for table `studi`
  --
  
  CREATE TABLE `studi` (
    `id` int(11) NOT NULL,
    `mahasiswa_id` int(11) NOT NULL,
    `matakuliah_id` int(11) NOT NULL,
    `nilai` decimal(3,2) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  --
  -- Dumping data for table `studi`
  --
  
  INSERT INTO `studi` (`id`, `mahasiswa_id`, `matakuliah_id`, `nilai`) VALUES
  (1, 1, 1, '3.70'),
  (2, 1, 2, '3.20'),
  (3, 2, 1, '9.99');
  
  --
  -- Indexes for dumped tables
  --
  
  --
  -- Indexes for table `fakultas`
  --
  ALTER TABLE `fakultas`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `jurusan`
  --
  ALTER TABLE `jurusan`
    ADD PRIMARY KEY (`id`),
    ADD KEY `fakultas_id` (`fakultas_id`);
  
  --
  -- Indexes for table `mahasiswa`
  --
  ALTER TABLE `mahasiswa`
    ADD PRIMARY KEY (`id`),
    ADD UNIQUE KEY `nim` (`nim`),
    ADD KEY `jurusan_id` (`jurusan_id`);
  
  --
  -- Indexes for table `matakuliah`
  --
  ALTER TABLE `matakuliah`
    ADD PRIMARY KEY (`id`);
  
  --
  -- Indexes for table `nilai`
  --
  ALTER TABLE `nilai`
    ADD PRIMARY KEY (`id`),
    ADD KEY `mahasiswa_id` (`mahasiswa_id`);
  
  --
  -- Indexes for table `studi`
  --
  ALTER TABLE `studi`
    ADD PRIMARY KEY (`id`),
    ADD KEY `mahasiswa_id` (`mahasiswa_id`),
    ADD KEY `matakuliah_id` (`matakuliah_id`);
  
  --
  -- AUTO_INCREMENT for dumped tables
  --
  
  --
  -- AUTO_INCREMENT for table `fakultas`
  --
  ALTER TABLE `fakultas`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
  --
  -- AUTO_INCREMENT for table `jurusan`
  --
  ALTER TABLE `jurusan`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
  --
  -- AUTO_INCREMENT for table `mahasiswa`
  --
  ALTER TABLE `mahasiswa`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
  --
  -- AUTO_INCREMENT for table `matakuliah`
  --
  ALTER TABLE `matakuliah`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
  --
  -- AUTO_INCREMENT for table `nilai`
  --
  ALTER TABLE `nilai`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
  --
  -- AUTO_INCREMENT for table `studi`
  --
  ALTER TABLE `studi`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
  --
  -- Constraints for dumped tables
  --
  
  --
  -- Constraints for table `jurusan`
  --
  ALTER TABLE `jurusan`
    ADD CONSTRAINT `jurusan_ibfk_1` FOREIGN KEY (`fakultas_id`) REFERENCES `fakultas` (`id`);
  
  --
  -- Constraints for table `mahasiswa`
  --
  ALTER TABLE `mahasiswa`
    ADD CONSTRAINT `mahasiswa_ibfk_1` FOREIGN KEY (`jurusan_id`) REFERENCES `jurusan` (`id`);
  
  --
  -- Constraints for table `nilai`
  --
  ALTER TABLE `nilai`
    ADD CONSTRAINT `nilai_ibfk_1` FOREIGN KEY (`mahasiswa_id`) REFERENCES `mahasiswa` (`id`);
  
  --
  -- Constraints for table `studi`
  --
  ALTER TABLE `studi`
    ADD CONSTRAINT `studi_ibfk_1` FOREIGN KEY (`mahasiswa_id`) REFERENCES `mahasiswa` (`id`),
    ADD CONSTRAINT `studi_ibfk_2` FOREIGN KEY (`matakuliah_id`) REFERENCES `matakuliah` (`id`);
  
  /*!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 */;
  