Programming & Development / April 11, 2025

How to Represent Bahrain’s Governorates in Java and SQL Using ISO 3166-2 Codes

Bahrain governorates Java enum Bahrain ISO 3166-2 BH SQL Bahrain regions Bahrain administrative divisions Spring Boot enum Bahrain regions list BH region codes governorates of Bahrain

🇧🇭 Java Enum: Bahrain’s Governorates

Bahrain is divided into 4 governorates. Here’s the Java enum using the ISO 3166-2:BH codes.

java

public enum BahrainGovernorate {
    CAPITAL("BH-01"),
    NORTHERN("BH-02"),
    SOUTHERN("BH-03"),
    MUHARRAQ("BH-04");

    private final String code;

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

    public String getCode() {
        return code;
    }
}

🗃️ SQL Table and Insert Statements

sql

CREATE TABLE bahrain_governorates (
    id SERIAL PRIMARY KEY,
    name VARCHAR(64) NOT NULL,
    code VARCHAR(8) NOT NULL UNIQUE
);

INSERT INTO bahrain_governorates (name, code) VALUES
('Capital', 'BH-01'),
('Northern', 'BH-02'),
('Southern', 'BH-03'),
('Muharraq', 'BH-04');

✅ Summary

This setup represents Bahrain’s 4 governorates using the ISO 3166-2:BH codes. It is perfect for managing administrative divisions, geographical data, or region-based functionalities in applications.


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