SlideShare a Scribd company logo
1 of 5
NAME:
MUHAMMAD BAQAR KAZMI
ROLL NO’s:
16094119-055
SUBJECT:
Data Base Management System
SUBMISSION DATE:
15JUNE 2018
Patient
ID
Patient
Name
Address Appointment
Date
Doctor Dieses Fee Room Test
P-1 Sarfraz
Ahmad
13-B Shadman
Colony Gujrat
10-12-2017 Dr. Imran Blood
Pressure
1000 110 Blood Sugar
12-08-2017 Dr. Nasir Fever 850 115 ERCCI
05-04-2017 Dr. Imran Anxiety 110 ABL Mutation
01-02-2017 Dr.
Shahid
Blood
Pressure
1000 120 Blood Sugar
P-2 Shahid 7-A Marghzar
Colony Gujrat
10-12-2017 Dr. Nasir Fever 850 115 Blood Sugar
09-10-2017 Dr. Imran Anxiety 110 ERCCI
02-08-2017 Dr.
Shahid
Blood
Pressure
1000 120 ABL Mutation
1st
NORMAL FORM
P_ID P_Name Address Appointment
_Date
Doctor Dieses Fee Room_
no
Test
p-1 Sarfraz
Ahmad
13-B
Shadman
Colony
Gujrat
10-12-2017 Dr. Imran Blood
Pressure
1000 110 Blood
Sugar
p-1 Sarfraz
Ahmad
13-B
Shadman
Colony
Gujrat
12-08-2017 Dr. Nasir Fever 850 115 ERCCI
p-1 Sarfraz
Ahmad
13-B
Shadman
Colony
Gujrat
05-04-2017 Dr. Imran Anxiety 110 ABL
Mutation
p-1 Sarfraz
Ahmad
13-B
Shadman
Colony
Gujrat
01-02-2017 Dr.
Shahid
Blood
Pressure
1000 120 Blood
Sugar
p-2 Shahid 7-A
Marghzar
Colony
Gujrat
10-12-2017 Dr. Nasir Fever 850 115 Blood
Sugar
p-2 Shahid 7-A
Marghzar
Colony
Gujrat
09-10-2017 Dr. Imran Anxiety 110 ERCCI
p-2 Shahid 7-A
Marghzar
Colony
Gujrat
02-08-2017 Dr.
Shahid
Blood
Pressure
1000 120 ABL
Mutation
2nd
NORMAL FORM
P_ID P_Name Address
p-1 Sarfraz
Ahmad
13-B
Shadman
Colony
Gujrat
p-2 Shahid 7-A
Marghzar
Colony
Gujrat
Appointment
_ID
Appointment
_Date
Doctor Dieses Fee Room_
no
Test P_ID
1 10-12-2017 Dr. Imran Blood
Pressure
1000 110 Blood
Sugar
p-1
2 12-08-2017 Dr. Nasir Fever 850 115 ERCCI p-1
3 05-04-2017 Dr. Imran Anxiety 110 ABL
Mutation
p-1
4 01-02-2017 Dr.
Shahid
Blood
Pressure
1000 120 Blood
Sugar
p-1
5 10-12-2017 Dr. Nasir Fever 850 115 Blood
Sugar
p-2
6 09-10-2017 Dr. Imran Anxiety 110 ERCCI p-2
7 02-08-2017 Dr.
Shahid
Blood
Pressure
1000 120 ABL
Mutation
p-2
3rd
NORMAL FORM
P_ID P_Name Address
p-1 Sarfraz
Ahmad
13-B
Shadman
Colony
Gujrat
p-2 Shahid 7-A
Marghzar
Colony
Gujrat
Doctor Doctor Room_no
ID Name
1 Dr. Imran 110
2 Dr. Nasir 115
3 Dr. Shahid 120
Dieses
ID
Dieses
Name
Fee
1 Blood
Pressure
1000
2 Fever 850
3 Anxiety 1000
Test ID Test
1 Blood
Sugar
2 ERCCI
3 ABL
Mutation
Q: Write Structure Query Language (SQL) queries for following question according to the
table obtained in 1NF. (Table’s name: Patient_Information).
1. Count total number of patient who are treated in the clinic.
2. Display only patientID, name and address for each patient. Record for each patient
shouldn’t be displayed more than once.
3. Display patient information for those patients who are treated as FREE. Patient
information should consist of patient’s tests and doctor.
4. Display the dieses having name started from “A” and treated as FREE.
5. Display the diagnosis’s names in descending order. Moreover show treatment facility for
each diagnosis, either it is free or paid.
6. Change the test of “ECCI” to “X-Rays”.
7. Insert a new record of Patient ID=P-3, Patient Name=Rizwan, Address=15-G, Gulberg,
Islamabad, Appointment Date=22-12-2017, Doctor=Dr.Imran, Dieses =Bone Fracture,
treatment=5000, room=130, test=X-Ray.
8. Add another column into table, named as dateOfBirth and data type as date.
9. Delete record of patient who paid maximum Fee.
10. Show information about patient ID=P-1 where he treated free.
SOLUTION:
1: select count(distinct P_ID) from Patient_Information;
2: Select distinct P_ID, P_Name, Address from Patient_Information;
3: Select Doctor, Test from Patient_Information where fee is NULL;
4: Select Dieses from Patient_Information where fee is NULL and Dieses like ‘A%’;
5: Select Doctor, Test, Room, Dieses from Patient_ Information order by Dieses desc;
6: Select Update Patient_ Information set Test=’X-Rays’ where Test = ‘ECCI’;
7: Insert into Patient_Information (P_ID,P_Name, Address , Appointment_Date, Doctor,
Dieses, treatment, room, Test) values ( p-3, Rizwan, 15-G, GulbergIslamabad, 22-12-
2017, Dr.Imran, Bone Fracture, 5000, 130, X-Ray);
8: Alter table patient_ Information add (Dob date);
9: Delete from Patient_Information where fee in(select max(fee) from Patient_Information);
10: select * from Patient_Information where P_ID=P-1 and fee is NULL;

More Related Content

Recently uploaded

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 

Recently uploaded (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Data base management system

  • 1. NAME: MUHAMMAD BAQAR KAZMI ROLL NO’s: 16094119-055 SUBJECT: Data Base Management System SUBMISSION DATE: 15JUNE 2018
  • 2. Patient ID Patient Name Address Appointment Date Doctor Dieses Fee Room Test P-1 Sarfraz Ahmad 13-B Shadman Colony Gujrat 10-12-2017 Dr. Imran Blood Pressure 1000 110 Blood Sugar 12-08-2017 Dr. Nasir Fever 850 115 ERCCI 05-04-2017 Dr. Imran Anxiety 110 ABL Mutation 01-02-2017 Dr. Shahid Blood Pressure 1000 120 Blood Sugar P-2 Shahid 7-A Marghzar Colony Gujrat 10-12-2017 Dr. Nasir Fever 850 115 Blood Sugar 09-10-2017 Dr. Imran Anxiety 110 ERCCI 02-08-2017 Dr. Shahid Blood Pressure 1000 120 ABL Mutation 1st NORMAL FORM P_ID P_Name Address Appointment _Date Doctor Dieses Fee Room_ no Test p-1 Sarfraz Ahmad 13-B Shadman Colony Gujrat 10-12-2017 Dr. Imran Blood Pressure 1000 110 Blood Sugar p-1 Sarfraz Ahmad 13-B Shadman Colony Gujrat 12-08-2017 Dr. Nasir Fever 850 115 ERCCI p-1 Sarfraz Ahmad 13-B Shadman Colony Gujrat 05-04-2017 Dr. Imran Anxiety 110 ABL Mutation p-1 Sarfraz Ahmad 13-B Shadman Colony Gujrat 01-02-2017 Dr. Shahid Blood Pressure 1000 120 Blood Sugar p-2 Shahid 7-A Marghzar Colony Gujrat 10-12-2017 Dr. Nasir Fever 850 115 Blood Sugar p-2 Shahid 7-A Marghzar Colony Gujrat 09-10-2017 Dr. Imran Anxiety 110 ERCCI p-2 Shahid 7-A Marghzar Colony Gujrat 02-08-2017 Dr. Shahid Blood Pressure 1000 120 ABL Mutation
  • 3. 2nd NORMAL FORM P_ID P_Name Address p-1 Sarfraz Ahmad 13-B Shadman Colony Gujrat p-2 Shahid 7-A Marghzar Colony Gujrat Appointment _ID Appointment _Date Doctor Dieses Fee Room_ no Test P_ID 1 10-12-2017 Dr. Imran Blood Pressure 1000 110 Blood Sugar p-1 2 12-08-2017 Dr. Nasir Fever 850 115 ERCCI p-1 3 05-04-2017 Dr. Imran Anxiety 110 ABL Mutation p-1 4 01-02-2017 Dr. Shahid Blood Pressure 1000 120 Blood Sugar p-1 5 10-12-2017 Dr. Nasir Fever 850 115 Blood Sugar p-2 6 09-10-2017 Dr. Imran Anxiety 110 ERCCI p-2 7 02-08-2017 Dr. Shahid Blood Pressure 1000 120 ABL Mutation p-2 3rd NORMAL FORM P_ID P_Name Address p-1 Sarfraz Ahmad 13-B Shadman Colony Gujrat p-2 Shahid 7-A Marghzar Colony Gujrat Doctor Doctor Room_no
  • 4. ID Name 1 Dr. Imran 110 2 Dr. Nasir 115 3 Dr. Shahid 120 Dieses ID Dieses Name Fee 1 Blood Pressure 1000 2 Fever 850 3 Anxiety 1000 Test ID Test 1 Blood Sugar 2 ERCCI 3 ABL Mutation Q: Write Structure Query Language (SQL) queries for following question according to the table obtained in 1NF. (Table’s name: Patient_Information). 1. Count total number of patient who are treated in the clinic. 2. Display only patientID, name and address for each patient. Record for each patient shouldn’t be displayed more than once. 3. Display patient information for those patients who are treated as FREE. Patient information should consist of patient’s tests and doctor. 4. Display the dieses having name started from “A” and treated as FREE. 5. Display the diagnosis’s names in descending order. Moreover show treatment facility for each diagnosis, either it is free or paid. 6. Change the test of “ECCI” to “X-Rays”. 7. Insert a new record of Patient ID=P-3, Patient Name=Rizwan, Address=15-G, Gulberg, Islamabad, Appointment Date=22-12-2017, Doctor=Dr.Imran, Dieses =Bone Fracture, treatment=5000, room=130, test=X-Ray. 8. Add another column into table, named as dateOfBirth and data type as date. 9. Delete record of patient who paid maximum Fee. 10. Show information about patient ID=P-1 where he treated free.
  • 5. SOLUTION: 1: select count(distinct P_ID) from Patient_Information; 2: Select distinct P_ID, P_Name, Address from Patient_Information; 3: Select Doctor, Test from Patient_Information where fee is NULL; 4: Select Dieses from Patient_Information where fee is NULL and Dieses like ‘A%’; 5: Select Doctor, Test, Room, Dieses from Patient_ Information order by Dieses desc; 6: Select Update Patient_ Information set Test=’X-Rays’ where Test = ‘ECCI’; 7: Insert into Patient_Information (P_ID,P_Name, Address , Appointment_Date, Doctor, Dieses, treatment, room, Test) values ( p-3, Rizwan, 15-G, GulbergIslamabad, 22-12- 2017, Dr.Imran, Bone Fracture, 5000, 130, X-Ray); 8: Alter table patient_ Information add (Dob date); 9: Delete from Patient_Information where fee in(select max(fee) from Patient_Information); 10: select * from Patient_Information where P_ID=P-1 and fee is NULL;