Programming & Development / April 12, 2025

Enum Representation of Provinces in the Philippines and SQL Table for Storing Province Data

Enum Province Philippines Java SQL Abra Agusan del Norte Agusan del Sur Aklan Albay Antipolo Apayao Aurora Basilan Bataan Batanes Batangas Benguet Bohol Bukidnon Bulacan Cagayan Camarines Norte Camarines Sur Camiguin Capiz Catanduanes Cavite Cebu Davao de Oro Davao del Norte Davao del Sur Davao Oriental Region Code

Enum Representation in Java

The Philippines consists of 81 provinces, divided into regions. Here's an enum representation for a few provinces in the Philippines with their respective codes:

java

public enum Province {
    ABRA("AB"),
    AGUSAN_DEL_NORTE("ADN"),
    AGUSAN_DEL_SUR("ADS"),
    AKLAN("AK"),
    ALBAY("AL"),
    ANTIPOLO("AN"),
    APAYAO("AP"),
    AURORA("AU"),
    BASILAN("BS"),
    BATAAN("BT"),
    BATANES("BN"),
    BATANGAS("BG"),
    BENGUET("BE"),
    BOHOL("BO"),
    BUKIDNON("BU"),
    BULACAN("BL"),
    CAGAYAN("CG"),
    CAMARINES_NORTE("CN"),
    CAMARINES_SUR("CS"),
    CAMIGUIN("CM"),
    CAPIZ("CP"),
    CATANDUANES("CT"),
    CAVITE("CV"),
    CEBU("CE"),
    DAVAO_DE_ORO("DO"),
    DAVAO_DEL_NORTE("DN"),
    DAVAO_DEL_SUR("DS"),
    DAVAO_ORIENTAL("DO");

    private final String code;

    Province(String code) {
        this.code = code;
    }

    public String getCode() {
        return this.code;
    }
}

In the code:

  • The enum Province defines several provinces in the Philippines along with their respective codes.
  • Each province has a corresponding two or three-character abbreviation.
  • The getCode() method allows access to the province code.

SQL Representation for Storing Province Data

To store the provinces of the Philippines in a database, you can create a table and insert the data using the following SQL:

sql

-- Table definition for storing provinces of the Philippines
CREATE TABLE provinces (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    code CHAR(3) NOT NULL
);

-- Inserting data for provinces of the Philippines
INSERT INTO provinces (name, code) VALUES
('Abra', 'AB'),
('Agusan del Norte', 'ADN'),
('Agusan del Sur', 'ADS'),
('Aklan', 'AK'),
('Albay', 'AL'),
('Antipolo', 'AN'),
('Apayao', 'AP'),
('Aurora', 'AU'),
('Basilan', 'BS'),
('Bataan', 'BT'),
('Batanes', 'BN'),
('Batangas', 'BG'),
('Benguet', 'BE'),
('Bohol', 'BO'),
('Bukidnon', 'BU'),
('Bulacan', 'BL'),
('Cagayan', 'CG'),
('Camarines Norte', 'CN'),
('Camarines Sur', 'CS'),
('Camiguin', 'CM'),
('Capiz', 'CP'),
('Catanduanes', 'CT'),
('Cavite', 'CV'),
('Cebu', 'CE'),
('Davao de Oro', 'DO'),
('Davao del Norte', 'DN'),
('Davao del Sur', 'DS'),
('Davao Oriental', 'DO');

In the SQL:

  • We define a provinces table with id (auto-incremented), name (the province name), and code (the abbreviation for the province).
  • The INSERT INTO statement adds several provinces of the Philippines along with their respective codes into the table.

This structure ensures that you can store and query the provinces of the Philippines efficiently, both in your Java application (using enums) and in a database system.


Comments

No comments yet

Add a new Comment

NUHMAN.COM

Information Technology website for Programming & Development, Web Design & UX/UI, Startups & Innovation, Gadgets & Consumer Tech, Cloud Computing & Enterprise Tech, Cybersecurity, Artificial Intelligence (AI) & Machine Learning (ML), Gaming Technology, Mobile Development, Tech News & Trends, Open Source & Linux, Data Science & Analytics

Categories

Tags

©{" "} Nuhmans.com . All Rights Reserved. Designed by{" "} HTML Codex