Programming & Development / April 12, 2025

Enum Representation of Departments in Paraguay and SQL Table for Storing Department Data

Enum Department Paraguay Java SQL Alto Parana Amambay Asuncion Boqueron Caaguazu Caazapa Canindeyu Central Concepcion Cordillera Guaira Itapua Misiones Paraguarí Presidente Hayes San Pedro Department Code

Enum Representation in Java

Paraguay is divided into 17 departments. Below is an enum representation of those departments with their respective codes:

java

public enum Department {
    ALTO_PARANA("AP"),
    AMAMBAY("AM"),
    ASUNCION("AS"),
    BOQUERON("BO"),
    CAAGUAZU("CA"),
    CAAZAPA("CZ"),
    CANINDEYU("CY"),
    CENTRAL("CE"),
    CONCEPCION("CO"),
    CORDILLERA("CD"),
    GUAIRA("GA"),
    ITAPUA("IT"),
    MISIONES("MI"),
    PARAGUARI("PA"),
    PRESIDENTE_HAYES("PH"),
    SAN_PEDRO("SP");

    private final String code;

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

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

In the code:

  • The enum Department defines the departments of Paraguay and their respective codes.
  • Each department is associated with a two-character code.
  • The getCode() method is used to retrieve the department code.

SQL Representation for Storing Department Data

To store the departments of Paraguay in a database, we can create a table and insert the data using the following SQL:

sql

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

-- Inserting data for departments of Paraguay
INSERT INTO departments (name, code) VALUES
('Alto Parana', 'AP'),
('Amambay', 'AM'),
('Asuncion', 'AS'),
('Boqueron', 'BO'),
('Caaguazu', 'CA'),
('Caazapa', 'CZ'),
('Canindeyu', 'CY'),
('Central', 'CE'),
('Concepcion', 'CO'),
('Cordillera', 'CD'),
('Guaira', 'GA'),
('Itapua', 'IT'),
('Misiones', 'MI'),
('Paraguari', 'PA'),
('Presidente Hayes', 'PH'),
('San Pedro', 'SP');

In the SQL:

  • We define a departments table with columns id (auto-incremented), name (the name of the department), and code (the abbreviation for the department).
  • The INSERT INTO statement inserts the departments of Paraguay along with their respective codes into the table.

This structure ensures that you can easily store and query department data for Paraguay both in application code (via Java enum) and in a relational database.


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