Programming & Development / April 12, 2025

Enum Representation of Districts in Sierra Leone and SQL Table for Storing District Data

Enum District Sierra Leone Java SQL Western Area Eastern Province Northern Province Southern Province District Code

Enum Representation in Java

Sierra Leone is divided into 16 districts. Below is an enum representation of these districts with their respective codes:

java

public enum District {
    WESTERN_AREA("WA"),
    EASTERN_PROVINCE("EP"),
    NORTHERN_PROVINCE("NP"),
    SOUTHERN_PROVINCE("SP"),
    BONTHE("BO"),
    KAILAHUN("KA"),
    KAMBIA("KM"),
    KENEMA("KE"),
    KOINADUGU("KD"),
    PORT_LOKO("PL"),
    TONKOLILI("TO"),
    BO("BO"),
    BOMBALI("BM"),
    FREEN_TOWN("FT"),
    MAGBURAKA("MG"),
    KONO("KO");

    private final String code;

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

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

In the code:

  • The enum District defines the 16 districts of Sierra Leone along with their respective codes.
  • Each district is associated with a two-character abbreviation.
  • The getCode() method allows you to retrieve the district code.

SQL Representation for Storing District Data

To store the districts of Sierra Leone in a database, you can create a table and insert the data using the following SQL:

sql

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

-- Inserting data for districts of Sierra Leone
INSERT INTO districts (name, code) VALUES
('Western Area', 'WA'),
('Eastern Province', 'EP'),
('Northern Province', 'NP'),
('Southern Province', 'SP'),
('Bonthe', 'BO'),
('Kailahun', 'KA'),
('Kambia', 'KM'),
('Kenema', 'KE'),
('Koinadugu', 'KD'),
('Port Loko', 'PL'),
('Tonkilili', 'TO'),
('Bo', 'BO'),
('Bombali', 'BM'),
('Freetown', 'FT'),
('Magburaka', 'MG'),
('Kono', 'KO');

In the SQL:

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

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