-- ================================================================
-- Analisis Radius Bantuan — DDL
-- Jalankan di database: webgis
-- ================================================================

CREATE TABLE IF NOT EXISTS `tabel_ibadah` (
    `id`          INT(11)        NOT NULL AUTO_INCREMENT,
    `nama_ibadah` VARCHAR(150)   NOT NULL,
    `latitude`    DOUBLE         NOT NULL,
    `longitude`   DOUBLE         NOT NULL,
    `radius`      INT(11)        NOT NULL DEFAULT 500 COMMENT 'Radius dalam meter',
    `created_at`  TIMESTAMP      NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `tabel_penduduk` (
    `id`            INT(11)       NOT NULL AUTO_INCREMENT,
    `nama_penduduk` VARCHAR(150)  NOT NULL,
    `latitude`      DOUBLE        NOT NULL,
    `longitude`     DOUBLE        NOT NULL,
    `status_warna`  ENUM('Merah','Hijau') NOT NULL DEFAULT 'Merah',
    `created_at`    TIMESTAMP     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Data contoh (opsional, hapus jika tidak diperlukan)
INSERT INTO `tabel_ibadah` (`nama_ibadah`, `latitude`, `longitude`, `radius`) VALUES
('Masjid Al-Hikmah',   -0.0200, 109.3400, 800),
('Gereja Bethel',      -0.0300, 109.3500, 600);

INSERT INTO `tabel_penduduk` (`nama_penduduk`, `latitude`, `longitude`, `status_warna`) VALUES
('Budi Santoso',  -0.0210, 109.3410, 'Merah'),
('Ani Rahayu',    -0.0350, 109.3600, 'Merah');
