Enum Representation in Java
Saint Kitts and Nevis is divided into 14 parishes. Below is an enum representation of these parishes with their respective codes:
java
public enum Parish {
SAINT_ANNE("SA"),
SAINT_GEORGE("SG"),
SAINT_JAMES("SJ"),
SAINT_JOHN("SJ"),
SAINT_MARY("SM"),
SAINT_PAUL("SP"),
CHARLESTOWN("CH"),
SAINT_KITTS("SK"),
SAINT_CATHERINE("SC"),
NEVIS("NE"),
BASSETERRE("BS"),
SAINT_EUSTATIUS("SE"),
SAINT_PETER("SP"),
SAINT_LEONARD("SL");
private final String code;
Parish(String code) {
this.code = code;
}
public String getCode() {
return this.code;
}
}
In the code:
- The enum
Parish
defines the 14 parishes of Saint Kitts and Nevis 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 Kitts and Nevis in a database, you can create a table and insert the data using the following SQL:
sql
-- Table definition for storing parishes of Saint Kitts and Nevis
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 Kitts and Nevis
INSERT INTO parishes (name, code) VALUES
('Saint Anne', 'SA'),
('Saint George', 'SG'),
('Saint James', 'SJ'),
('Saint John', 'SJ'),
('Saint Mary', 'SM'),
('Saint Paul', 'SP'),
('Charlestown', 'CH'),
('Saint Kitts', 'SK'),
('Saint Catherine', 'SC'),
('Nevis', 'NE'),
('Basseterre', 'BS'),
('Saint Eustatius', 'SE'),
('Saint Peter', 'SP'),
('Saint Leonard', 'SL');
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 Kitts and Nevis along with their respective codes into the table.
This setup ensures that you can efficiently store and query the parishes of Saint Kitts and Nevis, both in your Java application (via enums) and in a relational database system.