ses( address_id varchar2(10) not null constraint addresses_pk primary key, city varchar2(20) not null, state varchar2(20) not null, country varchar2(20) not null, note varchar2(50) ); create table Doctors(

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
  1. List the name of doctors with the number of written prescriptions.
  2. List the customers and the number of prescriptions each has.
  3. List the most prescribed medicines in the ascending order.
  4. . What is the name of mostly prescribed medicine?

 

create table Addresses(
address_id varchar2(10) not null constraint addresses_pk primary key,
city varchar2(20) not null,
state varchar2(20) not null,
country varchar2(20) not null,
note varchar2(50)
);

create table Doctors(
doctor_id varchar2(10) not null constraint doctor_pk primary key,
address_id varchar2(10) not null,
first_name varchar2(20) not null,
last_name varchar2(20) not null,
phone varchar2(20),
email varchar2(20),
note varchar2(50),
constraint doctor_fk foreign key (address_id) references Addresses(address_id)
);

create table Customers(
customer_id varchar2(10) not null constraint customer_id primary key,
address_id varchar2(10) not null,
first_name varchar2(20) not null,
last_name varchar2(20) not null,
phone varchar2(10),
note varchar2(50),
constraint customer_fk foreign key (address_id) references Addresses(address_id)
);

create table Payment(
payment_method_id varchar2(10) not null constraint paymentmethod_pk primary key,
payment_name varchar2(10) not null,
note varchar2(50)
);

create table Prescription(
prescription_id varchar2(10) not null constraint prescription_pk primary key,
customer_id varchar2(10) not null,
doctor_id varchar2(10) not null,
payment_method_id varchar2(10) not null,
p_date date not null,
note varchar2(50),
constraint prescription_fk foreign key (customer_id) references Customers(customer_id),
constraint prescription1_fk foreign key (doctor_id) references Doctors(doctor_id),
constraint prescription2_fk foreign key (payment_method_id) references Payment(payment_method_id)
);

create table Medication(
medication_id varchar2(10) not null constraint medication_pk primary key,
medication_code varchar2(10) not null,
medication_name varchar2(10) not null,
medication_cost varchar2(10) not null,
note varchar2(50)
);

create table Prescription_items(
prescription_id varchar2(10) not null,
medication_id varchar2(10) not null,
quantity varchar2(10) not null,
note varchar2(50),
constraint prescriptionitems_fk foreign key (prescription_id) references Prescription(prescription_id),
constraint prescriptionitems1_fk foreign key (medication_id) references Medication(medication_id)
);

Customers (patients)
customer id
PK
Addresses
Doctors
address id
FK
address_id
PK
doctor id
PK
first_name
city
address_id
FK
last name
state
first _name
phone
country
last_name
note
note
phone
email
note
Prescription
prescription_id
PK
customer_id
EK
doctor_id
FK
Рayment
payment_method_id
FK
peyment_method_id
PK
date
payment_name
note
note
Prescription_items
Medication
prescription_id
medication_id
FK
medication_id
PK
FK
medication code
quantity
medication_name
note
medication_cost
note
Transcribed Image Text:Customers (patients) customer id PK Addresses Doctors address id FK address_id PK doctor id PK first_name city address_id FK last name state first _name phone country last_name note note phone email note Prescription prescription_id PK customer_id EK doctor_id FK Рayment payment_method_id FK peyment_method_id PK date payment_name note note Prescription_items Medication prescription_id medication_id FK medication_id PK FK medication code quantity medication_name note medication_cost note
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
SQL Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education