Programming & Development / April 12, 2025

Enum Representation of Parishes in Saint Vincent and the Grenadines and SQL Table for Storing Parish Data

Enum Parish Saint Vincent and the Grenadines Java SQL Charlotte Grenadines Kingstown Saint Andrew Saint David Saint George Parish Code

Enum Representation in Java

Saint Vincent and the Grenadines is divided into 6 parishes. Below is an enum representation of these parishes with their respective codes:

java

public enum Parish {
    CHARLOTTE("CH"),
    GRENAINES("GR"),
    KINGSTOWN("KI"),
    SAINT_ANDREW("SA"),
    SAINT_DAVID("SD"),
    SAINT_GEORGE("SG");

    private final String code;

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

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

In the code:

  • The enum Parish defines the 6 parishes of Saint Vincent and the Grenadines along with their respective codes.
  • Each parish is associated with a two-character abbreviation.
  • The getCode() method allows you to retrieve the parish code.

SQL Representation for Storing Parish Data

To store the parishes of Saint Vincent and the Grenadines in a database, you can create a table and insert the data using the following SQL:

sql

-- Table definition for storing parishes of Saint Vincent and the Grenadines
CREATE TABLE parishes (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    code CHAR(2) NOT NULL
);

-- Inserting data for parishes of Saint Vincent and the Grenadines
INSERT INTO parishes (name, code) VALUES
('Charlotte', 'CH'),
('Grenadines', 'GR'),
('Kingstown', 'KI'),
('Saint Andrew', 'SA'),
('Saint David', 'SD'),
('Saint George', 'SG');

In the SQL:

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

This setup ensures that you can efficiently store and query the parishes of Saint Vincent and the Grenadines, 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