Question: Section 1 Using SQL , create tables according to the given schema shown in Figure 1 . Note that this section is exactly the same
Section
Using SQL create tables according to the given schema shown in Figure Note that this
section is exactly the same as the one in Assignment You can use your Assignment
directly, or modify your Assignment if needed
doctor dssn dname, specialty
prescriptiondssn preno pdate foreign key dssn references to doctordssn
phcompanypname phone
drug pname trade name, formula foreign key pname references to
phcompanypname
consistof dssn preno pname, tradename foreign key dssn preno references
prescriptiondssn preno foreign key pname tradename references drugpanme
tradename
pharmacy pcy name, address, phone
sell pharmacyname, pname, tradename, price foreign key pname tradename
references drug pname tradename foreign key pharmacyname references
pharmacypcyname
Figure Schema Figure ER Diagram
Section
Populate the database. Please check sections for details.
Section
Use SQL to specify the following queries. When you populate the database, insert data such that at least two rows will be display as the result of running each query. Retrieve the drugs' information trade name and formula which are manufactured by company "Pfizer". Order the result by trade name in descending order.
List drug information Pharmaceutical company name, trade name, formula that has been prescribed by at least one doctor.
Obtain all the prescription drugs trade name, company name and prescription date given by Doctor "Kate Elmasri".
Retrieve all the drugs tradename, formula sold by "Walmart". Walmart is pharmacy name
Retrieve number of type of drugs made by "Pfizer". Type is distinguished by "tradename"
Obtain information pharmacy name, address of pharmacy that sells "Ibuprofen" with the highest price among all pharmacies. Ibuprofen is a trade name
Retrieve the pharmacies that sell more than types of drugs. List pharmacy name and number of types of drugs sold. Type is distinguished by "tradename". However, if two drugs with the same trade name are produced by two different pharmaceutical companies, they are considered as two different types of drugs.
Section
Specify the statements to drop all the tables. Pay attention to the order of the drop statements in order to drop everything successfully. Note that this section is exactly the same as the one in Assignment You can use your assignment directly, or modify your assignment if needed
Submission
Submit the following files to Canvas. Do NOT zip them. Please double check that you submit a correct version and your submission status is "submitted".
You must test that the create, insert, drop statements and queries can be executed
successfully before your submission.
Create table statements file name must be: createtable.txt
I will copy everything from this file and execute it Make sure the tables are
listed in the correct order such that I can execute it without any error. For any table that cannot be created, you will lose points, even if the error caused by the incorrect order of creating table. You should have already handled this task in Assignment
You must submit a file DDLscreenshot.pdf to prove that you have ran your create table statements, insert tuples, and the operations were successful. You can reuse the create table part of the screenshots of your Assignment but you have to include it in this DDLscreenshot.pdf file. I still need to run your create table statements to do grading. A demo using your Canvas files may be scheduled if there is any grading disagreement.
Insert statements to populate database file name must be: populatedbtxt will be given to each nonexecutable insert statement
Queries file name must be: query.txt
Note that if the create table statements do not work properly, your query may not be executable even it is correct.
point will be given to each nonexecutable query, even if the query is specified correctly, but cannot be executed because of incorrect create table statements.
Statements to drop all tables file name must be: dropall.txt will be given to each nonexecutable drop statement.
An output file showing query results file name must be: output.pdf In this file, for each query, you must:
a Include the number and query description eg Query : Retrieve the drugs' information
b Your SQL query eg select... from...
c The result of running this query screen shots
Note: and can be the same as the ones that you submitted for Assignment
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
