Programming & Development / April 12, 2025

Enum Representation of Counties in Romania and SQL Table for Storing County Data

Enum County Romania Java SQL Alba Arad Argeș Bacău Bihor Bistrița-Năsăud Botoșani Brașov Brăila Buzău Caraș-Severin Călărași Cluj Constanța Covasna Dâmbovița Dolj Galați Giurgiu Gorj Harghita Hunedoara Ialomița Iași Ilfov Maramureș Mehedinți Mureș Neamț Olt Prahova Sălaj Satu Mare Sibiu Suceava Teleorman Timiș Tulcea Vâlcea Vaslui Vrancea County Code

Enum Representation in Java

Romania is divided into 41 counties and the capital city, Bucharest. Below is an enum representation of those counties with their respective codes:

java

public enum County {
    ALBA("AB"),
    ARAD("AR"),
    ARGEȘ("AG"),
    BACĂU("BC"),
    BIHOR("BH"),
    BISTRIȚA_NĂSĂUD("BN"),
    BOTOȘANI("BS"),
    BRAȘOV("BR"),
    BRĂILA("BR"),
    BUZĂU("BZ"),
    CARAȘ_SEVERIN("CS"),
    CĂLĂRAȘI("CL"),
    CLUJ("CJ"),
    CONSTANȚA("CS"),
    COVASNA("CV"),
    DÂMBOVIȚA("DB"),
    DOLJ("DO"),
    GALAȚI("GL"),
    GIURGIU("GR"),
    GORJ("GO"),
    HARGHITA("HR"),
    HUNEDOARA("HD"),
    IALOMIȚA("IL"),
    IAȘI("IS"),
    ILFOV("IF"),
    MARAMUREȘ("MM"),
    MEHEDINȚI("MH"),
    MUREȘ("MS"),
    NEAMȚ("NT"),
    OLT("OT"),
    PRAHOVA("PH"),
    SĂLAJ("SJ"),
    SATU_MARE("SM"),
    SIBIU("SB"),
    SUCEAVA("SV"),
    TELEORMAN("TR"),
    TIMIȘ("TM"),
    TULCEA("TL"),
    VÂLCEA("VS"),
    VASLUI("VS"),
    VRANCEA("VS");

    private final String code;

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

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

In the code:

  • The enum County defines the counties of Romania and their respective codes.
  • Each county is associated with a two-character abbreviation.
  • The getCode() method allows you to retrieve the county code.

SQL Representation for Storing County Data

To store the counties of Romania in a database, you can create a table and insert the data using the following SQL:

sql

-- Table definition for storing counties of Romania
CREATE TABLE counties (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    code CHAR(2) NOT NULL
);

-- Inserting data for counties of Romania
INSERT INTO counties (name, code) VALUES
('Alba', 'AB'),
('Arad', 'AR'),
('Argeș', 'AG'),
('Bacău', 'BC'),
('Bihor', 'BH'),
('Bistrița-Năsăud', 'BN'),
('Botoșani', 'BS'),
('Brașov', 'BR'),
('Brăila', 'BR'),
('Buzău', 'BZ'),
('Caraș-Severin', 'CS'),
('Călărași', 'CL'),
('Cluj', 'CJ'),
('Constanța', 'CS'),
('Covasna', 'CV'),
('Dâmbovița', 'DB'),
('Dolj', 'DO'),
('Galați', 'GL'),
('Giurgiu', 'GR'),
('Gorj', 'GO'),
('Harghita', 'HR'),
('Hunedoara', 'HD'),
('Ialomița', 'IL'),
('Iași', 'IS'),
('Ilfov', 'IF'),
('Maramureș', 'MM'),
('Mehedinți', 'MH'),
('Mureș', 'MS'),
('Neamț', 'NT'),
('Olt', 'OT'),
('Prahova', 'PH'),
('Sălaj', 'SJ'),
('Satu Mare', 'SM'),
('Sibiu', 'SB'),
('Suceava', 'SV'),
('Teleorman', 'TR'),
('Timiș', 'TM'),
('Tulcea', 'TL'),
('Vâlcea', 'VS'),
('Vaslui', 'VS'),
('Vrancea', 'VS');

In the SQL:

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

This setup ensures that you can efficiently store and query the counties of Romania, 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