Programming & Development / April 12, 2025

Enum Representation of Municipalities in Qatar and SQL Table for Storing Municipality Data

Enum Municipality Qatar Java SQL Al Daayen Al Khor Al Shahaniya Al Wakrah Doha Umm Salal Municipality Code

Enum Representation in Java

Qatar is divided into 8 municipalities. Below is an enum representation of those municipalities with their respective codes:

java

public enum Municipality {
    AL_DAAYEN("DA"),
    AL_KHOR("KH"),
    AL_SHAHANIYA("SH"),
    AL_WAKRAH("WA"),
    DOHA("DO"),
    UMM_SALAL("US");

    private final String code;

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

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

In the code:

  • The enum Municipality defines the municipalities of Qatar and their respective codes.
  • Each municipality is associated with a two-character abbreviation.
  • The getCode() method allows you to retrieve the municipality code.

SQL Representation for Storing Municipality Data

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

sql

-- Table definition for storing municipalities of Qatar
CREATE TABLE municipalities (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    code CHAR(2) NOT NULL
);

-- Inserting data for municipalities of Qatar
INSERT INTO municipalities (name, code) VALUES
('Al Daayen', 'DA'),
('Al Khor', 'KH'),
('Al Shahaniya', 'SH'),
('Al Wakrah', 'WA'),
('Doha', 'DO'),
('Umm Salal', 'US');

In the SQL:

  • We create a municipalities table with columns id (auto-incremented), name (the name of the municipality), and code (the abbreviation for the municipality).
  • The INSERT INTO statement adds the municipalities of Qatar along with their respective codes into the table.

This setup ensures that you can efficiently store and query the municipalities of Qatar, both in your Java application (via enums) and in a relational 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