Kamaru Dbms PDF
Kamaru Dbms PDF
submitted by
KAMARUDDEEN M P
Regno.2201132803
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
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.
Office Seal
ACKNOWLEDGEMENT
DESCRIPTION
Database Creation:
The `USE` statement selects the "HospitalDB" database for further operations.
Tables
:
Patients Table:
- Stores patient information, including a unique identifier, first name, last name, date of birth,
Doctors Table:
- Stores doctor information, including a unique identifier, first name, last name, specialization,
Appointments Table:
- Stores appointment information, including a unique identifier, patient ID, doctor ID,
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.
ER DIAGRAM
7
-- 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');
Output
+-----------+------------+-----------+------------+--------+----------------+----------
------------ +
| 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