Enum Representation in Java
Seychelles is divided into 25 districts. Below is an enum representation of these districts with their respective codes:
java
public enum District {
ANSE_BOILEAU("AB"),
ANSE_EJOUE("AE"),
ANSE_LAZIO("AL"),
ANSE_LEON("AL"),
ANSE_ROYALE("AR"),
BEL_AIR("BA"),
BOILEAU("BO"),
COVE("CO"),
GRAND_ANCE("GA"),
LA_DIGUE("LD"),
LARUE("LR"),
LES_MAREES("LM"),
MAHE("MA"),
MONT_ROSE("MR"),
PORT_VICTORIA("PV"),
PRASLIN("PR"),
ROSE_HILL("RH"),
ST_LUCIA("SL"),
ST_PIERRE("SP"),
TRIBORD("TR"),
VALLEE_DE_MAI("VM"),
VICTORIA("VI"),
SEXTANT("SE"),
BELVEDERE("BV");
private final String code;
District(String code) {
this.code = code;
}
public String getCode() {
return this.code;
}
}
In the code:
- The enum
District
defines the 25 districts of Seychelles 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 Seychelles in a database, you can create a table and insert the data using the following SQL:
sql
-- Table definition for storing districts of Seychelles
CREATE TABLE districts (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
code CHAR(2) NOT NULL
);
-- Inserting data for districts of Seychelles
INSERT INTO districts (name, code) VALUES
('Anse Boileau', 'AB'),
('Anse Ejoué', 'AE'),
('Anse Lazio', 'AL'),
('Anse Leon', 'AL'),
('Anse Royale', 'AR'),
('Bel Air', 'BA'),
('Boileau', 'BO'),
('Cove', 'CO'),
('Grand Anse', 'GA'),
('La Digue', 'LD'),
('Larue', 'LR'),
('Les Marees', 'LM'),
('Mahe', 'MA'),
('Mont Rose', 'MR'),
('Port Victoria', 'PV'),
('Praslin', 'PR'),
('Rose Hill', 'RH'),
('St Lucia', 'SL'),
('St Pierre', 'SP'),
('Tribord', 'TR'),
('Vallee de Mai', 'VM'),
('Victoria', 'VI'),
('Sextant', 'SE'),
('Belvedere', 'BV');
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 Seychelles along with their respective codes into the table.
This setup ensures that you can efficiently store and query the districts of Seychelles, both in your Java application (via enums) and in a relational database system.