0% found this document useful (0 votes)
25 views11 pages

Kamaru Dbms PDF

This document describes a database project for a hospital management system. It includes the creation of a database called "HospitalDB" and three tables - Patients, Doctors, and Appointments. Sample data is inserted and several queries are provided to retrieve information like patient records, doctor details, appointments with patient and doctor details, patients with medical history of allergies, doctors specializing in Dermatology, and more. An ER diagram is also included to show the relationships between entities.

Uploaded by

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

Kamaru Dbms PDF

This document describes a database project for a hospital management system. It includes the creation of a database called "HospitalDB" and three tables - Patients, Doctors, and Appointments. Sample data is inserted and several queries are provided to retrieve information like patient records, doctor details, appointments with patient and doctor details, patients with medical history of allergies, doctors specializing in Dermatology, and more. An ER diagram is also included to show the relationships between entities.

Uploaded by

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

1

DATABASE MANAGEMENT SYSTEM LAB

A OPEN ENDED PROJECT REPORT

submitted by

KAMARUDDEEN M P

Regno.2201132803

The Technical Education department


in partial fulfilment of the requirement
for the award

Diploma in Computer Engineering

Department of Computer Engineering


Government Polytechnic College Mananthavady, Wayanad

Dwaraka – 670644
October 2023
2
2

DECLARATION

I undersigned, hereby declare that the Opened project report submitted for partial
fulfilment of the requirements for the award of Diploma in computer engineering of
theTechnicalEducationdepart-ment,Keralaisabonafideworkdonebymeunder
supervision of KARUNAKARAN V N

. This submission represents my ideas in my own words. I also declare that I


have adhered to ethics of academic honesty and integrity and have not
misrepresented or fabricated any data or idea or fact or source in my submission.
This report has not been previously formed the basis for the award of any degree,
diploma or similar title of any other Uni-versity.

Place: Mananthavady KAMARUDDEEN M P


Date: October, 2023 S3CT
3
3

DEPARTMENT OF COMPUTER ENGINEERING GOVERNMENT


POLYTECHNIC COLLEGE, DWARAKA WAYANAD – 670645

CERTIFICATE
This is to certify that the report entitled"OPENED PROJECT"submitted
by "KAMARUDDEEN M P" to the Technical Education department partial fulfillment
of the requirements for the award of Diploma in Computer Engineering is a bonafide
record of the project work carried out by her un-der my guidance and supervision.
This report in any form has not been submitted to any other University or Institute
for any purpose.

Internal Supervisor(s) External Supervisor(s)

Office Seal

Project Coordinator Head of the Department


4
4

ACKNOWLEDGEMENT

First of all, I would like to solicit my humble thanks to God


almighty for being with me, the right way throughout my Opened
project presentation. I record my indebtedness to our principal
Suresh Kumar CP, for his guidance and sustained encouragement
for the successful completion of this report. I am highly grateful to
VInod E, Head, Department of Computer Science, and his valuable
suggestion and guidance throughout this report. His positive
approach had offered incessant help in all possible ways from the
beginning. It’s my pleasure to express my gratitude to my minor
project coordinators KARUNAKARAN VN Lecturer, Department of
Computer Engineering . I also extend my thanks to my faculty
mem-bers and my friends for their moral support for completing
the Minor project report.I would also extremely grateful to Suresh
Kumar C P, Principal of Govt.Polytechnic College,Wayanad for
providing the facilities.I would also like to extend my gratitude to
all well wishes and friends who supported me to present the
Project
5

DESCRIPTION
Database Creation:

- A database named "HospitalDB" is created using the `CREATE DATABASE` command. -

The `USE` statement selects the "HospitalDB" database for further operations.

Tables
:

- Three main tables are created: "Patients," "Doctors," and "Appointments."

Patients Table:

- Stores patient information, including a unique identifier, first name, last name, date of birth,

gender, contact number, and medical history.

Doctors Table:

- Stores doctor information, including a unique identifier, first name, last name, specialization,

and contact number.

Appointments Table:

- Stores appointment information, including a unique identifier, patient ID, doctor ID,

appointment date, and notes.

Sample Data:

- Sample patient and doctor records are inserted into their respective tables.

- Sample appointment records are also inserted, associating patients and doctors with specific

appointment details.

Queries:

- Several SQL queries are provided to retrieve various information from the database.

- The queries include:

- Retrieving all patient records.

- Retrieving all doctor records.

- Retrieving appointments with patient and doctor details.

- Retrieving patients with medical history containing allergies.

- Retrieving doctors who specialize in Dermatology.

- Retrieving appointments scheduled for a specific date.

- Retrieving patients older than 40 years.

- Retrieving doctors who have appointments scheduled.

- Retrieving patients with upcoming appointments.

- Retrieving the total number of appointments for each doctor.


6

ER DIAGRAM
7

HOSPITAL DATABASE SYSTEM

-- Create a database
CREATE DATABASE HospitalDB;
USE HospitalDB;
-- Create a table for patients
CREATE TABLE Patients (
PatientID INT AUTO_INCREMENT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
DateOfBirth DATE,
Gender ENUM('Male', 'Female', 'Other'),
ContactNumber VARCHAR(15),
MedicalHistory TEXT
);
-- Create a table for doctors
CREATE TABLE Doctors (
DoctorID INT AUTO_INCREMENT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Specialization VARCHAR(100),
ContactNumber VARCHAR(15)
);
-- Create a table for appointments
CREATE TABLE Appointments (
AppointmentID INT AUTO_INCREMENT PRIMARY KEY,
PatientID INT,
DoctorID INT,
AppointmentDate DATETIME,
Notes TEXT
);
-- Sample patient records
INSERT INTO Patients (FirstName, LastName, DateOfBirth, Gender,
ContactNumber, MedicalHistory)
VALUES
('Sarah', 'Wilson', '1972-04-10', 'Female', '+7778889999', 'Allergies: Peanuts'),
('Mark', 'Miller', '1995-08-15', 'Male', '+5554443333', 'Asthma: Controlled'),
('Emily', 'Garcia', '1983-02-28', 'Female', '+1112223333', 'Hypertension: Medication
required'),
('James', 'Lee', '2000-11-03', 'Male', '+3332221111', 'Allergies: Shellfish'),
('Linda', 'Chen', '1970-12-20', 'Female', '+2223334444', 'Diabetes:
Insulin-dependent'),
('Richard', 'Wilson', '1992-07-15', 'Male', '+6667778888', 'Previous surgeries: Knee
replacement'),
('Mia', 'Brown', '1989-03-25', 'Female', '+8889990000', 'Asthma: Controlled'),
('David', 'Hall', '1976-06-10', 'Male', '+1234567890', 'Hypertension: Medication
required'),
('Olivia', 'Adams', '1980-01-02', 'Female', '+4445556666', 'Chronic condition:
Migraines');

-- Sample doctor records


INSERT INTO Doctors (FirstName, LastName, Specialization, ContactNumber)
VALUES
('Dr. James', 'Taylor', 'Gynecology', '+7778889999'),
('Dr. Laura', 'Clark', 'Dermatology', '+5554443333'),
8
('Dr. Robert', 'Lee', 'Neurology', '+3332221111'),
('Dr. Susan', 'Miller', 'Ophthalmology', '+2223334444'),
('Dr. Daniel', 'Martinez', 'Oncology', '+6667778888'),
('Dr. Maria', 'Hernandez', 'Pulmonology', '+8889990000'),
('Dr. John', 'Garcia', 'Urology', '+1234567890'),
('Dr. Patricia', 'Wang', 'Endocrinology', '+4445556666');

-- Sample appointment records


INSERT INTO Appointments (PatientID, DoctorID, AppointmentDate, Notes)
VALUES
(4, 4, '2023-11-04 11:00:00', 'Gynecological checkup'),
(5, 5, '2023-11-05 15:45:00', 'Dermatology consultation'),
(6, 6, '2023-11-06 16:30:00', 'Neurology assessment'),
(7, 7, '2023-11-07 14:30:00', 'Ophthalmology examination'),
(8, 8, '2023-11-08 10:15:00', 'Oncology consultation'),
(9, 9, '2023-11-09 12:45:00', 'Pulmonology checkup'),
(10, 10, '2023-11-10 09:30:00', 'Urology assessment'),
(1, 8, '2023-11-11 13:15:00', 'Endocrinology consultation');

-- Retrieve all patient records


SELECT * FROM Patients;
-- Retrieve all doctor records
SELECT * FROM Doctors;
-- Retrieve appointments with patient and doctor details
SELECT A.AppointmentID, P.FirstName AS PatientFirstName, P.LastName AS
PatientLastName,
D.FirstName AS DoctorFirstName, D.LastName AS DoctorLastName,
A.AppointmentDate, A.Notes
FROM Appointments A
JOIN Patients P ON A.PatientID = P.PatientID
JOIN Doctors D ON A.DoctorID = D.DoctorID;
-- Retrieve patients with medical history containing allergies
SELECT * FROM Patients WHERE MedicalHistory LIKE '%Allergies%';
-- Retrieve doctors who specialize in Dermatology
SELECT * FROM Doctors WHERE Specialization = 'Dermatology'';
-- Retrieve appointments scheduled for a specific date
SELECT A.AppointmentID, P.FirstName AS PatientFirstName, P.LastName AS
PatientLastName,
D.FirstName AS DoctorFirstName, D.LastName AS DoctorLastName,
A.AppointmentDate, A.Notes
FROM Appointments A
JOIN Patients P ON A.PatientID = P.PatientID
JOIN Doctors D ON A.DoctorID = D.DoctorID
WHERE DATE(A.AppointmentDate) = '2023-11-02';
-- Retrieve patients older than 40 years
SELECT * FROM Patients WHERE DATEDIFF(NOW(), DateOfBirth) >= 14600;
-- Retrieve doctors who have appointments scheduled
SELECT D.DoctorID, D.FirstName, D.LastName
FROM Doctors D
JOIN Appointments A ON D.DoctorID = A.DoctorID
GROUP BY D.DoctorID, D.FirstName, D.LastName;
-- Retrieve patients with upcoming appointments
SELECT P.PatientID, P.FirstName, P.LastName
FROM Patients P
9
JOIN Appointments A ON P.PatientID = A.PatientID
WHERE A.AppointmentDate > NOW();
-- Retrieve the total number of appointments for each doctor
SELECT D.DoctorID, D.FirstName, D.LastName, COUNT(A.AppointmentID) AS
TotalAppointments
FROM Doctors D
LEFT JOIN Appointments A ON D.DoctorID = A.DoctorID
GROUP BY D.DoctorID, D.FirstName, D.LastName;

Output

1. Retrieve all patients records:

+-----------+------------+-----------+------------+--------+----------------+----------
------------ +
| PatientID | FirstName | LastName | DateOfBirth | Gender | ContactNumber |
MedicalHistory | +-----------+------------+-----------+------------+--------+--------
--------+---------------------- +
|1 |Sarah |Wilson |1972-04-10|Female|+7778889999 | Allergies:Peanuts |
|2 |Mark |Miller|1995-08-15|Male|+5554443333|Asthma: Controlled |
|3 |Emily |Garcia |1983-02-28|Female|+1112223333 Hypertension: Medication
required |
|4 |James |Lee |2000-11-03|Male|+3332221111 |Allergies: Shellfish |
|5 |Linda |Chen |1970-12-20|Female|+2223334444 | Diabetes: Insulin-
dependent |
|6 |Richard|Wilson|1992-07-15|Male|+6667778888|
Previous surgeries: Knee replacement |
|7 |Mia |Brown |1989-03-25|Female|+8889990000 | Asthma:Controlled |
|8 |David |Hall |1976-06-10|Male|+1234567890 | Hypertension: Medication
required |
|9 |Olivia |Adams |1980-01-02|Female|+4445556666 |
Chronic condition: Migraines | +-----------+------------+-----------+------------+---
-----+----------------+--------------------+
2.Retrieve all doctor records:
+----------+------------+-----------+------------------+----------------+
| DoctorID | FirstName | LastName | Specialization | ContactNumber | +----------
+------------+-----------+------------------+----------------+
|1 |Dr.James|Taylor |Gynecology |+7778889999 |
|2 |Dr.Laura|Clark |Dermatology |+5554443333 |
|3 |Dr.Robert|Lee |Neurology |+3332221111 |
|4 |Dr.Susan|Miller |Ophthalmology |+2223334444 |
|5 |Dr.Daniel|Martinez|Oncology |+6667778888|
|6 |Dr.Maria|Hernandez|Pulmonology |+8889990000 |
|7 |Dr.John|Garcia |Urology |+1234567890 |
|8 |Dr.Patricia|Wang |Endocrinology |+4445556666 | +----------+------------+---
--------+------------------+----------------+
10

3.Retrieve appointments with patient and doctor details:


+--------------+-----------------+----------------+----------------+----------------+--
------------- ------+------------------------+
| AppointmentID | PatientFirstName | PatientLastName | DoctorFirstName |
DoctorLastName|AppointmentDate|Notes | +--------------+-----------------+-----
-----------+----------------+----------------+--------------- ------+--------------------
----+
|1 |James |Lee |Susan |Miller |2023-11-07 14:30:00 | Ophthalmology
examination |
|2 |Linda |Chen |Daniel |Martinez |2023-11-08 10:15:00 | Oncology consultation
|
|3 |Richard |Wilson |Maria |Hernandez | 2023-11-09 12:45:00 | Pulmonology
checkup |
|4 |Mia |Brown |John |Garcia |2023-11-10 09:30:00|Urologyassessment |
|5 |Sarah |Wilson |Patricia |Wang |2023-11-11 13:15:00 | Endocrinology
consultation |
|6 |Mark |Miller |NULL |NULL |2023-11-02 08:30:00|Follow-up | +--------------
+-----------------+----------------+----------------+----------------+-------------+
4.Retrieve patients with medical history containing allergies:
+-----------+------------+-----------+------------+--------+----------------+----------
------------ +
| PatientID | FirstName | LastName | DateOfBirth | Gender | ContactNumber |
MedicalHistory | +-----------+------------+-----------+------------+--------+--------
--------+---------------------- +
|1 |Sarah |Wilson |1972-04-10|Female|+7778889999 | Allergies:Peanuts |
|4 |James |Lee |2000-11-03|Male|+3332221111 |Allergies: Shellfish | +---------
--+------------+-----------+------------+--------+----------------+--------------------
+
5.Retrieve doctors who specialize in Dermatology::
+----------+------------+-----------+------------------+
| DoctorID | FirstName | LastName | Specialization | +----------+------------+-----
------+------------------+
|2 |Dr.Laura|Clark |Dermatology | +----------+------------+-----------+-------------
-----+

6.Retrieve appointments scheduled for a specific date:


+--------------+-----------------+----------------+----------------+----------------+--
------------- ------+------------------------+
| AppointmentID | PatientFirstName | PatientLastName | DoctorFirstName |
DoctorLastName|AppointmentDate|Notes | +--------------+-----------------+-----
-----------+----------------+----------------+--------------- ------+--------------------
----+
|6 |Mark |Miller |NULL |NULL |2023-11-02 08:30:00|Follow-up |
11
+--------------+-----------------+----------------+----------------+----------------+--
------------- ------+------------------------+

7.Retrieve patients older than 40 years:


+-----------+------------+-----------+------------+--------+----------------+----------
------------ +
| PatientID | FirstName | LastName | DateOfBirth | Gender | ContactNumber |
MedicalHistory | +-----------+------------+-----------+------------+--------+--------
--------+---------------------- +
|1 |Sarah |Wilson |1972-04-10|Female|+7778889999 | Allergies:Peanuts |
|5 |Linda |Chen |1970-12-20|Female|+2223334444 | Diabetes: Insulin-
dependent |
|6 |Richard|Wilson|1992-07-15|Male|+6667778888|
Previous surgeries: Knee replacement |
|8 |David |Hall |1976-06-10|Male|+1234567890 | Hypertension: Medication
required |
|9 |Olivia |Adams |1980-01-02|Female|+4445556666 |
Chronic condition

You might also like