Enum Representation in Java
Poland is divided into 16 voivodeships (provinces). Below is an enum representation of those voivodeships with their respective codes:
java
public enum Voivodeship {
LOWER_SILESIAN("DS"),
KUYAVIAN_POMERANIAN("KP"),
LUBLIN("LU"),
LUBUSZ("LB"),
LÓDZ("LD"),
LESSER_POLAND("MA"),
MASOVIAN("MZ"),
OPOLE("OP"),
PODKARPACKIE("PK"),
PODLASKIE("PL"),
POMERANIAN("PM"),
SILESIAN("SL"),
WARMIAN_MASURIAN("WN"),
GREATER_POLAND("WP"),
WEST_POMERANIAN("ZP");
private final String code;
Voivodeship(String code) {
this.code = code;
}
public String getCode() {
return this.code;
}
}
In the code:
- The enum
Voivodeship
defines the voivodeships of Poland and their respective codes.
- Each voivodeship is associated with a two-character code.
- The
getCode()
method allows you to retrieve the voivodeship code.
SQL Representation for Storing Voivodeship Data
To store the voivodeships of Poland in a database, you can create a table and insert the data using the following SQL:
sql
-- Table definition for storing voivodeships of Poland
CREATE TABLE voivodeships (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
code CHAR(2) NOT NULL
);
-- Inserting data for voivodeships of Poland
INSERT INTO voivodeships (name, code) VALUES
('Lower Silesian', 'DS'),
('Kuyavian-Pomeranian', 'KP'),
('Lublin', 'LU'),
('Lubusz', 'LB'),
('Lódz', 'LD'),
('Lesser Poland', 'MA'),
('Masovian', 'MZ'),
('Opole', 'OP'),
('Podkarpackie', 'PK'),
('Podlaskie', 'PL'),
('Pomeranian', 'PM'),
('Silesian', 'SL'),
('Warmian-Masurian', 'WN'),
('Greater Poland', 'WP'),
('West Pomeranian', 'ZP');
In the SQL:
- We define a
voivodeships
table with columns id
(auto-incremented), name
(the name of the voivodeship), and code
(the abbreviation for the voivodeship).
- The
INSERT INTO
statement adds the voivodeships of Poland along with their respective codes into the table.
This structure ensures that you can efficiently store and query the voivodeships of Poland both in your application (using Java enums) and in a relational database system.