0% found this document useful (0 votes)
8 views4 pages

Create Table Department

The document outlines the creation of a database schema for a hospital system, including tables for Departments, Employees, Jobs, and Leave records. It includes the structure of each table, primary and foreign key relationships, and sample data insertion for departments, employees, job titles, and leave records. The schema supports employee management and tracking of leaves in various departments.

Uploaded by

aminaashraf1101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Create Table Department

The document outlines the creation of a database schema for a hospital system, including tables for Departments, Employees, Jobs, and Leave records. It includes the structure of each table, primary and foreign key relationships, and sample data insertion for departments, employees, job titles, and leave records. The schema supports employee management and tracking of leaves in various departments.

Uploaded by

aminaashraf1101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

CREATE TABLE Department (

Dept_id int,

Dept_Name varchar(255),

PRIMARY KEY (Dept_id));

CREATE TABLE Employees (

Employee_id int,

First_name varchar(255),

Last_name varchar(255),

Email varchar(255),

Phone_number int,

Hier_date date,

Job_id int,

Salary int,

Dept_id int,

PRIMARY KEY (Employee_id),

FOREIGN KEY (Dept_id) REFERENCES Department(Dept_id));

CREATE TABLE Job (

Job_title varchar(255),

Minjob_id int,

Min_salary int,

Max_salary int,

Dept_id int,

FOREIGN KEY (Dept_id) REFERENCES Department(Dept_id));

CREATE TABLE Leave (

Employee_id int,

L_id int,

Start_date DATE,

End_date DATE,

L_description varchar(255),
PRIMARY KEY (L_id),

FOREIGN KEY (Employee_id) REFERENCES Employees(Employee_id));

-- Inserting records into the Departments table

INSERT INTO Department (Dept_id, Dept_Name) VALUES (1, 'Cardiology');

INSERT INTO Department (Dept_id, Dept_Name) VALUES (2, 'Neurology');

INSERT INTO Department (Dept_id, Dept_Name) VALUES (3, 'Oncology');

INSERT INTO Department (Dept_id, Dept_Name) VALUES (4, 'Pediatrics');

INSERT INTO Department (Dept_id, Dept_Name) VALUES (5, 'Radiology');

INSERT INTO Department (Dept_id, Dept_Name) VALUES (6, 'Orthopedics');

-- Inserting records into the Employee table

INSERT INTO Employees (Employee_id, First_name, Last_name, Email, Phone_number, Hier_date,


Job_id, Salary, Dept_id)

VALUES (1, 'John', 'Doe', 'john.doe@example.com', 1234567890, TO_DATE('2022-05-15', 'YYYY-MM-


DD'), 101, 70000, 1);

INSERT INTO Employees (Employee_id, First_name, Last_name, Email, Phone_number, Hier_date,


Job_id, Salary, Dept_id)

VALUES (2, 'Emma', 'Smith', 'emma.smith@example.com', 9876543210, TO_DATE('2021-07-10', 'YYYY-


MM-DD'), 102, 65000, 2);

INSERT INTO Employees (Employee_id, First_name, Last_name, Email, Phone_number, Hier_date,


Job_id, Salary, Dept_id)

VALUES (3, 'Liam', 'Brown', 'liam.brown@example.com', 1231231234, TO_DATE('2023-01-25', 'YYYY-


MM-DD'), 103, 75000, 3);

INSERT INTO Employees (Employee_id, First_name, Last_name, Email, Phone_number, Hier_date,


Job_id, Salary, Dept_id)

VALUES (4, 'Olivia', 'Wilson', 'olivia.wilson@example.com', 4564564567, TO_DATE('2020-09-05', 'YYYY-


MM-DD'), 104, 60000, 4);
INSERT INTO Employees (Employee_id, First_name, Last_name, Email, Phone_number, Hier_date,
Job_id, Salary, Dept_id)

VALUES (5, 'Noah', 'Taylor', 'noah.taylor@example.com', 7897897890, TO_DATE('2022-12-19', 'YYYY-


MM-DD'), 105, 68000, 5);

INSERT INTO Employees (Employee_id, First_name, Last_name, Email, Phone_number, Hier_date,


Job_id, Salary, Dept_id)

VALUES (6, 'Sophia', 'Davis', 'sophia.davis@example.com', 3213213210, TO_DATE('2021-03-08', 'YYYY-


MM-DD'), 106, 72000, 6);

-- Inserting records into the Job table

INSERT INTO Job (Job_title, Minjob_id, Min_salary, Max_salary, Dept_id)

VALUES ('Cardiologist', 101, 80000, 150000, 1);

INSERT INTO Job (Job_title, Minjob_id, Min_salary, Max_salary, Dept_id)

VALUES ('Neurologist', 102, 75000, 145000, 2);

INSERT INTO Job (Job_title, Minjob_id, Min_salary, Max_salary, Dept_id)

VALUES ('Oncologist', 103, 72000, 140000, 3);

INSERT INTO Job (Job_title, Minjob_id, Min_salary, Max_salary, Dept_id)

VALUES ('Pediatrician', 104, 70000, 130000, 4);

INSERT INTO Job (Job_title, Minjob_id, Min_salary, Max_salary, Dept_id)

VALUES ('Radiologist', 105, 75000, 135000, 5);

INSERT INTO Job (Job_title, Minjob_id, Min_salary, Max_salary, Dept_id)

VALUES ('Orthopedic Surgeon', 106, 78000, 160000, 6);

-- Inserting records into the Leaves table

INSERT INTO Leave (Employee_id, L_id, Start_date, End_date, L_description)


VALUES (1, 1, TO_DATE('2024-01-10', 'YYYY-MM-DD'), TO_DATE('2024-01-15', 'YYYY-MM-DD'), 'Medical
leave for surgery');

INSERT INTO Leave (Employee_id, L_id, Start_date, End_date, L_description)

VALUES (2, 2, TO_DATE('2024-03-05', 'YYYY-MM-DD'), TO_DATE('2024-03-07', 'YYYY-MM-DD'), 'Personal


leave for family emergency');

INSERT INTO Leave (Employee_id, L_id, Start_date, End_date, L_description)

VALUES (3, 3, TO_DATE('2024-04-20', 'YYYY-MM-DD'), TO_DATE('2024-04-22', 'YYYY-MM-DD'),


'Conference leave for attending a medical seminar');

INSERT INTO Leave (Employee_id, L_id, Start_date, End_date, L_description)

VALUES (4, 4, TO_DATE('2024-06-01', 'YYYY-MM-DD'), TO_DATE('2024-06-10', 'YYYY-MM-DD'),


'Maternity leave');

INSERT INTO Leave (Employee_id, L_id, Start_date, End_date, L_description)

VALUES (5, 5, TO_DATE('2024-08-15', 'YYYY-MM-DD'), TO_DATE('2024-08-18', 'YYYY-MM-DD'), 'Sick


leave due to flu');

INSERT INTO Leave (Employee_id, L_id, Start_date, End_date, L_description)

VALUES (6, 6, TO_DATE('2024-10-01', 'YYYY-MM-DD'), TO_DATE('2024-10-05', 'YYYY-MM-DD'), 'Vacation


leave');

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy