Programming & Development / April 11, 2025

How to Represent Pakistan's Provinces and Territories in Java and SQL with ISO Codes

Pakistan provinces Pakistani territories Java enum ISO 3166-2 PK Spring Boot enum SQL table Pakistan address validation ISO codes Pakistan address validation Pakistan federal areas

🇵🇰 Java Enum: Pakistan's Provinces and Territories with ISO Codes

The following Java enum represents all 4 provinces, 2 autonomous territories, and the federal territory of Pakistan, using ISO 3166-2:PK codes.

java

public enum PakistanProvince {
    AZAD_KASHMIR("JK"), // Azad Jammu and Kashmir
    BALOCHISTAN("BS"),
    FEDERAL_CAPITAL_TERRITORY("IS"), // Islamabad Capital Territory
    KHYBER_PAKHTUNKHWA("KP"),
    PUNJAB("PB"),
    SINDH("SD"),
    GILGIT_BALTISTAN("GB"), // Gilgit-Baltistan
    FEDERAL_URDU_SPEAKING_AREAS("FU"); // Urdu Speaking areas

    private final String code;

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

    public String getCode() {
        return code;
    }
}

🗃️ SQL Version: Pakistan's Provinces and Territories Table

Here’s the SQL schema and insert statements for creating a table that represents the provinces, territories, and federal areas of Pakistan.

sql

CREATE TABLE pakistan_provinces (
    id SERIAL PRIMARY KEY,
    name VARCHAR(64) NOT NULL,
    code CHAR(2) NOT NULL UNIQUE
);

Insert Statements:

sql

INSERT INTO pakistan_provinces (name, code) VALUES
('Azad Jammu and Kashmir', 'JK'),
('Balochistan', 'BS'),
('Islamabad Capital Territory', 'IS'),
('Khyber Pakhtunkhwa', 'KP'),
('Punjab', 'PB'),
('Sindh', 'SD'),
('Gilgit-Baltistan', 'GB'),
('Federal Urdu Speaking Areas', 'FU');

✅ Summary

Representing Pakistan’s administrative regions as Java enums and storing them in a relational database ensures clean and organized handling of address or region data in Pakistani applications. Using ISO 3166-2:PK standards allows seamless integration across various systems.


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