Skip to content

Latest commit

 

History

History
197 lines (140 loc) · 4.44 KB

File metadata and controls

197 lines (140 loc) · 4.44 KB

UNIWA

UNIVERSITY OF WEST ATTICA
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING AND INFORMATICS

University of West Attica · Department of Computer Engineering and Informatics


Databases II

Creation of Database personnel

Vasileios Evangelos Athanasiou
Student ID: 19390005

GitHub · LinkedIn


Supervision

Supervisor: Periklis Andritsos, Associate Professor

UNIWA Profile · LinkedIn

Co-supervisor: Rania Garofalaki, Laboratory Teaching Staff

UNIWA Profile · LinkedIn

Athens, December 2023



INSTALL

Creation of Database personnel

This repository contains a personnel database creation project developed for the Databases II course at the University of West Attica (UNIWA).
The focus is on creating a relational database with DEPT, JOB, and EMP tables, inserting sample data, and performing queries for analysis.


1. Prerequisites

Before starting, ensure the following software is installed:

1.1 Database Management System (DBMS)

  • MySQL (recommended)
  • Alternative options:
    • MariaDB
    • PostgreSQL (minor syntax adjustments may be required)

1.2 SQL Client / Interface

A tool to execute SQL commands:

  • MySQL Workbench (recommended)
  • phpMyAdmin
  • DBeaver
  • Command-line MySQL client

1.3 Basic Knowledge

  • SQL commands: CREATE DATABASE, CREATE TABLE, INSERT, SELECT
  • Foreign key relationships
  • Aggregate functions: SUM(), AVG(), COUNT(), etc.

2. Installation

2.1 Clone the Repository

Open a terminal/command prompt and run:

git clone https://github.com/Data-Bases-2/Create-Database.git

2.2 Alternative (Without Git)

  • Open the repository URL in your browser
  • Click Code → Download ZIP
  • Extract the ZIP file to a local directory

2.3 Open SQL Client

  • Launch your preferred SQL client (e.g., MySQL Workbench)
  • Connect to your local or remote MySQL server

2.4 Create the Database

  • Execute the following SQL command if the database does not exist:
CREATE DATABASE IF NOT EXISTS personnel;
USE personnel;

2.5 Create Tables

Run the provided SQL script src/personnel.sql:

-- Example for DEPT table
CREATE TABLE DEPT (
    DEPTNO INT PRIMARY KEY,
    DNAME VARCHAR(50),
    LOC VARCHAR(50)
);

-- Example for JOB table
CREATE TABLE JOB (
    JOBCODE INT PRIMARY KEY,
    JOB_DESCR VARCHAR(50),
    SAL INT
);

-- Example for EMP table
CREATE TABLE EMP (
    EMPNO INT PRIMARY KEY,
    NAME VARCHAR(50),
    JOBNO INT,
    DEPTNO INT,
    COMM INT,
    FOREIGN KEY (DEPTNO) REFERENCES DEPT(DEPTNO),
    FOREIGN KEY (JOBNO) REFERENCES JOB(JOBCODE)
);

Tip: You can execute the full personnel.sql file in one step using your SQL client.

2.6 Insert Sample Data

Populate tables with example records using the INSERT INTO statements in personnel.sql or refer to images in queries/ for visual guidance.

2.7 Verify Tables

Check that the tables and sample data exist:

USE personnel;
SHOW TABLES;

SELECT * FROM DEPT;
SELECT * FROM JOB;
SELECT * FROM EMP;

3. Open the Documentation

  1. Navigate to the docs/ directory
  2. Open the report corresponding to your preferred language:
    • English: Create-Database.pdf
    • Greek: Δημιουργία-ΒΔ.pdf