Escolar Documentos
Profissional Documentos
Cultura Documentos
HOSPITAL
MANAGEMENT
SYSTEM
EXPERIMENT -5
AIM:
THEORY:
TABLES
Entity Table:
Department Table
Doctor
Nurse
Ward
Test
Relationship Table:
Takestest
Treats
Conduct
1. DEPARTMENT TABLE
CREATION
INSERTION
DISPLAY
CREATION
INSERTION
3. NURSE TABLE
CREATION
INSERTION
INSERT INTO NURSE VALUES(1005,'KAMINI SHARMA','JUNIOR
NURSE','BSC','PITAMPURA - 110034',9958435445,1004)
DISPLAY
4. WARD TABLE
CREATION
DISPLAY
CREATION
INSERTION
DISPLAY
1. TAKESTEST TABLE
CREATION
CREATE TABLE TAKESTEST
( TESTID NUMBER,
PID NUMBER,
RESULT VARCHAR2(25),
PRIMARY KEY ("PID", "TESTID") ,
FOREIGN KEY ("TESTID") REFERENCES "TEST" ("TESTID"),
FOREIGN KEY ("PID") REFERENCES "PATIENT" ("PID")
);
INSERTION
INSERT INTO TAKESTEST VALUES(1003,209,'POSITIVE');
DISPLAY
SELECT * FROM TAKESTEST
2. TREATS TABLE
CREATION
CREATE TABLE TREATS
( DOCID NUMBER,
P_ID NUMBER,
PRIMARY KEY ("DOCID", "P_ID"),
FOREIGN KEY ("DOCID") REFERENCES "DOCTOR" ("DOCID") ,
FOREIGN KEY ("P_ID") REFERENCES "PATIENT" ("PID")
)
INSERTION
INSERT INTO TREATS VALUES(1003,209)
DISPLAY
SELECT * FROM TREATS
3. CONDUCT TABLE
CREATION
CREATE TABLE CONDUCTS
( DOCID NUMBER,
TESTID NUMBER,
PRIMARY KEY ("DOCID", "TESTID"),
FOREIGN KEY ("DOCID") REFERENCES "DOCTOR" ("DOCID"),
FOREIGN KEY ("TESTID") REFERENCES "TEST" ("TESTID")
);
INSERTION
Adding Foreign Key HOD_ID in DEPARTMENT table
ALTER TABLE DEPARTMENT ADD CONSTRAINT HOD_ID_FK FOREIGN
KEY(HOD_ID) REFERENCES DOCTOR(DOCID)
ALTER COMMAND
UPDATE COMMAND
DELETE COMMAND
BASIC SELECT QUERIES
Retrieve Patient Name and Address whose name contains letter 'i' .
Count number of wards whose capacity is more than 10 but less than 40
System Date
System Time
SQL AGGREGATE FUNCTIONS
1. AVG( ) :
2. COUNT( ) :
3. SUM( ) :
4. MAX( ) :
5. MIN( ) :
SQL STRING FUNCTIONS
1. LENGTH( ) :
2. CONCAT( )
3. LOWER( ) :
4. UPPER( ) :
5. SUBSTR( ) :
6. RTRIM( ) :
COMPLEX SQL QUERIES
4. List all the patients who are treated by the Doctor whose id is 1001
SELECT * FROM PATIENT WHERE PID IN (SELECT P_ID FROM TREATS
WHERE DOCID = 1001)
CONCLUSIONS
We Successfully implemented Hospital Management System using
following commands : CREATE, INSERT, ALTER, UPDATE, DROP, DELETE.
We successfully run the simple sql queries to retrieve data from the
Hospital Database using SELECT command.
CASE STUDY 2
UNIVERSITY
MANAGEMENT
SYSTEM
EXPERIMENT -6
AIM:
1. Creation of a database.
2. To implement all types of join to retrieve data from database tables.
3. To implement the Date Functions in SQL.
4. To implement the Aggregate functions in SQL.
THEORY:
SQL JOIN
A JOIN clause is used to combine rows from two or more tables, based
on a related column between them.
(INNER) JOIN: Returns records that have matching values in both tables
LEFT (OUTER) JOIN: Return all records from the left table, and the
matched records from the right table
RIGHT (OUTER) JOIN: Return all records from the right table, and the
matched records from the left table
FULL (OUTER) JOIN: Return all records when there is a match in either
left or right table
AGGREGATE FUNCTIONS : SQL aggregate functions return a single
value, calculated from values in a column.
TABLES
Entity Table :
College
Clg_Contact
Clg_Department
Student
Course
Faculty
Progress Report
Relationship Table
Teaches
1. COLLEGE
2. CLG_CONTACT
3. CLG_DEPARTMENT
4. FACULTY
5. COURSES
6. STUDENT
7. PROGRESS_REPORT
8. TEACHES
PERFORMING JOIN ON THE DEFINED UNIVERSITY DATABASE
1. List details of all the students who are alloted to some department
along with their department details (INNER JOIN)
2. List all the faculty members of the university along with the
courses id they teach , if they teach any course (LEFT JOIN)
3. List faculty id , faculty name , course id and course name for all the
faculty members and courses even if the faculty teaches no course
or course is taught by none faculty. (FULL JOIN)
SELECT FACULTY.FAC_ID, FACULTY.FAC_NAME, COURSES.COURSE_ID,
COURSES.COURSE_TITLE FROM (FACULTY FULL JOIN TEACHES ON
FACULTY.FAC_ID = TEACHES.FAC_ID) FULL JOIN COURSES ON
COURSES.COURSE_ID = TEACHES.COURSE_ID;
4. List names and id of faculty with the department name whose hod
they are, if they are. (RIGHT JOIN)
CONCLUSION :
The database for University is implemented successfully.
The implementation of INNER JOIN, OUTER JOIN (full join, right
join, left join) query to retrieve data from tables is successful
The implementation of aggregate functions on the database is
completed.
PROBLEM STATEMENT FOR HOSPITAL
MANAGEMENT SYSTEM
1. It will maintain information about all departments like dept – name,
contact number, head of department.
2. It will maintain information about the doctors like name, address,
qualification, specialisation, designation, contact number, department.
3. It will maintain information about the patients like name, sex, age, dob,
admitDate, disease, test results, address, contact number.
4. It will maintain information about the nurses like name, address,
qualification, designation, department.
5. It will maintain information about all the tests that are being done in
hospital like test_name, result, concerned patients and concerned
doctor.
6. It will maintain about all wards in each department like ward_no,
department, ward capacity.
RELATIONSHIP :
1. Department : Doctor (1:N)
2. Department : Ward (1:N)
3. Ward : Patient (1:N)
4. Doctor : Patient (1:N)
5. Test : Doctor (1:N)
6. Nurse : Patient (1:N)
PROBLEM STATEMENT FOR UNIVERSITY
MANAGEMENT SYSTEM
1) Database maintains information about all the departments of
each college in the university like name, contact no,address
2) Maintains info about all depts of each college like Department
name, contact no, Hod
3) Maintains info about all the courses being offered in each
department like course no, course title,year
4) Maintains info about all the facilities for each college like name,
designation, qualification,address, contact no
5) Maintains info about all students like name, year.contact
no,address
6) Maintains info about the progress report of students like year ,
grade, Rank
IDENTIFICATION OF ENTITIES :
1) College(college_id,college_name,contact_no,address)
2) Department(dept_id,dept_name,contact_no,hod_no)
3) Courses(course_id,course_title,year)
4) Faculty(fac_id,fac_name,designation,qualification,contact_no,a
ddress)
5) Student(std_id,std_name,year,admission_date)
6) Progress_report(report_id,year,grade,rank)
IDENTIFICATION OF RELATIONSHIPS :