CREATE DATABASE IF NOT EXISTS webgis_spbu;
USE webgis_spbu;

CREATE TABLE IF NOT EXISTS jalan (
    id INT AUTO_INCREMENT PRIMARY KEY,
    nama_jalan VARCHAR(150) NOT NULL,
    status ENUM('nasional', 'provinsi', 'kabupaten') NOT NULL,
    panjang_meter DOUBLE NOT NULL,
    geom LINESTRING NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    SPATIAL INDEX idx_jalan_geom (geom)
) ENGINE=InnoDB;

CREATE TABLE IF NOT EXISTS parsil_tanah (
    id INT AUTO_INCREMENT PRIMARY KEY,
    nama_pemilik VARCHAR(150) NOT NULL,
    status_kepemilikan ENUM('SHM', 'HGB', 'HGU', 'HP') NOT NULL,
    luas_m2 DOUBLE NOT NULL,
    geom POLYGON NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    SPATIAL INDEX idx_parsil_geom (geom)
) ENGINE=InnoDB;
