-- =====================================================
-- WebGIS SPBU Pontianak — Database Schema
-- Jalankan di phpMyAdmin atau MySQL CLI
-- =====================================================

CREATE DATABASE IF NOT EXISTS webgis_spbu
  CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

USE webgis_spbu;

CREATE TABLE IF NOT EXISTS spbu (
  id        INT AUTO_INCREMENT PRIMARY KEY,
  nama      VARCHAR(150)   NOT NULL COMMENT 'Nama SPBU',
  no        VARCHAR(50)    NOT NULL COMMENT 'Nomor SPBU (mis: 64.751.01)',
  status    TINYINT(1)     NOT NULL DEFAULT 0 COMMENT '1=Buka 24 Jam, 0=Terbatas',
  latitude  DECIMAL(10,8)  NOT NULL COMMENT 'Koordinat Latitude',
  longitude DECIMAL(11,8)  NOT NULL COMMENT 'Koordinat Longitude',
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  INDEX idx_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ── Contoh Data SPBU Pontianak ──────────────────────
INSERT INTO spbu (nama, no, status, latitude, longitude) VALUES
('SPBU Jl. Ahmad Yani',       '64.751.01', 1, -0.020500, 109.341200),
('SPBU Jl. Gajahmada',        '64.751.02', 0, -0.031800, 109.325600),
('SPBU Jl. Tanjungpura',      '64.751.03', 1, -0.025300, 109.332400),
('SPBU Jl. Sutan Syahrir',    '64.751.04', 0, -0.018200, 109.348700),
('SPBU Jl. Adisucipto',       '64.751.05', 1, -0.040100, 109.358900);