SQL Lab Task: Medical Database
Scenario: A hospital stores patient, doctor, appointment, and prescription information. Schema
Patients(patient_id PK, name, age, gender, city)
Doctors(doctor_id PK, name, specialty)
Appointments(app_id PK, patient_id FK, doctor_id FK, app_date, status)
Prescriptions(rx_id PK, app_id FK, medicine, dosage) Tasks Create all four tables with appropriate
primary and foreign keys. Insert at least 5 records into each table. Display all patients older than 40.
Find all doctors whose specialty is 'Cardiology'. Show appointments with patient and doctor names
using JOIN. Count appointments for each doctor. List patients who have never booked an
appointment. Update the status of a selected appointment to 'Completed'. Delete a prescription by
rx_id. Create a view named ActiveAppointments showing appointments with status='Scheduled'.
Write a query to display the most prescribed medicine. Bonus: Create a stored procedure or trigger
(if supported by your DBMS). Submission: Submit SQL script, screenshots of query outputs, and a
brief explanation (1–2 pages).