Patient Consultation Doctor PK Pat ID 0.. PK,FK1Doc ID PK Doc ID 1..1 0..* 1..1 Pat_Name PK, FK2 Pat ID Doc_Name Pat Age Con_Date Doc_EmployDate Pat_Gender FK Prc_ID 0..* 1..1 Practice PK Pro_ID Prc_Name Prc_YearEstablished Prc_Province Write SQL statements for the following: 6.1 Create all the necessary tables. Name the tables; and all their attributes appropriately. Insert TWO records into each of the tables created to demonstrate that you have created them correctly. List all the TrueHealth practices based in Gauteng. List, in alphabetical order, the names of all patients who had consultations after 01 January 2018. Which practice (by name) has the most recent hire (i.e. doctor with latest employment date)? Which doctor has had the least number of consultations? Give the doctor's name and the number of consultation s/he has given. 6.2 6.1 6.2 6.3 6.4

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

"6.1,6.2,6.1 are answered"

Note: Since you have posted multiple sub-questions in the same request, we will solve the first three questions for you. To get the remaining questions solved, please repost other questions independently.

Database management systems store records about separate related entities and manage them efficiently. Also, they provide mechanisms to fetch those values when required. DML/DDL/DCL queries can be formed to create/destroy relations, fetch data from one or more relations, etc. 

Storing data and information using the database systems is secure and time-convenient. Relations are optimized or normalized so that no data loss or unnecessary data modification occurs in the database.

Step 2

Answer:

6.1. There are four tables in this database system Doctor, Patient, Consultation, and Practice. The tables are designed with the defined attributes as:

Syntax:

CREATE TABLE TABLE-NAME(FIELD1 TYPE, FIELD2 TYPE, ...);

CREATE TABLE Patient(Pat_ID varchar(4) primary key,
Pat_name varchar(50),
Pat_age number,
Pat_gender varchar(4));

CREATE TABLE Practice(Prc_ID varchar(4) primary key,
Prc_name varchar(50),
Prc_yearestablished number,
Prc_province varchar(20));

CREATE TABLE Doctor(Doc_ID varchar(4) primary key,
Doc_name varchar(50),
Doc_employdate date,
Prc_ID varchar(4),
FOREIGN KEY (Prc_ID) REFERENCES Practice(Prc_ID));

CREATE TABLE Consultation(Doc_ID varchar(4),
Pat_ID varchar(4),
Con_date date,
primary key(Doc_ID,Pat_ID),
FOREIGN KEY (Pat_ID) REFERENCES Patient(Pat_ID),
FOREIGN KEY (Doc_ID) REFERENCES Doctor(Doc_ID));

 Schema:

 

 

 

 

Step 3

6.2. Adding two records in each table:

For adding records, the insert query should be used.

insert into Patient values('P001','Patient1',45,'M');
insert into Patient values('P002','Patient2',32,'F');

 

insert into Practice values('Pr01','Practice1',2010,'Gauteng');
insert into Practice values('Pr02','Practice2',2015,'Luxemberg');

 

insert into Doctor values('D001','Alam',date '2018-04-01','Pr01');
insert into Doctor values('D002','Abedin',date '2021-01-20','Pr02');

 

insert into Consultation values('D001','P002',date '2020-09-20');
insert into Consultation values('D001','P001',date '2021-01-24');

 

 

Step 4

6.1. To show the TrueHealth practices in the location 'Gauteng', the select statement should be used providing the correct condition.

select * from Practice where Prc_province='Gauteng';

 

The practice records for the province "Gauteng" will be displayed. Again, you can show only the name of the practices mentioning the field name.

select Prc_name from Practice where Prc_province='Gauteng';

 

The entity relationship diagram below models the components of a database belonging to
TrueHealth, a network of medical centers. The database allows TrueHealth to keep track
of doctors at each practice and their patients.
Patient
PK Pat ID
Consultation
Doctor
PK,FK1 Doc_ID
PK Doc ID
1..1
0..
1..1
Pat_Name
PK, FK2 Pat ID
Doc_Name
Pat Age
Con_Date
Doc_EmployDate
Pat_Gender
FK Prc_ID
0..*
1..1
Practice
PK Prc ID
Prc_Name
Prc_YearEstablished
Prc_Province
Write SQL statements for the following:
Create all the necessary tables. Name the tables; and all their attributes
appropriately.
Insert TWO records into each of the tables created to demonstrate that you
have created them correctly.
List all the TrueHealth practices based in Gauteng.
List, in alphabetical order, the names of all patients who had consultations
after 01 January 2018.
Which practice (by name) has the most recent hire (i.e. doctor with latest
employment date)?
Which doctor has had the least number of consultations? Give the doctor's
name and the number of consultation s/he has given.
6.1
6.2
6.1
6.2
6.3
6.4
Transcribed Image Text:The entity relationship diagram below models the components of a database belonging to TrueHealth, a network of medical centers. The database allows TrueHealth to keep track of doctors at each practice and their patients. Patient PK Pat ID Consultation Doctor PK,FK1 Doc_ID PK Doc ID 1..1 0.. 1..1 Pat_Name PK, FK2 Pat ID Doc_Name Pat Age Con_Date Doc_EmployDate Pat_Gender FK Prc_ID 0..* 1..1 Practice PK Prc ID Prc_Name Prc_YearEstablished Prc_Province Write SQL statements for the following: Create all the necessary tables. Name the tables; and all their attributes appropriately. Insert TWO records into each of the tables created to demonstrate that you have created them correctly. List all the TrueHealth practices based in Gauteng. List, in alphabetical order, the names of all patients who had consultations after 01 January 2018. Which practice (by name) has the most recent hire (i.e. doctor with latest employment date)? Which doctor has had the least number of consultations? Give the doctor's name and the number of consultation s/he has given. 6.1 6.2 6.1 6.2 6.3 6.4
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY