A particular query can have several formulations, and a query optimizer may produce di?erent query plans with di?erent costs for each.
a. Assume that the Computer Science Department teaches only three 100-level courses:
CS110, CS113, and CS114. Write an SQL statement whose result set contains the course codes of all courses that have these as prerequisites in three ways: using OR, UNION, and a nested subquery involving LIKE.
b. Write an SQL statement whose result set contains the names of all computer science courses that are prerequisites to other courses in three ways: using a join, a nested subquery involving EXISTS, and a nested subquery involving IN.
a. ```
SELECT R.CrsCode
FROM Requires R
WHERE R.PrereqCrsCode = ’CS110’ OR
R.PrereqCrsCode = ’CS113’
R.PrereqCrsCode = ’CS114’
```
```
SELECT R.CrsCode
FROM Requires R
WHERE R.PrereqCrsCode = ’CS110’
UNION
SELECT R.CrsCode
FROM Requires R
WHERE R.PrereqCrsCode = ’CS113’
UNION
SELECT R.CrsCode
FROM Requires R
WHERE R.PrereqCrsCode = ’CS114’
```
```
SELECT R.CrsCode
FROM Requires R
WHERE R.PrereqCrsCode LIKE ’CS1%’
```
b. ```
SELECT C.CrsName
FROM Course C, Requires R
WHERE C.CrsCode = R.PrereqCrsCode
```
```
SELECT C.CrsName
FROM Course C
WHERE EXISTS (
SELECT *
FROM Requires R
WHERE C.CrsCode = R.PrereqCrsCode)
```
```
SELECT C.CrsName
FROM Course C
WHERE C.CrsCode IN (
SELECT R.PrereqCrsCode
FROM Requires R)
```
You might also like to view...
A program event is triggered when the user presses a keyboard key.
Answer the following statement true (T) or false (F)
What does the conversion rate of a web site measure? Give an example of “taking action” on an e-commerce site. What would be an example of taking action on a college admissions web site? Many students who are seeking employment will post their rŽsumŽs on their personal web sites. What would be an example of taking action in this case?
What will be an ideal response?
_____________ virtual devices are a software implementation of typical PCI devices.
Fill in the blank(s) with the appropriate word(s).
The width of a table column can be changed manually or by using the ________ command
A) AutoFit Contents B) AutoCorrect C) Cell Margins D) AutoFormat