-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `db_absensi`
--

-- --------------------------------------------------------

--
-- Table structure for table `absensi`
--

CREATE TABLE `absensi` (
  `id_absensi` int(11) NOT NULL,
  `id_jadwal` int(11) NOT NULL,
  `id_siswa` int(11) NOT NULL,
  `tanggal_absensi` date NOT NULL,
  `status` enum('hadir','sakit','alpa') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `absensi`
--

INSERT INTO `absensi` (`id_absensi`, `id_jadwal`, `id_siswa`, `tanggal_absensi`, `status`) VALUES
(1, 1, 1, '2026-05-07', 'hadir'),
(2, 1, 2, '2026-05-07', 'alpa'),
(3, 1, 3, '2026-05-07', 'sakit'),
(4, 1, 4, '2026-05-07', 'alpa'),
(5, 1, 5, '2026-05-07', 'hadir'),
(11, 3, 11, '2026-05-07', 'hadir'),
(12, 3, 12, '2026-05-07', 'alpa'),
(13, 3, 13, '2026-05-07', 'sakit'),
(14, 3, 14, '2026-05-07', 'hadir'),
(15, 3, 15, '2026-05-07', 'hadir'),
(16, 7, 1, '2026-05-07', 'hadir'),
(17, 7, 2, '2026-05-07', 'hadir'),
(18, 7, 3, '2026-05-07', 'hadir'),
(19, 7, 4, '2026-05-07', 'hadir'),
(20, 7, 5, '2026-05-07', 'sakit');

-- --------------------------------------------------------

--
-- Table structure for table `jadwal`
--

CREATE TABLE `jadwal` (
  `id_jadwal` int(11) NOT NULL,
  `id_guru` int(11) NOT NULL,
  `id_kelas` int(11) NOT NULL,
  `id_mapel` int(11) NOT NULL,
  `hari` varchar(20) NOT NULL,
  `jam_mulai` time NOT NULL,
  `jam_selesai` time NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `jadwal`
--

INSERT INTO `jadwal` (`id_jadwal`, `id_guru`, `id_kelas`, `id_mapel`, `hari`, `jam_mulai`, `jam_selesai`) VALUES
(1, 1, 1, 1, 'Senin', '07:00:00', '08:30:00'),
(2, 1, 2, 6, 'Senin', '09:00:00', '10:30:00'),
(3, 1, 3, 3, 'Kamis', '07:00:00', '08:30:00'),
(4, 1, 4, 1, 'Kamis', '09:00:00', '10:30:00'),
(5, 1, 5, 1, 'Rabu', '07:00:00', '08:30:00'),
(6, 1, 6, 1, 'Rabu', '09:00:00', '10:30:00'),
(7, 2, 1, 2, 'Kamis', '07:00:00', '08:30:00'),
(8, 2, 2, 2, 'Kamis', '09:00:00', '10:30:00'),
(9, 2, 3, 2, 'Jumat', '07:00:00', '08:30:00'),
(10, 2, 4, 2, 'Jumat', '09:00:00', '10:30:00'),
(11, 2, 5, 2, 'Sabtu', '07:00:00', '08:30:00'),
(12, 2, 6, 2, 'Sabtu', '09:00:00', '10:30:00');

-- --------------------------------------------------------

--
-- Table structure for table `kelas`
--

CREATE TABLE `kelas` (
  `id_kelas` int(11) NOT NULL,
  `nama_kelas` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `kelas`
--

INSERT INTO `kelas` (`id_kelas`, `nama_kelas`) VALUES
(1, 'X IPA 1'),
(2, 'X IPA 2'),
(3, 'XI IPA 1'),
(4, 'XI IPA 2'),
(5, 'XII IPA 1'),
(6, 'XII IPA 2');

-- --------------------------------------------------------

--
-- Table structure for table `mata_pelajaran`
--

CREATE TABLE `mata_pelajaran` (
  `id_mapel` int(11) NOT NULL,
  `nama_mapel` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `mata_pelajaran`
--

INSERT INTO `mata_pelajaran` (`id_mapel`, `nama_mapel`) VALUES
(1, 'Matematika'),
(2, 'Fisika'),
(3, 'Kimia'),
(4, 'Biologi'),
(5, 'Bahasa Indonesia'),
(6, 'Bahasa Inggris');

-- --------------------------------------------------------

--
-- Table structure for table `siswa`
--

CREATE TABLE `siswa` (
  `id_siswa` int(11) NOT NULL,
  `nis` varchar(20) NOT NULL,
  `nama_siswa` varchar(100) NOT NULL,
  `id_kelas` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `siswa`
--

INSERT INTO `siswa` (`id_siswa`, `nis`, `nama_siswa`, `id_kelas`) VALUES
(1, '010001', 'Ahmad Fauzia', 1),
(2, '010002', 'Bunga Citra Lestari', 1),
(3, '010003', 'Citra Dewi', 1),
(4, '010004', 'Dedi Kurniawan', 1),
(5, '010005', 'Eka Putri', 1),
(6, '020001', 'Fajar Nugroho', 2),
(7, '020002', 'Gita Permata', 2),
(8, '020003', 'Hadi Prasetyo', 2),
(9, '020004', 'Indah Sari', 2),
(10, '020005', 'Joko Widodo', 2),
(11, '030001', 'Kartika Sari', 3),
(12, '030002', 'Lukman Hakim', 3),
(13, '030003', 'Maya Anggraini', 3),
(14, '030004', 'Nugroho Adi', 3),
(15, '030005', 'Olivia Putri', 3),
(16, '040001', 'Prayoga Budi', 4),
(17, '040002', 'Rina Marlina', 4),
(18, '040003', 'Satrio Wibowo', 4),
(19, '040004', 'Titis Ayu', 4),
(20, '040005', 'Umar Kholid', 4),
(21, '050001', 'Vina Amelia', 5),
(22, '050002', 'Wahyu Hidayat', 5),
(23, '050003', 'Xaverius Dwi', 5),
(24, '050004', 'Yuniarti', 5),
(25, '050005', 'Zainal Abidin', 5),
(26, '060001', 'Agus Salim', 6),
(27, '060002', 'Bambang Tri', 6),
(28, '060003', 'Cahya Ningsih', 6),
(29, '060004', 'Dian Pertiwi', 6),
(30, '060005', 'Endah Lestari', 6);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `absensi`
--
ALTER TABLE `absensi`
  ADD PRIMARY KEY (`id_absensi`),
  ADD UNIQUE KEY `unique_absensi` (`id_jadwal`,`id_siswa`,`tanggal_absensi`),
  ADD KEY `id_siswa` (`id_siswa`);

--
-- Indexes for table `jadwal`
--
ALTER TABLE `jadwal`
  ADD PRIMARY KEY (`id_jadwal`),
  ADD KEY `id_guru` (`id_guru`),
  ADD KEY `id_kelas` (`id_kelas`),
  ADD KEY `id_mapel` (`id_mapel`);

--
-- Indexes for table `kelas`
--
ALTER TABLE `kelas`
  ADD PRIMARY KEY (`id_kelas`);

--
-- Indexes for table `mata_pelajaran`
--
ALTER TABLE `mata_pelajaran`
  ADD PRIMARY KEY (`id_mapel`);

--
-- Indexes for table `siswa`
--
ALTER TABLE `siswa`
  ADD PRIMARY KEY (`id_siswa`),
  ADD UNIQUE KEY `nis` (`nis`),
  ADD KEY `id_kelas` (`id_kelas`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `absensi`
--
ALTER TABLE `absensi`
  MODIFY `id_absensi` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;

--
-- AUTO_INCREMENT for table `jadwal`
--
ALTER TABLE `jadwal`
  MODIFY `id_jadwal` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;

--
-- AUTO_INCREMENT for table `kelas`
--
ALTER TABLE `kelas`
  MODIFY `id_kelas` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `mata_pelajaran`
--
ALTER TABLE `mata_pelajaran`
  MODIFY `id_mapel` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `siswa`
--
ALTER TABLE `siswa`
  MODIFY `id_siswa` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=31;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `absensi`
--
ALTER TABLE `absensi`
  ADD CONSTRAINT `absensi_ibfk_1` FOREIGN KEY (`id_jadwal`) REFERENCES `jadwal` (`id_jadwal`) ON DELETE CASCADE,
  ADD CONSTRAINT `absensi_ibfk_2` FOREIGN KEY (`id_siswa`) REFERENCES `siswa` (`id_siswa`) ON DELETE CASCADE;

--
-- Constraints for table `jadwal`
--
ALTER TABLE `jadwal`
  ADD CONSTRAINT `jadwal_ibfk_1` FOREIGN KEY (`id_guru`) REFERENCES `guru` (`id_guru`) ON DELETE CASCADE,
  ADD CONSTRAINT `jadwal_ibfk_2` FOREIGN KEY (`id_kelas`) REFERENCES `kelas` (`id_kelas`) ON DELETE CASCADE,
  ADD CONSTRAINT `jadwal_ibfk_3` FOREIGN KEY (`id_mapel`) REFERENCES `mata_pelajaran` (`id_mapel`) ON DELETE CASCADE;

--
-- Constraints for table `siswa`
--
ALTER TABLE `siswa`
  ADD CONSTRAINT `siswa_ibfk_1` FOREIGN KEY (`id_kelas`) REFERENCES `kelas` (`id_kelas`) ON DELETE CASCADE;
COMMIT;

