Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 3 Practical computer work: The answer to this question should be submitted electronically. ( Marks: 6 5 ) Using MySQL , create a single
Question
Practical computer work: The answer to this question should be submitted electronically.
Marks:
Using MySQL create a single Structured Query Language SQL script that answers all the questions below. Include comments to indicate which part of the script answers which question.
The script must execute correctly using MySQL to get full marks.
Consider the following extract from an Entity Relationship Diagram ERD before answering questions to :
Patient
PatientID PK
PatientName
PatientSurname
PatientDOB
Doctor
DoctorID PK
DoctorName
DoctorSurname
Appointment
AppointmentID PK
PatientID FK
DoctorID FK
AppointmentDate AppointmentTime
AppointmentDuration
Q
Q
Q
Q
Write an SQL statement to create the Patient table.
Write an SQL statement to create the Doctor table.
Write an SQL statement to create the Appointments table.
Write SQL statements to insert the following data:
Table: Patient
Patient ID
Patient Name
Patient Surname
Date of Birth
Debbie
Theart
Thomas
Duncan
Table: Doctor
Table: Appointments
Doctor ID
Doctor Name
Doctor Surname
Zintle
Nukani
Ravi
Maharaj
Appointment
ID
Appointment
Doctor
ID
Patient
ID
Date
Time
Duration
:
:
:
:
Q
Q
Write an SQL statement to display all the appointments between and inclusive
Write a SQL statement to display the names and surnames of patients with the total number of appointments they have. Sort the results in descending order based on the number of appointments.
Q
Write an SQL statement to display all the appointments. The statement should display the appointment date in descending order the time, the doctor's name and surname, and the patient's name and surname.
Q
Create a view that gets a list of all the patients that have appointments with the doctor with Doctor ID Include just the name and surname of the patients in the result and sort results in ascending alphabetical order according toCreate a stored procedure called get appointments. It should take the date of an appointment as input and display all the appointment details for that date.
Display the time in ascending order duration, doctor name and surname, as well as patient name and surname
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started