-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Dec 02, 2025 at 07:01 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: `testmamikos`
--

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

--
-- Table structure for table `aktivitas_kerja`
--

CREATE TABLE `aktivitas_kerja` (
  `id` int(11) NOT NULL,
  `mitra_id` int(11) NOT NULL,
  `detail_kegiatan_id` int(11) NOT NULL,
  `tgl_mulai` date NOT NULL,
  `tgl_selesai` date NOT NULL,
  `jumlah_honor` decimal(15,2) NOT NULL,
  `jenis_kegiatan` enum('Pendataan','Pengolahan','Lainnya') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `aktivitas_kerja`
--

INSERT INTO `aktivitas_kerja` (`id`, `mitra_id`, `detail_kegiatan_id`, `tgl_mulai`, `tgl_selesai`, `jumlah_honor`, `jenis_kegiatan`) VALUES
(1, 1, 1, '2025-05-10', '2025-05-20', 1200000.00, 'Pendataan'),
(2, 2, 3, '2025-05-01', '2025-05-31', 800000.00, 'Pendataan'),
(3, 3, 3, '2025-06-01', '2025-06-30', 800000.00, 'Pendataan'),
(5, 3, 1, '2025-12-03', '2025-12-16', 8000000.00, 'Pendataan'),
(6, 1, 1, '2025-12-02', '2025-12-25', 500000.00, 'Pendataan');

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

--
-- Table structure for table `detail_kegiatan`
--

CREATE TABLE `detail_kegiatan` (
  `id` int(11) NOT NULL,
  `subkomponen_id` int(11) NOT NULL,
  `tahun_aktif_id` int(11) NOT NULL,
  `kode` varchar(50) DEFAULT NULL,
  `nama_detail` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `detail_kegiatan`
--

INSERT INTO `detail_kegiatan` (`id`, `subkomponen_id`, `tahun_aktif_id`, `kode`, `nama_detail`) VALUES
(1, 2, 1, NULL, 'Honor Peserta Pelatihan Listing 10 Hari'),
(2, 3, 1, NULL, 'Honor Pengawas Lapangan Listing'),
(3, 4, 1, NULL, 'Honor Pencacah Harga Bulanan'),
(4, 4, 1, NULL, 'Honor Pengolahan Dokumen');

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

--
-- Table structure for table `kegiatan`
--

CREATE TABLE `kegiatan` (
  `id` int(11) NOT NULL,
  `program_id` int(11) NOT NULL,
  `tahun_aktif_id` int(11) NOT NULL,
  `kode` varchar(50) DEFAULT NULL,
  `nama_kegiatan` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `kegiatan`
--

INSERT INTO `kegiatan` (`id`, `program_id`, `tahun_aktif_id`, `kode`, `nama_kegiatan`) VALUES
(1, 1, 1, NULL, 'Kegiatan Sensus Ekonomi'),
(2, 1, 1, NULL, 'Kegiatan Survei Harga Konsumen');

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

--
-- Table structure for table `komponen`
--

CREATE TABLE `komponen` (
  `id` int(11) NOT NULL,
  `subkegiatan_id` int(11) NOT NULL,
  `tahun_aktif_id` int(11) NOT NULL,
  `kode` varchar(50) DEFAULT NULL,
  `nama_komponen` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `komponen`
--

INSERT INTO `komponen` (`id`, `subkegiatan_id`, `tahun_aktif_id`, `kode`, `nama_komponen`) VALUES
(1, 1, 1, NULL, 'Komponen Pelatihan Listing'),
(2, 1, 1, NULL, 'Komponen Lapangan Listing'),
(3, 2, 1, NULL, 'Komponen Pengumpulan Data Harga');

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

--
-- Table structure for table `mitra`
--

CREATE TABLE `mitra` (
  `id` int(11) NOT NULL,
  `tahun_aktif_id` int(11) NOT NULL,
  `nama` varchar(100) NOT NULL,
  `nik` varchar(20) DEFAULT NULL,
  `alamat` text DEFAULT NULL,
  `no_hp` varchar(15) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `mitra`
--

INSERT INTO `mitra` (`id`, `tahun_aktif_id`, `nama`, `nik`, `alamat`, `no_hp`) VALUES
(1, 1, 'Andi Susanto', '3201011001950001', 'Jl. Merdeka No. 10', '081234567890'),
(2, 1, 'Budi Cahyono', '3201011002900002', 'Perum Asri Blok A5', '085678901234'),
(3, 1, 'Citra Dewi', '3201011003980003', 'Desa Sukamaju RT 03', '087890123456'),
(4, 1, 'Dina Amelia', '3201011004930004', 'Komplek Bunga No. 22', '081345678901');

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

--
-- Table structure for table `program`
--

CREATE TABLE `program` (
  `id` int(11) NOT NULL,
  `tahun_aktif_id` int(11) NOT NULL,
  `kode` varchar(50) DEFAULT NULL,
  `nama_program` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `program`
--

INSERT INTO `program` (`id`, `tahun_aktif_id`, `kode`, `nama_program`) VALUES
(1, 1, NULL, 'Program Penyediaan Data Strategis');

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

--
-- Table structure for table `subkegiatan`
--

CREATE TABLE `subkegiatan` (
  `id` int(11) NOT NULL,
  `kegiatan_id` int(11) NOT NULL,
  `tahun_aktif_id` int(11) NOT NULL,
  `kode` varchar(50) DEFAULT NULL,
  `nama_subkegiatan` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `subkegiatan`
--

INSERT INTO `subkegiatan` (`id`, `kegiatan_id`, `tahun_aktif_id`, `kode`, `nama_subkegiatan`) VALUES
(1, 1, 1, NULL, 'Subkegiatan Listing Wilayah SE'),
(2, 2, 1, NULL, 'Subkegiatan Pencacahan Data Harga');

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

--
-- Table structure for table `subkomponen`
--

CREATE TABLE `subkomponen` (
  `id` int(11) NOT NULL,
  `komponen_id` int(11) NOT NULL,
  `tahun_aktif_id` int(11) NOT NULL,
  `kode` varchar(50) DEFAULT NULL,
  `nama_subkomponen` varchar(150) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `subkomponen`
--

INSERT INTO `subkomponen` (`id`, `komponen_id`, `tahun_aktif_id`, `kode`, `nama_subkomponen`) VALUES
(1, 1, 1, NULL, 'Subkomponen Honor Instruktur'),
(2, 1, 1, NULL, 'Subkomponen Honor Peserta'),
(3, 2, 1, NULL, 'Subkomponen Honor Pengawas'),
(4, 3, 1, NULL, 'Subkomponen Honor Pencacah');

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

--
-- Table structure for table `tahun_aktif`
--

CREATE TABLE `tahun_aktif` (
  `id` int(11) NOT NULL,
  `tahun` year(4) NOT NULL,
  `is_aktif` tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `tahun_aktif`
--

INSERT INTO `tahun_aktif` (`id`, `tahun`, `is_aktif`) VALUES
(1, '2025', 1),
(2, '2024', 0),
(3, '2021', 0);

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

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

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `is_admin` tinyint(1) DEFAULT 0,
  `nama_lengkap` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `users` (`id`, `username`, `password`, `is_admin`, `nama_lengkap`) VALUES
(1, 'adminbps', '$2y$10$0b13/nv1fStvMVhYfeSoiOZCucuEC2vrfyuGP9TQv.vdAdyCKgvPi', 1, 'Admin BPS Utama'),
(2, 'admin', '$2y$10$y6AsUj/OzGgVasSQIqeioelmo.T6mC6Teuc.4m6HB.G5uIrnwe2pC', 1, 'Admin'),
(3, 'ruth', '$2y$10$6IdLEONOhFVkpJeqwxgV2O8MA5G65ul8wBd3UYeldWLeh24qnlyb6', 0, 'Ruth Madeline');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `aktivitas_kerja`
--
ALTER TABLE `aktivitas_kerja`
  ADD PRIMARY KEY (`id`),
  ADD KEY `mitra_id` (`mitra_id`),
  ADD KEY `detail_kegiatan_id` (`detail_kegiatan_id`);

--
-- Indexes for table `detail_kegiatan`
--
ALTER TABLE `detail_kegiatan`
  ADD PRIMARY KEY (`id`),
  ADD KEY `tahun_aktif_id` (`tahun_aktif_id`),
  ADD KEY `fk_detail_kegiatan_subkomponen` (`subkomponen_id`);

--
-- Indexes for table `kegiatan`
--
ALTER TABLE `kegiatan`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_kegiatan_tahun` (`tahun_aktif_id`,`kode`),
  ADD KEY `fk_kegiatan_program` (`program_id`);

--
-- Indexes for table `komponen`
--
ALTER TABLE `komponen`
  ADD PRIMARY KEY (`id`),
  ADD KEY `tahun_aktif_id` (`tahun_aktif_id`),
  ADD KEY `fk_komponen_subkegiatan` (`subkegiatan_id`);

--
-- Indexes for table `mitra`
--
ALTER TABLE `mitra`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `nik` (`nik`),
  ADD KEY `tahun_aktif_id` (`tahun_aktif_id`);

--
-- Indexes for table `program`
--
ALTER TABLE `program`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uk_program_tahun` (`tahun_aktif_id`,`kode`);

--
-- Indexes for table `subkegiatan`
--
ALTER TABLE `subkegiatan`
  ADD PRIMARY KEY (`id`),
  ADD KEY `tahun_aktif_id` (`tahun_aktif_id`),
  ADD KEY `fk_subkegiatan_kegiatan` (`kegiatan_id`);

--
-- Indexes for table `subkomponen`
--
ALTER TABLE `subkomponen`
  ADD PRIMARY KEY (`id`),
  ADD KEY `tahun_aktif_id` (`tahun_aktif_id`),
  ADD KEY `fk_subkomponen_komponen` (`komponen_id`);

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

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

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

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

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

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

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `aktivitas_kerja`
--
ALTER TABLE `aktivitas_kerja`
  ADD CONSTRAINT `aktivitas_kerja_ibfk_1` FOREIGN KEY (`mitra_id`) REFERENCES `mitra` (`id`),
  ADD CONSTRAINT `aktivitas_kerja_ibfk_2` FOREIGN KEY (`detail_kegiatan_id`) REFERENCES `detail_kegiatan` (`id`);

--
-- Constraints for table `detail_kegiatan`
--
ALTER TABLE `detail_kegiatan`
  ADD CONSTRAINT `detail_kegiatan_ibfk_2` FOREIGN KEY (`tahun_aktif_id`) REFERENCES `tahun_aktif` (`id`),
  ADD CONSTRAINT `fk_detail_kegiatan_subkomponen` FOREIGN KEY (`subkomponen_id`) REFERENCES `subkomponen` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `kegiatan`
--
ALTER TABLE `kegiatan`
  ADD CONSTRAINT `fk_kegiatan_program` FOREIGN KEY (`program_id`) REFERENCES `program` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `kegiatan_ibfk_2` FOREIGN KEY (`tahun_aktif_id`) REFERENCES `tahun_aktif` (`id`);

--
-- Constraints for table `komponen`
--
ALTER TABLE `komponen`
  ADD CONSTRAINT `fk_komponen_subkegiatan` FOREIGN KEY (`subkegiatan_id`) REFERENCES `subkegiatan` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `komponen_ibfk_2` FOREIGN KEY (`tahun_aktif_id`) REFERENCES `tahun_aktif` (`id`);

--
-- Constraints for table `mitra`
--
ALTER TABLE `mitra`
  ADD CONSTRAINT `mitra_ibfk_1` FOREIGN KEY (`tahun_aktif_id`) REFERENCES `tahun_aktif` (`id`);

--
-- Constraints for table `program`
--
ALTER TABLE `program`
  ADD CONSTRAINT `program_ibfk_1` FOREIGN KEY (`tahun_aktif_id`) REFERENCES `tahun_aktif` (`id`);

--
-- Constraints for table `subkegiatan`
--
ALTER TABLE `subkegiatan`
  ADD CONSTRAINT `fk_subkegiatan_kegiatan` FOREIGN KEY (`kegiatan_id`) REFERENCES `kegiatan` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `subkomponen`
--
ALTER TABLE `subkomponen`
  ADD CONSTRAINT `fk_subkomponen_komponen` FOREIGN KEY (`komponen_id`) REFERENCES `komponen` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `subkomponen_ibfk_2` FOREIGN KEY (`tahun_aktif_id`) REFERENCES `tahun_aktif` (`id`);
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 */;
