Programming & Development / April 11, 2025

Modeling Morocco's Administrative Regions in Java and SQL Using ISO 3166-2:MA Codes

Morocco regions Java enum Morocco ISO 3166-2 MA SQL Morocco Morocco provinces Moroccan regions Spring Boot geography Morocco administrative units Morocco backend regions regions of Morocco

🇲🇦 Java Enum: Morocco's Administrative Regions

Morocco is divided into 12 regions, each with its official ISO 3166-2:MA code.

java

public enum MoroccoRegion {
    CASABLANCA_SETTA("MA-01"),
    FES_MEKNES("MA-02"),
    TANGER_TETOUAN_AL_HOCEIMA("MA-03"),
    RABAT_SALE_KENITRA("MA-04"),
    MARRAKECH_SAFI("MA-05"),
    DRAA_TAFILALET("MA-06"),
    BOUJDOUR_SAKIA_EL_HAMRA("MA-07"),
    LAAYOUNE_SAKIA_EL_HAMRA("MA-08"),
    GUELMIM_ESSAOUIRA("MA-09"),
    DOUKKALA_ABDA("MA-10"),
    TAZA_AL_HOCEIMA_TAOUNATE("MA-11"),
    SOUSS_MASSA("MA-12");

    private final String code;

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

    public String getCode() {
        return code;
    }
}

🗃️ SQL Table and Insert Statements

sql

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

INSERT INTO morocco_regions (name, code) VALUES
('Casablanca-Setta', 'MA-01'),
('Fès-Meknès', 'MA-02'),
('Tangier-Tetouan-Al Hoceima', 'MA-03'),
('Rabat-Salé-Kénitra', 'MA-04'),
('Marrakech-Safi', 'MA-05'),
('Draa-Tafilalet', 'MA-06'),
('Boujdour-Sakia El Hamra', 'MA-07'),
('Laayoune-Sakia El Hamra', 'MA-08'),
('Guelmim-Es Souira', 'MA-09'),
('Doukkala-Abda', 'MA-10'),
('Taza-Al Hoceima-Taounate', 'MA-11'),
('Souss-Massa', 'MA-12');

✅ Summary

This setup models Morocco's administrative regions with their ISO 3166-2:MA codes. It is designed for geographic applications and backend systems that need to handle Morocco's regional data efficiently.



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