Programming & Development / April 12, 2025

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

Enum Province South Africa Java SQL Gauteng KwaZulu-Natal Western Cape Eastern Cape Limpopo Province Code

Enum Representation in Java

South Africa is divided into 9 provinces. Below is an enum representation of these provinces with standard two-letter codes:

java

public enum Province {
    EASTERN_CAPE("EC"),
    FREE_STATE("FS"),
    GAUTENG("GP"),
    KWAZULU_NATAL("KZN"),
    LIMPOPO("LP"),
    MPUMALANGA("MP"),
    NORTHERN_CAPE("NC"),
    NORTH_WEST("NW"),
    WESTERN_CAPE("WC");

    private final String code;

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

    public String getCode() {
        return this.code;
    }
}
  • Each province is assigned a standard two-character code, commonly used in government systems and forms.
  • The getCode() method provides the abbreviation for integration in systems or UI displays.

SQL Representation for Storing Province Data

Here's the SQL table and insert script for the provinces of South Africa:

sql

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

-- Inserting data for South African provinces
INSERT INTO provinces (name, code) VALUES
('Eastern Cape', 'EC'),
('Free State', 'FS'),
('Gauteng', 'GP'),
('KwaZulu-Natal', 'KZN'),
('Limpopo', 'LP'),
('Mpumalanga', 'MP'),
('Northern Cape', 'NC'),
('North West', 'NW'),
('Western Cape', 'WC');
  • The provinces table holds each province’s name and abbreviation.
  • The two- or three-letter codes are based on common abbreviations used in official and postal contexts.

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