Programming & Development / April 12, 2025

Enum Representation of Provinces in Rwanda and SQL Table for Storing Province Data

Enum Province Rwanda Java SQL Eastern Kigali Northern Western Southern Province Code

Enum Representation in Java

Rwanda is divided into 4 provinces and the capital city Kigali. Below is an enum representation of these provinces with their respective codes:

java

public enum Province {
    EASTERN("EA"),
    KIGALI("KI"),
    NORTHERN("NO"),
    WESTERN("WE"),
    SOUTHERN("SO");

    private final String code;

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

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

In the code:

  • The enum Province defines the 4 provinces of Rwanda along with their respective codes.
  • Each province is associated with a two-character abbreviation.
  • The getCode() method allows you to retrieve the province code.

SQL Representation for Storing Province Data

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

sql

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

-- Inserting data for provinces of Rwanda
INSERT INTO provinces (name, code) VALUES
('Eastern', 'EA'),
('Kigali', 'KI'),
('Northern', 'NO'),
('Western', 'WE'),
('Southern', 'SO');

In the SQL:

  • We define a provinces table with columns id (auto-incremented), name (the name of the province), and code (the abbreviation for the province).
  • The INSERT INTO statement adds the provinces of Rwanda along with their respective codes into the table.

This setup ensures that you can efficiently store and query the provinces of Rwanda, 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