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

Day3 Exercise - Healthcare

The document outlines a healthcare database structure including tables for doctors, patients, and cases, detailing their attributes and relationships. It also includes a series of queries to extract specific information from the database, such as patient admissions and doctor specialties. Additionally, it provides SQL commands for creating the tables and inserting sample data into them.

Uploaded by

Prasad Deshpande
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)
14 views4 pages

Day3 Exercise - Healthcare

The document outlines a healthcare database structure including tables for doctors, patients, and cases, detailing their attributes and relationships. It also includes a series of queries to extract specific information from the database, such as patient admissions and doctor specialties. Additionally, it provides SQL commands for creating the tables and inserting sample data into them.

Uploaded by

Prasad Deshpande
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

Healthcare – (Hospital)

Doctor table

Doc_id fname Lname speciality phone


D1 arun Patel ortho 9675093453
D2 tim Patil general 9674560453
D3 abhay sharma heart 9675993453

Patient

Pat_id Fname lname Insurance_comp phone


P1 Akul shankar Y 9148752347
P2 aman shetty Y 9512896317
P3 Ajay shetty N 9987321564
P4 akshay pandit Y 9112255889
P5 Adi shankar N 9177788821

Case

Admission_date Pat_id Doc_id diagnosis


10-jun-16 P1 D1 fracture
03-may-16 P2 D1 Bone cancer
17-apr-16 P2 D2 Fever
28-oct-15 P3 D2 Cough
10-jun-16 P3 D1 fracture
1-jan-16 P3 D1 bone cramp
11-sep-15 P3 D3 Heart attack
30-nov-15 P4 D3 Heart hole
10-nov-15 P4 D3 angioplasty
1-jan-16 P5 D3 angiogram
Doctor Table

Column Data type and constraints


doc_id Char(9), PRIMARY KEY
Fname Char(20)
Lname Char(25)
specialty Char(25)
Phone Char(10)

Patient table

Column Data type and constraints


pat_id Char(9), PRIMARY KEY
Fname Char(20)
Lname Char(25)
insurance_company Char(25),
Phone Char(10)

Case table

Column Data type and constraints


admission_date Datetime, PRIMARY KEY (composite)
pat_id Char(9), PRIMARY KEY (composite), FOREIGN KEY to patient.pat_id
Doc_id Char(9), FOREIGN KEY to doctor.doc_id
Diagnosis Varchar(150)

1. Find all the patients who are treated in the first week of this month.
2. Find all the doctors who have more than 3 admissions today
3. Find the patient name (first,last) who got admitted today where the doctor is ‘TIM’
4. Find the Doctors whose phone numbers were not update (phone number is null)
5. Display the doctors whose specialty is same as Doctor ‘TIM’
6. Find out the number of cases monthly wise for the current year
7. Display the doctors who don’t have any cases registered this week
8. Display Doctor Name, Patient Name, Diagnosis for all the admissions which happened on 1st of
Jan this year
9. Display Doctor Name, patient count based on the cases registered in the hospital.
10. Display the Patient_name, phone, insurance company, insurance code (first 3 characters of
insurance company)
11. Create a view which gives the doctors whose specialty is ‘ORTHO’ and call it as ortho_doctors

HealthCare

create table doctor


(doc_id varchar2(4) primary key,
fname varchar2(20),
lname varchar2(20),
specialty varchar2(20),
phone number(10)
);

create table patient


(pat_id varchar2(4) primary key,
fname varchar2(20),
lname varchar2(20),
ins_comp varchar2(20),
phone number(10)
);

create table case


(admission_date date,
pat_id varchar2(4) references patient(pat_id),
doc_id varchar2(4) references doctor(doc_id),
diagnosis varchar2(40),
constraint con_cpk primary key(admission_date,pat_id)
);

insert all
into doctor values('d1','arun','patel','ortho',9675093453)
into doctor values('d2','tim','patil','general',9674560453)
into doctor values('d3','abhay','sharma','heart',9675993453)
select * from dual;

insert all
into patient values('p1','akul','shankar','y',9148752347)
into patient values('p2','aman','shetty','y',9512896317)
into patient values('p3','ajay','shetty','n',9987321564)
into patient values('p4','akshay','pandit','y',9112255889)
into patient values('p5','adi','shankar','n',9177788821)
select * from dual;

insert all
into case values('10-jun-16','p1','d1','fracture')
into case values('03-may-16','p2','d1','bone cancer')
into case values('17-apr-16','p2','d2','fever')
into case values('28-oct-15','p3','d2','cough')
into case values('10-jun-16','p3','d1','fracture')
into case values('1-jan-16','p3','d1','bone cramp')
into case values('11-sep-15','p3','d3','heart attack')
into case values('30-nov-15','p4','d3','heart hole')
into case values('10-nov-15','p4','d3','angioplasty')
into case values('1-jan-16','p5,'d3','angiogram')
select * from dual;

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