Enum Representation in Java
The Solomon Islands is divided into 9 provinces and 1 capital territory (Honiara). Here's the enum representation with province codes:
java
public enum Province {
CENTRAL("CE"),
CHOISEUL("CH"),
GUADALCANAL("GU"),
ISABEL("IS"),
MAKIRA_ULAWA("MU"),
MALAITA("ML"),
RENNELL_BELLONA("RB"),
TEMOTU("TE"),
WESTERN("WE"),
HONIARA("HO"); // Capital Territory
private final String code;
Province(String code) {
this.code = code;
}
public String getCode() {
return this.code;
}
}
- The enum
Province
includes all 9 provinces and Honiara as a separate entity.
- Each province is assigned a unique two-letter code.
getCode()
method retrieves the code for use in systems or databases.
SQL Representation for Storing Province Data
Here is the SQL schema and insert statements for storing the Solomon Islands' provinces in a relational database:
sql
-- Table definition for provinces in Solomon Islands
CREATE TABLE provinces (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
code CHAR(2) NOT NULL
);
-- Insert statements for Solomon Islands provinces
INSERT INTO provinces (name, code) VALUES
('Central', 'CE'),
('Choiseul', 'CH'),
('Guadalcanal', 'GU'),
('Isabel', 'IS'),
('Makira-Ulawa', 'MU'),
('Malaita', 'ML'),
('Rennell and Bellona', 'RB'),
('Temotu', 'TE'),
('Western', 'WE'),
('Honiara', 'HO');
- The
provinces
table holds the province name and code.
- Insert values match official administrative regions.