Programming & Development / April 12, 2025

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

Enum Counties Sweden Java SQL Stockholm Västra Götaland Skåne Län County Code Administrative Division

✅ Enum Representation in Java

Sweden is divided into 21 counties (län in Swedish). Below is a Java enum representing each county along with a two-letter county code based on common abbreviations:

java

public enum County {
    BLEKINGE("K"),
    DALARNA("W"),
    GAVLEBORG("X"),
    GOTLAND("I"),
    HALLAND("N"),
    JAMTLAND("Z"),
    JONKOPING("F"),
    KALMAR("H"),
    KRONOBERG("G"),
    NORRBOTTEN("BD"),
    ÖREBRO("T"),
    ÖSTERGÖTLAND("E"),
    SKANE("M"),
    SÖDERMANLAND("D"),
    STOCKHOLM("AB"),
    UPPSALA("C"),
    VÄRMLAND("S"),
    VÄSTERBOTTEN("AC"),
    VÄSTERNORRLAND("Y"),
    VÄSTMANLAND("U"),
    VÄSTRA_GÖTALAND("O");

    private final String code;

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

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

🔹 Notes:

  • Codes are based on the official vehicle registration and administrative codes used in Sweden.
  • getCode() enables integration with systems or databases that require standardized identifiers.

✅ SQL Representation for Storing County Data

Here’s a SQL table and insert script to store Sweden’s 21 counties:

sql

-- Table definition for Swedish counties
CREATE TABLE counties (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    code VARCHAR(3) NOT NULL
);

-- Insert counties into the table
INSERT INTO counties (name, code) VALUES
('Blekinge', 'K'),
('Dalarna', 'W'),
('Gävleborg', 'X'),
('Gotland', 'I'),
('Halland', 'N'),
('Jämtland', 'Z'),
('Jönköping', 'F'),
('Kalmar', 'H'),
('Kronoberg', 'G'),
('Norrbotten', 'BD'),
('Örebro', 'T'),
('Östergötland', 'E'),
('Skåne', 'M'),
('Södermanland', 'D'),
('Stockholm', 'AB'),
('Uppsala', 'C'),
('Värmland', 'S'),
('Västerbotten', 'AC'),
('Västernorrland', 'Y'),
('Västmanland', 'U'),
('Västra Götaland', 'O');

This setup is perfect for applications and databases that need to manage Swedish regional data with precision.


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