CREATE DATABASE epmsd;
USE epmsd;
-- 1. Table y'abakoresha (Users)
CREATE TABLE users (
    UserID INT AUTO_INCREMENT PRIMARY KEY,
    Email VARCHAR(100) UNIQUE NOT NULL,
    Password VARCHAR(255) NOT NULL
);

-- 2. Table y'amashami (Department)
CREATE TABLE Department (
    DepartementCode VARCHAR(20) PRIMARY KEY,
    DepartementName VARCHAR(100) NOT NULL,
    GrossSalary DECIMAL(10, 2),
    TotalDeduction DECIMAL(10, 2)
);

-- 3. Table y'abakozi (Employee)
CREATE TABLE Employee (
    employeeNumber VARCHAR(20) PRIMARY KEY,
    FirstName VARCHAR(50),
    LastName VARCHAR(50),
    Position VARCHAR(50),
    Address VARCHAR(100),
    Telephone VARCHAR(20),
    Gender VARCHAR(10),
    hiredDate DATE,
    DepartementCode VARCHAR(20),
    FOREIGN KEY (DepartementCode) REFERENCES Department(DepartementCode)
);

-- 4. Table y'imishahara (Salary)
CREATE TABLE Salary (
    SalaryID INT AUTO_INCREMENT PRIMARY KEY,
    employeeNumber VARCHAR(20),
    GlossSalary DECIMAL(10, 2),
    TotalDeduction DECIMAL(10, 2),
    NetSalary DECIMAL(10, 2),
    month VARCHAR(20),
    transactionDate DATE,
    FOREIGN KEY (employeeNumber) REFERENCES Employee(employeeNumber)
);