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

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

--
-- Table structure for table `admin`
--

CREATE TABLE `admin` (
  `id` int(11) NOT NULL,
  `nama` varchar(100) NOT NULL,
  `email` varchar(150) NOT NULL,
  `password` varchar(255) NOT NULL,
  `status` enum('aktif','nonaktif') NOT NULL DEFAULT 'aktif',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `admin`
--

INSERT INTO `admin` (`id`, `nama`, `email`, `password`, `status`, `created_at`) VALUES
(2, 'Admin', 'admin@admin.com', '$2y$10$wUrYCRXLn/kUJwNtCtyRF.waS50yDrj5w6aoCaQahNCDHVCahXonO', 'aktif', '2025-11-05 13:50:03'),
(3, 'admin1', 'admin1@admin.com', '$2y$10$9iaVnJjS/NU5diogW/PdneLUB0m2V/aOmvoao6WBlkRCpuNuY2R0C', 'aktif', '2025-11-07 05:14:11');

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

--
-- Table structure for table `admin_subscription`
--

CREATE TABLE `admin_subscription` (
  `id_subscription` int(11) NOT NULL,
  `id_admin` int(11) NOT NULL,
  `status` enum('active','expired','pending') NOT NULL,
  `start_date` datetime NOT NULL,
  `end_date` datetime NOT NULL,
  `payment_method` varchar(50) DEFAULT NULL,
  `payment_ref` varchar(100) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `admin_subscription`
--

INSERT INTO `admin_subscription` (`id_subscription`, `id_admin`, `status`, `start_date`, `end_date`, `payment_method`, `payment_ref`, `created_at`) VALUES
(1, 2, 'active', '2025-12-01 00:00:00', '2027-01-31 00:00:00', 'manual', 'SUBS001', '2025-12-03 16:10:51');

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

--
-- Table structure for table `chat_connections`
--

CREATE TABLE `chat_connections` (
  `id` int(11) NOT NULL,
  `connection_id` varchar(255) NOT NULL,
  `user_type` enum('admin','penghuni') NOT NULL,
  `user_id` int(11) NOT NULL,
  `is_online` tinyint(1) DEFAULT 0,
  `last_seen` timestamp NOT NULL DEFAULT current_timestamp(),
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `chat_message`
--

CREATE TABLE `chat_message` (
  `id_chat` int(11) NOT NULL,
  `id_penghuni` int(11) NOT NULL,
  `id_admin` int(11) NOT NULL,
  `message` text NOT NULL,
  `sender` enum('penghuni','admin') NOT NULL,
  `is_read` tinyint(1) DEFAULT 0,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `is_delivered` tinyint(1) DEFAULT 0,
  `is_read_admin` tinyint(1) DEFAULT 0,
  `is_read_penghuni` tinyint(1) DEFAULT 0,
  `message_type` enum('text','image','file') DEFAULT 'text',
  `file_url` varchar(500) DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `chat_message`
--

INSERT INTO `chat_message` (`id_chat`, `id_penghuni`, `id_admin`, `message`, `sender`, `is_read`, `created_at`, `is_delivered`, `is_read_admin`, `is_read_penghuni`, `message_type`, `file_url`, `deleted_at`) VALUES
(53, 2, 2, 'hsaaalooo', 'penghuni', 0, '2025-12-03 11:12:31', 0, 1, 1, 'text', NULL, NULL),
(54, 2, 2, 'jnjnnjb', 'penghuni', 0, '2025-12-03 11:16:11', 0, 1, 1, 'text', NULL, NULL),
(55, 2, 2, 'jnjnnjb', 'penghuni', 0, '2025-12-03 11:16:19', 0, 1, 1, 'text', NULL, NULL),
(56, 2, 2, 'jbasjkdbjasdn', 'penghuni', 0, '2025-12-03 11:16:48', 0, 1, 1, 'text', NULL, NULL),
(57, 2, 2, 'sihwud', 'penghuni', 0, '2025-12-03 11:26:45', 0, 1, 1, 'text', NULL, NULL),
(58, 2, 2, 'wuhuwhduwdfh', 'penghuni', 0, '2025-12-03 20:32:03', 0, 1, 1, 'text', NULL, NULL),
(59, 2, 2, 'siqdwidd', 'admin', 0, '2025-12-03 21:03:24', 0, 1, 0, 'text', NULL, NULL),
(60, 2, 2, 'ssssss', 'admin', 0, '2025-12-03 21:03:38', 0, 1, 0, 'text', NULL, NULL),
(61, 2, 2, 'sddd', 'admin', 0, '2025-12-03 21:04:05', 0, 1, 0, 'text', NULL, NULL),
(62, 2, 2, 'ddkdkkdkd', 'admin', 0, '2025-12-03 21:09:30', 0, 1, 0, 'text', NULL, NULL),
(63, 2, 2, 'haloo', 'admin', 0, '2025-12-03 21:10:30', 0, 1, 0, 'text', NULL, NULL),
(64, 2, 2, 'dwewqfdewq', 'penghuni', 0, '2025-12-05 08:13:27', 0, 1, 1, 'text', NULL, NULL),
(65, 2, 2, 'wsdwd', 'penghuni', 0, '2025-12-05 08:18:39', 0, 1, 1, 'text', NULL, NULL),
(66, 2, 2, 'halooo', 'penghuni', 0, '2025-12-05 08:18:48', 0, 1, 1, 'text', NULL, NULL),
(67, 2, 2, 'halooo', 'penghuni', 0, '2025-12-05 08:18:51', 0, 1, 1, 'text', NULL, NULL),
(68, 2, 2, 'efewfwefew', 'penghuni', 0, '2025-12-05 08:40:10', 0, 1, 1, 'text', NULL, NULL),
(69, 2, 2, 'fefef', 'penghuni', 0, '2025-12-05 08:40:23', 0, 1, 1, 'text', NULL, NULL),
(70, 2, 2, 'fefef', 'penghuni', 0, '2025-12-05 08:40:25', 0, 1, 1, 'text', NULL, NULL),
(71, 2, 2, 'yoooo', 'admin', 0, '2025-12-05 08:40:42', 0, 1, 0, 'text', NULL, NULL),
(72, 2, 2, 'dwdw', 'admin', 0, '2025-12-05 08:41:03', 0, 1, 0, 'text', NULL, NULL),
(73, 2, 2, 'wdweddddddd', 'penghuni', 0, '2025-12-05 09:09:44', 0, 1, 1, 'text', NULL, NULL),
(74, 2, 2, 'dddd', 'admin', 0, '2025-12-05 09:09:54', 0, 1, 0, 'text', NULL, NULL),
(75, 2, 2, 'sssssss', 'admin', 0, '2025-12-05 09:23:43', 0, 1, 0, 'text', NULL, NULL);

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

--
-- Table structure for table `chat_sessions`
--

CREATE TABLE `chat_sessions` (
  `id` int(11) NOT NULL,
  `id_penghuni` int(11) NOT NULL,
  `id_admin` int(11) NOT NULL,
  `last_message_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `unread_count_admin` int(11) DEFAULT 0,
  `unread_count_penghuni` int(11) DEFAULT 0,
  `is_active` tinyint(1) DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `chat_sessions`
--

INSERT INTO `chat_sessions` (`id`, `id_penghuni`, `id_admin`, `last_message_at`, `unread_count_admin`, `unread_count_penghuni`, `is_active`) VALUES
(1, 2, 2, '2025-12-03 20:32:03', 0, 0, 1);

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

--
-- Table structure for table `detail_laporan`
--

CREATE TABLE `detail_laporan` (
  `id_detail_laporan` int(11) NOT NULL,
  `id_laporan` int(11) NOT NULL,
  `id_penghuni` int(11) DEFAULT NULL,
  `keterangan` text NOT NULL,
  `gambar` varchar(255) DEFAULT NULL,
  `status` enum('Diajukan','Diproses','Selesai') DEFAULT 'Diajukan',
  `tanggal_update` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `iklan`
--

CREATE TABLE `iklan` (
  `id_iklan` int(11) NOT NULL,
  `id_admin` int(11) DEFAULT NULL,
  `id_kos` int(11) DEFAULT NULL,
  `judul` varchar(150) NOT NULL,
  `deskripsi` text DEFAULT NULL,
  `gambar` varchar(255) NOT NULL,
  `link` varchar(255) DEFAULT NULL,
  `urutan` int(3) DEFAULT 0,
  `status` enum('Aktif','Nonaktif') DEFAULT 'Aktif',
  `tanggal_dibuat` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `iklan`
--

INSERT INTO `iklan` (`id_iklan`, `id_admin`, `id_kos`, `judul`, `deskripsi`, `gambar`, `link`, `urutan`, `status`, `tanggal_dibuat`) VALUES
(12, 2, 1, 'ewdwedew3', 'dwdewdewd', '08daf918674b032ea8375fee8b016ea4.jpg', 'asasa.comahttps://www.youtube.com/watch?v=B9KFb_fmvV8&list=RDcXDOHqa_QgY&index=4', 1, 'Aktif', '2025-11-06 14:58:30'),
(13, 2, 2, 'dwwqdqw3d', 'dww', '0b29c373df741adcbeec01f7e3e9407c.png', 'yoooo.comahttps://www.youtube.com/watch?v=B9KFb_fmvV8&list=RDcXDOHqa_QgY&index=4', 1, 'Aktif', '2025-11-06 15:17:55');

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

--
-- Table structure for table `kos`
--

CREATE TABLE `kos` (
  `id_kos` int(11) NOT NULL,
  `id_admin` int(11) NOT NULL,
  `nama_kos` varchar(150) NOT NULL,
  `alamat` text DEFAULT NULL,
  `jumlah_kamar` int(11) DEFAULT NULL,
  `deskripsi` text DEFAULT NULL,
  `status` enum('Aktif','Nonaktif') DEFAULT 'Aktif',
  `tanggal_dibuat` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `kos`
--

INSERT INTO `kos` (`id_kos`, `id_admin`, `nama_kos`, `alamat`, `jumlah_kamar`, `deskripsi`, `status`, `tanggal_dibuat`) VALUES
(1, 2, 'larisa', 'jaln capung', 20, 'okee boss', 'Aktif', '2025-11-05 19:58:47'),
(2, 2, 'kontol', 'okee', 23, 'edewfwe', 'Aktif', '2025-11-05 20:00:33'),
(4, 3, 'kos waris', 'odqwodoqwjkd', 12, 'sixjwicjdiw', 'Aktif', '2025-11-07 11:14:38');

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

--
-- Table structure for table `laporan`
--

CREATE TABLE `laporan` (
  `id_laporan` int(11) NOT NULL,
  `id_penghuni` int(11) NOT NULL,
  `id_kos` int(11) DEFAULT NULL,
  `judul` varchar(150) NOT NULL,
  `deskripsi` text NOT NULL,
  `gambar` varchar(255) DEFAULT NULL,
  `status` enum('Diajukan','Diproses','Selesai') DEFAULT 'Diajukan',
  `tanggal_laporan` timestamp NOT NULL DEFAULT current_timestamp(),
  `tanggal_selesai` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `laporan`
--

INSERT INTO `laporan` (`id_laporan`, `id_penghuni`, `id_kos`, `judul`, `deskripsi`, `gambar`, `status`, `tanggal_laporan`, `tanggal_selesai`) VALUES
(1, 1, 1, 'kd3or32o2rjj3', 'efjeifjeif', '13a5475573cd50dd95a50537d07310f5.png', 'Selesai', '2025-11-05 20:14:24', '2025-11-12 21:04:48'),
(2, 2, 2, 'hihh', 'gyjugjgjyhg', 'b49237b1479073043080df0613f31450.jpg', 'Diajukan', '2025-11-05 21:41:40', NULL);

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

--
-- Table structure for table `payment_log`
--

CREATE TABLE `payment_log` (
  `id_payment` int(11) NOT NULL,
  `id_admin` int(11) NOT NULL,
  `order_id` varchar(100) NOT NULL,
  `gross_amount` int(11) NOT NULL,
  `payment_type` varchar(50) DEFAULT NULL,
  `transaction_status` varchar(50) DEFAULT NULL,
  `transaction_time` datetime DEFAULT NULL,
  `raw_response` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `penghuni`
--

CREATE TABLE `penghuni` (
  `id_penghuni` int(11) NOT NULL,
  `id_kos` int(11) DEFAULT NULL,
  `nama_penghuni` varchar(100) NOT NULL,
  `email` varchar(150) NOT NULL,
  `password` varchar(255) NOT NULL,
  `no_hp` varchar(20) DEFAULT NULL,
  `kamar` varchar(50) DEFAULT NULL,
  `alamat` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `penghuni`
--

INSERT INTO `penghuni` (`id_penghuni`, `id_kos`, `nama_penghuni`, `email`, `password`, `no_hp`, `kamar`, `alamat`, `created_at`) VALUES
(1, 1, 'kiki', 'rizqywahyu59@gmail.com', '$2y$10$P23y1xe1NQBzVrS8zXCsQ.ET6bjZQu7pQRBjBeYSDncUL30D.0dli', '00000000000', '20', 'jdjkdjd', '2025-11-05 14:13:51'),
(2, 2, 'kiki', 'kiki@gmail.com', '$2y$10$HL/mHLA1g0GAOZuPWFoc0OrblH2nI6GdQ/6kxFC0Ky4U76Ev1y93C', '00000000000', '23', 'jogja okeee', '2025-11-05 15:28:01');

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

--
-- Table structure for table `super_admin`
--

CREATE TABLE `super_admin` (
  `id_super_admin` int(11) NOT NULL,
  `nama` varchar(100) NOT NULL,
  `email` varchar(150) NOT NULL,
  `password` varchar(255) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `super_admin`
--

INSERT INTO `super_admin` (`id_super_admin`, `nama`, `email`, `password`, `created_at`) VALUES
(1, 'superr boss', 'superadmin@superadmin.com', '$2y$10$uV5Woi7aLDpjBGHC8OQHVuJH.Glg.e.u6E.4JxenxnOvVVGDvZkmq', '2025-10-31 16:31:17');

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

--
-- Table structure for table `typing_indicators`
--

CREATE TABLE `typing_indicators` (
  `id` int(11) NOT NULL,
  `id_penghuni` int(11) DEFAULT NULL,
  `id_admin` int(11) DEFAULT NULL,
  `is_typing` tinyint(1) DEFAULT 0,
  `last_activity` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Indexes for dumped tables
--

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

--
-- Indexes for table `admin_subscription`
--
ALTER TABLE `admin_subscription`
  ADD PRIMARY KEY (`id_subscription`),
  ADD KEY `id_admin` (`id_admin`);

--
-- Indexes for table `chat_connections`
--
ALTER TABLE `chat_connections`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `connection_id` (`connection_id`),
  ADD KEY `idx_user` (`user_type`,`user_id`);

--
-- Indexes for table `chat_message`
--
ALTER TABLE `chat_message`
  ADD PRIMARY KEY (`id_chat`),
  ADD KEY `id_penghuni` (`id_penghuni`),
  ADD KEY `id_admin` (`id_admin`);

--
-- Indexes for table `chat_sessions`
--
ALTER TABLE `chat_sessions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_chat_pair` (`id_penghuni`,`id_admin`),
  ADD KEY `idx_admin` (`id_admin`);

--
-- Indexes for table `detail_laporan`
--
ALTER TABLE `detail_laporan`
  ADD PRIMARY KEY (`id_detail_laporan`),
  ADD KEY `fk_detail_laporan_laporan` (`id_laporan`),
  ADD KEY `fk_detail_laporan_penghuni` (`id_penghuni`);

--
-- Indexes for table `iklan`
--
ALTER TABLE `iklan`
  ADD PRIMARY KEY (`id_iklan`),
  ADD KEY `fk_iklan_admin` (`id_admin`),
  ADD KEY `fk_iklan_kos` (`id_kos`);

--
-- Indexes for table `kos`
--
ALTER TABLE `kos`
  ADD PRIMARY KEY (`id_kos`),
  ADD KEY `fk_kos_admin` (`id_admin`);

--
-- Indexes for table `laporan`
--
ALTER TABLE `laporan`
  ADD PRIMARY KEY (`id_laporan`),
  ADD KEY `fk_laporan_penghuni` (`id_penghuni`),
  ADD KEY `fk_laporan_kos` (`id_kos`);

--
-- Indexes for table `payment_log`
--
ALTER TABLE `payment_log`
  ADD PRIMARY KEY (`id_payment`),
  ADD KEY `id_admin` (`id_admin`);

--
-- Indexes for table `penghuni`
--
ALTER TABLE `penghuni`
  ADD PRIMARY KEY (`id_penghuni`),
  ADD UNIQUE KEY `email` (`email`),
  ADD KEY `fk_penghuni_kos` (`id_kos`);

--
-- Indexes for table `super_admin`
--
ALTER TABLE `super_admin`
  ADD PRIMARY KEY (`id_super_admin`),
  ADD UNIQUE KEY `email` (`email`);

--
-- Indexes for table `typing_indicators`
--
ALTER TABLE `typing_indicators`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_penghuni` (`id_penghuni`),
  ADD KEY `idx_admin` (`id_admin`);

--
-- AUTO_INCREMENT for dumped tables
--

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

--
-- AUTO_INCREMENT for table `admin_subscription`
--
ALTER TABLE `admin_subscription`
  MODIFY `id_subscription` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

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

--
-- AUTO_INCREMENT for table `chat_message`
--
ALTER TABLE `chat_message`
  MODIFY `id_chat` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=76;

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

--
-- AUTO_INCREMENT for table `detail_laporan`
--
ALTER TABLE `detail_laporan`
  MODIFY `id_detail_laporan` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `iklan`
--
ALTER TABLE `iklan`
  MODIFY `id_iklan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;

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

--
-- AUTO_INCREMENT for table `laporan`
--
ALTER TABLE `laporan`
  MODIFY `id_laporan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `payment_log`
--
ALTER TABLE `payment_log`
  MODIFY `id_payment` int(11) NOT NULL AUTO_INCREMENT;

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

--
-- AUTO_INCREMENT for table `super_admin`
--
ALTER TABLE `super_admin`
  MODIFY `id_super_admin` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `admin_subscription`
--
ALTER TABLE `admin_subscription`
  ADD CONSTRAINT `admin_subscription_ibfk_1` FOREIGN KEY (`id_admin`) REFERENCES `admin` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `chat_message`
--
ALTER TABLE `chat_message`
  ADD CONSTRAINT `chat_message_ibfk_1` FOREIGN KEY (`id_penghuni`) REFERENCES `penghuni` (`id_penghuni`) ON DELETE CASCADE,
  ADD CONSTRAINT `chat_message_ibfk_2` FOREIGN KEY (`id_admin`) REFERENCES `admin` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `detail_laporan`
--
ALTER TABLE `detail_laporan`
  ADD CONSTRAINT `fk_detail_laporan_laporan` FOREIGN KEY (`id_laporan`) REFERENCES `laporan` (`id_laporan`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_detail_laporan_penghuni` FOREIGN KEY (`id_penghuni`) REFERENCES `penghuni` (`id_penghuni`) ON DELETE SET NULL ON UPDATE CASCADE;

--
-- Constraints for table `iklan`
--
ALTER TABLE `iklan`
  ADD CONSTRAINT `fk_iklan_admin` FOREIGN KEY (`id_admin`) REFERENCES `admin` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_iklan_kos` FOREIGN KEY (`id_kos`) REFERENCES `kos` (`id_kos`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `kos`
--
ALTER TABLE `kos`
  ADD CONSTRAINT `fk_kos_admin` FOREIGN KEY (`id_admin`) REFERENCES `admin` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `laporan`
--
ALTER TABLE `laporan`
  ADD CONSTRAINT `fk_laporan_kos` FOREIGN KEY (`id_kos`) REFERENCES `kos` (`id_kos`) ON DELETE SET NULL ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_laporan_penghuni` FOREIGN KEY (`id_penghuni`) REFERENCES `penghuni` (`id_penghuni`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `payment_log`
--
ALTER TABLE `payment_log`
  ADD CONSTRAINT `payment_log_ibfk_1` FOREIGN KEY (`id_admin`) REFERENCES `admin` (`id`);

--
-- Constraints for table `penghuni`
--
ALTER TABLE `penghuni`
  ADD CONSTRAINT `fk_penghuni_kos` FOREIGN KEY (`id_kos`) REFERENCES `kos` (`id_kos`) ON DELETE SET NULL ON UPDATE 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 */;




ini kode 
Server Key :Mid-server-Phr8mLWEe_OJIMKTsd4MLEFn
Client Key :Mid-client-6BXZRIf8OVmxbcaJ