Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 12 Weeks Ago, 2 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
1. For the table PATIENT (PatientID, PatientEmail, PatientAddress, PatientCity, PalientState, Physician),it is desired to know if PatientEmails are unique, i.e., there are no two patients who share the same email address, since, if this is so, PatientEmail could possibly be a candidate (alternate) key. In the following correlated subquery which was designed to see if PatientEmail are unique, fill in the SELECT and FROM in the lower query.
Â
SELECT P1.PatientEmail
FROM PATIENT P1
WHERE P1.patientEmail IN
Â
(SELECTÂ Â ________________________
 FROM      ________________________
 WHERE P1.PatientEmail = P2.PatientEmail
 AND P1.PatientID <> P2.PatientlD);
Â
Â
Â
Â
Â
2. Insurance Company A has just acquired Insurance Company B, and in Company B’s database there are two tables of interest: PEOPLE and INSURANCEPOLICY. Company A wishes to determine if Company B enforced referential integrity between its PEOPLE and INSURANCE policy tables, and wrote the SQL code below to determine if any policies In PEOPLE had policyIDs which violated referential Integrity, and, if so, the names of the people and the violating policylDs. Fill in the WHERE clause in the inner subquery.
Â
PEOPLE (PersonID, PersonName, PersonPhone, PolicylD)
INSURANCEPOLICY (PolicylD, YearIssued, Amount)
Â
SELECT PersonName, PEOPLE.PolicyID
FROM PEOPLE
WHERE PEOPLE.PolicylD NOT IN
(SELECT INSURANCEPOLICY.PolicyID
FROM INSURANCEPOLICY, PEOPLE
WHERE ________________________________);
-----------