-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Oct 24, 2025 at 01:24 PM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12

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: `db_ruangtik`
--

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

--
-- Table structure for table `kehadiran`
--

CREATE TABLE `kehadiran` (
  `siswa_id` int(11) NOT NULL,
  `tanggal` date NOT NULL,
  `status` enum('H','I','S','A') NOT NULL DEFAULT 'A',
  `bulan` varchar(7) NOT NULL COMMENT 'Format YYYY-MM untuk rekap'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `kehadiran`
--

INSERT INTO `kehadiran` (`siswa_id`, `tanggal`, `status`, `bulan`) VALUES
(1, '2025-10-24', 'H', '2025-10'),
(2, '2025-10-24', 'H', '2025-10'),
(14, '2025-10-24', 'H', '2025-10'),
(15, '2025-10-24', 'H', '2025-10'),
(16, '2025-10-24', 'H', '2025-10');

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

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

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

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

INSERT INTO `kelas` (`id`, `nama_kelas`) VALUES
(4, '1');

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

--
-- Table structure for table `qr_tokens`
--

CREATE TABLE `qr_tokens` (
  `id` int(11) NOT NULL,
  `token` varchar(100) NOT NULL,
  `expiry_time` datetime NOT NULL,
  `created_at` datetime DEFAULT current_timestamp(),
  `is_used` tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `qr_tokens`
--

INSERT INTO `qr_tokens` (`id`, `token`, `expiry_time`, `created_at`, `is_used`) VALUES
(17, 'KANTOR_20251024_014808_a2378b7a', '2025-10-24 01:53:08', '2025-10-24 01:48:08', 0),
(18, 'KANTOR_20251024_014856_01c7a28f', '2025-10-24 01:53:56', '2025-10-24 01:48:56', 0);

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

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

CREATE TABLE `siswa` (
  `siswa_id` int(11) NOT NULL,
  `nama` varchar(100) NOT NULL,
  `jenis_kelamin` enum('L','P') DEFAULT NULL COMMENT 'L: Laki-laki, P: Perempuan',
  `tempat_lahir` varchar(100) DEFAULT NULL,
  `tanggal_lahir` date DEFAULT NULL,
  `nisn` varchar(10) DEFAULT NULL,
  `kelas_id` int(11) NOT NULL,
  `foto_path` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `siswa` (`siswa_id`, `nama`, `jenis_kelamin`, `tempat_lahir`, `tanggal_lahir`, `nisn`, `kelas_id`, `foto_path`) VALUES
(1, 'Wellyanson Xavier', 'L', 'e', '2025-10-21', '2345', 4, 'https://i.pinimg.com/736x/8d/19/c1/8d19c1b559067e2dab8c78a954ffdd82.jpg'),
(2, 'Malik Maycello', 'L', 'wer', '2025-10-21', '456', 4, 'https://th.bing.com/th/id/R.b234f2398e5e53077321f5f7a92d8948?rik=QdstT1MwhldVDQ&riu=http%3a%2f%2fstatic.newworldencyclopedia.org%2fc%2fc5%2fSoekarno.jpg&ehk=sYXIdITrM26jY2fJ%2fAe%2bXtVn0nKXqs5NlDg9mFS5iV4%3d&risl=&pid=ImgRaw&r=0'),
(3, 'M. Kinza Ahyan Ramadhan', 'L', 'wert', '2025-10-21', '789', 4, NULL),
(4, 'Ridwan Supriatna', 'L', 'wer', '2025-10-21', '345678', 4, NULL),
(12, 'indi', NULL, NULL, NULL, NULL, 1, NULL),
(14, 'xavier saja', 'L', 'Tangsel', '2025-10-23', '155465', 4, 'https://i.pinimg.com/736x/8d/19/c1/8d19c1b559067e2dab8c78a954ffdd82.jpg'),
(15, 'Muhammad Kinza', 'L', 'Banten', '2025-10-27', '888888', 4, NULL),
(16, 'Sachi', 'P', 'Pamulang', '2025-10-24', '1234567', 4, NULL);

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

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `siswa_id` int(11) DEFAULT NULL,
  `role` enum('siswa','admin') DEFAULT 'siswa',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `username`, `password`, `siswa_id`, `role`, `created_at`) VALUES
(1, 'admin', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', NULL, 'admin', '2025-10-23 15:16:14'),
(3, 'a', '$2y$10$R/nmWqLJ029r1AWXev1pKuvY5avRr4aGUnNig9v7.EEl2Vl1TqqcC', 12, 'siswa', '2025-10-23 15:39:13'),
(5, 'xavier', '$2y$10$kPPLUD8lxYl830Abg4tMl.lzD5HaQUxoqhKkRNkc.msLfGGlotlJm', 14, 'siswa', '2025-10-23 15:56:19'),
(6, 'kinza', '$2y$10$LntTutC6NOoAJZQcab6wo.z9MjqbF.zPjj8bQnFW4fYU2ZRzGKU36', 15, 'siswa', '2025-10-23 18:03:27');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `kehadiran`
--
ALTER TABLE `kehadiran`
  ADD PRIMARY KEY (`siswa_id`,`tanggal`);

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

--
-- Indexes for table `qr_tokens`
--
ALTER TABLE `qr_tokens`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `token` (`token`);

--
-- Indexes for table `siswa`
--
ALTER TABLE `siswa`
  ADD PRIMARY KEY (`siswa_id`),
  ADD UNIQUE KEY `nisn` (`nisn`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`),
  ADD KEY `siswa_id` (`siswa_id`);

--
-- AUTO_INCREMENT for dumped tables
--

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

--
-- AUTO_INCREMENT for table `qr_tokens`
--
ALTER TABLE `qr_tokens`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `kehadiran`
--
ALTER TABLE `kehadiran`
  ADD CONSTRAINT `kehadiran_ibfk_1` FOREIGN KEY (`siswa_id`) REFERENCES `siswa` (`siswa_id`) ON DELETE CASCADE;

--
-- Constraints for table `users`
--
ALTER TABLE `users`
  ADD CONSTRAINT `users_ibfk_1` FOREIGN KEY (`siswa_id`) REFERENCES `siswa` (`siswa_id`) ON DELETE 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 */;
