-- phpMyAdmin SQL Dump
-- version 6.0.0-dev+20260316.8b2a2c41dc
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Jun 18, 2026 at 02:42 PM
-- Server version: 8.4.3
-- PHP Version: 8.4.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: `posyandu`
--

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

--
-- Table structure for table `edukasi`
--

CREATE TABLE `edukasi` (
  `id` int UNSIGNED NOT NULL,
  `kategori_id` int UNSIGNED NOT NULL,
  `judul` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL,
  `ringkasan` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `isi_konten` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `gambar` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_published` tinyint(1) DEFAULT '1',
  `views` int UNSIGNED DEFAULT '0',
  `created_by` int UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `ibu_hamil`
--

CREATE TABLE `ibu_hamil` (
  `id` int UNSIGNED NOT NULL,
  `nik` varchar(16) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nama_lengkap` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tanggal_lahir` date NOT NULL,
  `alamat` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `no_hp` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nama_suami` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `no_hp_suami` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `golongan_darah` enum('A','B','AB','O','Tidak Tahu') COLLATE utf8mb4_unicode_ci DEFAULT 'Tidak Tahu',
  `bidan_id` int UNSIGNED NOT NULL,
  `kehamilan_ke` tinyint UNSIGNED NOT NULL DEFAULT '1',
  `hpht` date NOT NULL,
  `hpl` date NOT NULL,
  `status` enum('Aktif','Melahirkan','Keguguran','Pindah') COLLATE utf8mb4_unicode_ci DEFAULT 'Aktif',
  `catatan` text COLLATE utf8mb4_unicode_ci,
  `tanggal_daftar` date NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `ibu_hamil`
--

INSERT INTO `ibu_hamil` (`id`, `nik`, `nama_lengkap`, `tanggal_lahir`, `alamat`, `no_hp`, `nama_suami`, `no_hp_suami`, `golongan_darah`, `bidan_id`, `kehamilan_ke`, `hpht`, `hpl`, `status`, `catatan`, `tanggal_daftar`, `created_at`, `updated_at`) VALUES
(12, '1503071606030004', 'Salsa Nabila', '2004-07-03', 'Siumbut Baru', '089877665463', 'Junanda Ardiansyah Putra', '085298809586', 'O', 1, 1, '2026-03-03', '2026-12-08', 'Aktif', 'Muntah Muntah', '2026-05-15', '2026-05-15 12:21:09', '2026-05-15 12:21:09');

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

--
-- Table structure for table `jadwal_posyandu`
--

CREATE TABLE `jadwal_posyandu` (
  `id` int UNSIGNED NOT NULL,
  `tanggal` date NOT NULL,
  `waktu_mulai` time NOT NULL,
  `waktu_selesai` time NOT NULL,
  `lokasi` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Balai Posyandu Tunas Bangsa',
  `kegiatan` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL,
  `keterangan` text COLLATE utf8mb4_unicode_ci,
  `created_by` int UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `kategori_edukasi`
--

CREATE TABLE `kategori_edukasi` (
  `id` int UNSIGNED NOT NULL,
  `nama` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `kategori_edukasi`
--

INSERT INTO `kategori_edukasi` (`id`, `nama`, `slug`) VALUES
(1, 'Trimester 1', 'trimester-1'),
(2, 'Trimester 2', 'trimester-2'),
(3, 'Trimester 3', 'trimester-3'),
(4, 'Gizi & Nutrisi', 'gizi-nutrisi'),
(5, 'Persiapan Persalinan', 'persiapan-persalinan'),
(6, 'Tanda Bahaya Kehamilan', 'tanda-bahaya'),
(7, 'Kesehatan Kehamilan', 'kesehatan-kehamilan'),
(8, 'Nutrisi', 'nutrisi'),
(10, 'Senam Hamil', 'senam-hamil');

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

--
-- Table structure for table `kunjungan_posyandu`
--

CREATE TABLE `kunjungan_posyandu` (
  `id` int UNSIGNED NOT NULL,
  `ibu_hamil_id` int UNSIGNED NOT NULL,
  `tanggal_kunjungan` date NOT NULL,
  `usia_kehamilan_minggu` tinyint UNSIGNED DEFAULT NULL,
  `tekanan_darah` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `berat_badan` decimal(5,2) DEFAULT NULL,
  `tinggi_fundus` decimal(5,2) DEFAULT NULL,
  `letak_janin` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `denyut_jantung_janin` smallint UNSIGNED DEFAULT NULL,
  `catatan` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci,
  `created_by` int UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `kunjungan_posyandu`
--

INSERT INTO `kunjungan_posyandu` (`id`, `ibu_hamil_id`, `tanggal_kunjungan`, `usia_kehamilan_minggu`, `tekanan_darah`, `berat_badan`, `tinggi_fundus`, `letak_janin`, `denyut_jantung_janin`, `catatan`, `created_by`, `created_at`, `updated_at`) VALUES
(1, 12, '2026-05-15', 10, '120', 26.00, 25.00, 'Lintang', 120, 'Kolah', 1, '2026-05-15 12:45:02', '2026-05-15 12:45:02');

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

--
-- Table structure for table `login_attempts`
--

CREATE TABLE `login_attempts` (
  `id` int UNSIGNED NOT NULL,
  `username` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `ip_address` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
  `attempted_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `login_attempts`
--

INSERT INTO `login_attempts` (`id`, `username`, `ip_address`, `attempted_at`) VALUES
(10, '1274014203910002', '::1', '2026-05-01 16:43:44');

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

--
-- Table structure for table `profil_posyandu`
--

CREATE TABLE `profil_posyandu` (
  `id` int UNSIGNED NOT NULL,
  `nama_posyandu` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'Posyandu Tunas Bangsa',
  `deskripsi` text COLLATE utf8mb4_unicode_ci,
  `alamat` text COLLATE utf8mb4_unicode_ci,
  `email` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `telepon` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `logo` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `foto_1` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `foto_2` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `foto_3` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `profil_posyandu`
--

INSERT INTO `profil_posyandu` (`id`, `nama_posyandu`, `deskripsi`, `alamat`, `email`, `telepon`, `logo`, `foto_1`, `foto_2`, `foto_3`, `updated_at`) VALUES
(1, 'Posyandu Tunas Bangsa', 'Pusat layanan kesehatan terpadu bagi ibu hamil, bayi, dan balita di Desa Mentawak Ulu. Bersama mewujudkan generasi sehat dan cerdas.', 'Desa Mentawak Ulu, Kec. Air Hitam, Kab. Merangin, Jambi', 'junandaardiansyahputra365@gmail.com', '0812-3456-7890', 'logo_1777622558.png', 'foto_1_1777691481.jpg', 'foto_2_1777654060.jpg', 'foto_3_1777654060.jpeg', '2026-05-04 02:13:22');

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

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

CREATE TABLE `users` (
  `id` int UNSIGNED NOT NULL,
  `username` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nama_lengkap` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `role` enum('admin','user') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'user',
  `no_hp` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `ibu_hamil_id` int UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

INSERT INTO `users` (`id`, `username`, `password`, `nama_lengkap`, `role`, `no_hp`, `is_active`, `ibu_hamil_id`, `created_at`, `updated_at`) VALUES
(1, 'admin', 'admin123', 'Sarnida Simatupang', 'admin', '081234567890', 1, NULL, '2026-04-30 17:11:16', '2026-04-30 17:25:07'),
(15, '1503071606030004', '03072004', 'Salsa Nabila', 'user', '089877665463', 1, 12, '2026-05-15 12:21:09', '2026-05-15 14:59:12');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `edukasi`
--
ALTER TABLE `edukasi`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `slug` (`slug`),
  ADD KEY `kategori_id` (`kategori_id`),
  ADD KEY `created_by` (`created_by`);

--
-- Indexes for table `ibu_hamil`
--
ALTER TABLE `ibu_hamil`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `nik` (`nik`),
  ADD KEY `idx_nik` (`nik`),
  ADD KEY `idx_nama` (`nama_lengkap`),
  ADD KEY `idx_hpl` (`hpl`),
  ADD KEY `idx_status` (`status`),
  ADD KEY `bidan_id` (`bidan_id`);

--
-- Indexes for table `jadwal_posyandu`
--
ALTER TABLE `jadwal_posyandu`
  ADD PRIMARY KEY (`id`),
  ADD KEY `created_by` (`created_by`);

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

--
-- Indexes for table `kunjungan_posyandu`
--
ALTER TABLE `kunjungan_posyandu`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_ibu_tanggal` (`ibu_hamil_id`,`tanggal_kunjungan`),
  ADD KEY `fk_kunjungan_creator` (`created_by`);

--
-- Indexes for table `login_attempts`
--
ALTER TABLE `login_attempts`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_username_time` (`username`,`attempted_at`);

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

--
-- 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 `edukasi`
--
ALTER TABLE `edukasi`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;

--
-- AUTO_INCREMENT for table `ibu_hamil`
--
ALTER TABLE `ibu_hamil`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;

--
-- AUTO_INCREMENT for table `jadwal_posyandu`
--
ALTER TABLE `jadwal_posyandu`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;

--
-- AUTO_INCREMENT for table `kategori_edukasi`
--
ALTER TABLE `kategori_edukasi`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `kunjungan_posyandu`
--
ALTER TABLE `kunjungan_posyandu`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `login_attempts`
--
ALTER TABLE `login_attempts`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;

--
-- AUTO_INCREMENT for table `profil_posyandu`
--
ALTER TABLE `profil_posyandu`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `edukasi`
--
ALTER TABLE `edukasi`
  ADD CONSTRAINT `edukasi_ibfk_1` FOREIGN KEY (`kategori_id`) REFERENCES `kategori_edukasi` (`id`),
  ADD CONSTRAINT `edukasi_ibfk_2` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `ibu_hamil`
--
ALTER TABLE `ibu_hamil`
  ADD CONSTRAINT `ibu_hamil_ibfk_1` FOREIGN KEY (`bidan_id`) REFERENCES `users` (`id`) ON UPDATE CASCADE;

--
-- Constraints for table `jadwal_posyandu`
--
ALTER TABLE `jadwal_posyandu`
  ADD CONSTRAINT `jadwal_posyandu_ibfk_1` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`);

--
-- Constraints for table `kunjungan_posyandu`
--
ALTER TABLE `kunjungan_posyandu`
  ADD CONSTRAINT `fk_kunjungan_creator` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_kunjungan_ibu` FOREIGN KEY (`ibu_hamil_id`) REFERENCES `ibu_hamil` (`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 */;
