Programming & Development / April 11, 2025

How to Represent the Emirates of the UAE in Java and SQL with Official Codes

UAE Emirates Java enum ISO 3166-2 AE SQL table Spring Boot enum UAE address validation Emirates code UAE regions address validation UAE Emirates list ISO codes UAE

πŸ‡¦πŸ‡ͺ Java Enum: Emirates of the UAE with ISO Codes

This Java enum represents all 7 Emirates of the UAE using their official ISO 3166-2:AE codes.

java

public enum UAEEmirate {
    ABU_DHABI("AZ"),
    AJMAN("AJ"),
    DUBAI("DU"),
    FUJAIRAH("FU"),
    RAS_AL_KHAIMAH("RK"),
    SHARJAH("SH"),
    UMM_AL_QUWAIN("UQ");

    private final String code;

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

    public String getCode() {
        return code;
    }
}

Usage Example:

java

UAEEmirate emirate = UAEEmirate.DUBAI;
System.out.println(emirate.getCode()); // Outputs: DU

πŸ—ƒοΈ SQL Version: UAE Emirates Table

Here’s the SQL schema and insert statements for creating a table that represents the 7 Emirates of the UAE.

sql

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

Insert Statements:

sql

INSERT INTO uae_emirates (name, code) VALUES
('Abu Dhabi', 'AZ'),
('Ajman', 'AJ'),
('Dubai', 'DU'),
('Fujairah', 'FU'),
('Ras Al Khaimah', 'RK'),
('Sharjah', 'SH'),
('Umm Al Quwain', 'UQ');

βœ… Summary

This representation of the UAE's Emirates as a Java enum and in a relational SQL table provides a structured approach to handling address and regional data. The ISO 3166-2:AE codes ensure compliance with international standards and enable integration across 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