A pharmacy database tracks prescriptions written by doctors and purchased by patients at pharmacy locations. A prescription is written by a doctor for one or more drugs for exactly one patient. The prescription also specifies the pharmacy where the prescription is to be filled. The doctors identifier is called the National Provider Identifier (NPI). Every drug is identified by a National Drug Code (NDC). A prescription contains the following information. The NPI, NDC, date the prescription was written, and the patients identifier. Write a qeury that shows the prescription number, patient's name, the brand name for the drug, dosage, doctor's city for all prescriptions filled by a doctor whose NPI IS AT20030040 and written on or after January 1, 2022.  The database tables are designed as shown below. You do not need to create the database to answer this question but you might if you want to visualize the connections. CREATE TABLE DRUG ( NDC VARCHAR(20) NOT NULL, DRUG_BRAND_NAME VARCHAR(25) NOT NULL, DRUG_GENERIC_NAME VARCHAR(25) NOT NULL, PACKAGE_SIZE INT NOT NULL, DOSAGE VARCHAR(50), CONSTRAINT D_PK PRIMARY KEY (NDC)); CREATE TABLE PATIENT ( PATIENT_NUMBER VARCHAR(25) NOT NULL, FIRST_NAME VARCHAR(25) NOT NULL, LAST_NAME VARCHAR(25) NOT NULL, GENDER_CODE VARCHAR(2) NOT NULL, DATE_OF_BIRTH DATE NOT NULL, ADDRESS1 VARCHAR(100), ADDRESS2 VARCHAR(100), CITY VARCHAR(25), STATE VARCHAR(25), ZIP_CODE VARCHAR(25), CONSTRAINT PA_PK PRIMARY KEY (PATIENT_NUMBER)); CREATE TABLE DOCTOR ( NPI INT NOT NULL, FIRST_NAME VARCHAR(25) NOT NULL, LAST_NAME VARCHAR(25) NOT NULL, ADDRESS1 VARCHAR(100), ADDRESS2 VARCHAR(100), CITY VARCHAR(25), STATE VARCHAR(25), ZIP_CODE VARCHAR(25), PHONE_NUMBER VARCHAR(25) NOT NULL, FAX_NUMBER VARCHAR(25) NOT NULL, CONSTRAINT DO_PK PRIMARY KEY (NPI)); CREATE TABLE PRESCRIPTION ( PRESCRIPTION_NO INT NOT NULL, NPI VARCHAR(25) NOT NULL, PATIENT_NO VARCHAR(25) NOT NULL, NDC VARCHAR(20) NOT NULL, DATE_WRITTEN DATE NOT NULL, PHARMACY_ID INT NOT NULL, CONSTRAINT P_PK PRIMARY KEY (PRESCRIPTION_NO), CONSTRAINT P_PA_FK FOREIGN KEY (PATIENT_NO) REFERENCES PATIENT (PATIENT_NUMBER), CONSTRAINT P_DO_FK FOREIGN KEY (NPI) REFERENCES DOCTOR (NPI), CONSTRAINT P_DR_FK FOREIGN KEY (NDC) REFERENCES DRUG (NDC));

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

A pharmacy database tracks prescriptions written by doctors and purchased by patients at pharmacy locations. A prescription is written by a doctor for one or more drugs for exactly one patient. The prescription also specifies the pharmacy where the prescription is to be filled. The doctors identifier is called the National Provider Identifier (NPI). Every drug is identified by a National Drug Code (NDC). A prescription contains the following information. The NPI, NDC, date the prescription was written, and the patients identifier.

Write a qeury that shows the prescription number, patient's name, the brand name for the drug, dosage, doctor's city for all prescriptions filled by a doctor whose NPI IS AT20030040 and written on or after January 1, 2022. 

The database tables are designed as shown below. You do not need to create the database to answer this question but you might if you want to visualize the connections.

CREATE TABLE DRUG (
NDC VARCHAR(20) NOT NULL,
DRUG_BRAND_NAME VARCHAR(25) NOT NULL,
DRUG_GENERIC_NAME VARCHAR(25) NOT NULL,
PACKAGE_SIZE INT NOT NULL,
DOSAGE VARCHAR(50),
CONSTRAINT D_PK PRIMARY KEY (NDC));

CREATE TABLE PATIENT (
PATIENT_NUMBER VARCHAR(25) NOT NULL,
FIRST_NAME VARCHAR(25) NOT NULL,
LAST_NAME VARCHAR(25) NOT NULL,
GENDER_CODE VARCHAR(2) NOT NULL,
DATE_OF_BIRTH DATE NOT NULL,
ADDRESS1 VARCHAR(100),
ADDRESS2 VARCHAR(100),
CITY VARCHAR(25),
STATE VARCHAR(25),
ZIP_CODE VARCHAR(25),
CONSTRAINT PA_PK PRIMARY KEY (PATIENT_NUMBER));


CREATE TABLE DOCTOR (
NPI INT NOT NULL,
FIRST_NAME VARCHAR(25) NOT NULL,
LAST_NAME VARCHAR(25) NOT NULL,
ADDRESS1 VARCHAR(100),
ADDRESS2 VARCHAR(100),
CITY VARCHAR(25),
STATE VARCHAR(25),
ZIP_CODE VARCHAR(25),
PHONE_NUMBER VARCHAR(25) NOT NULL,
FAX_NUMBER VARCHAR(25) NOT NULL,
CONSTRAINT DO_PK PRIMARY KEY (NPI));


CREATE TABLE PRESCRIPTION (
PRESCRIPTION_NO INT NOT NULL,
NPI VARCHAR(25) NOT NULL,
PATIENT_NO VARCHAR(25) NOT NULL,
NDC VARCHAR(20) NOT NULL,
DATE_WRITTEN DATE NOT NULL,
PHARMACY_ID INT NOT NULL,
CONSTRAINT P_PK PRIMARY KEY (PRESCRIPTION_NO),
CONSTRAINT P_PA_FK FOREIGN KEY (PATIENT_NO) REFERENCES PATIENT (PATIENT_NUMBER),
CONSTRAINT P_DO_FK FOREIGN KEY (NPI) REFERENCES DOCTOR (NPI),
CONSTRAINT P_DR_FK FOREIGN KEY (NDC) REFERENCES DRUG (NDC));

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Types of Database Architectures
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
  • SEE MORE 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