-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab4review.txt
75 lines (51 loc) · 2.18 KB
/
lab4review.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
9 pts
Correct queries
Correct SQL statements
Correct output for some queries
SQL statements are somewhat readable
Recommendations:
To improve your readability, write queries instead of this
Select Distinct pid
From orders
Where aid in (Select aid
From orders
Where cid in (Select cid
From customers
Where city='Dallas'))
Order By pid Desc;
do it like this:
SELECT DISTINCT pid
FROM orders
WHERE aid IN (SELECT aid
FROM orders
WHERE cid IN (SELECT cid
FROM customers
WHERE city = 'Dallas'))
ORDER BY pid DESC; -- < notice the correct indentation here
2. Get the ids of products ordered through any agent who takes at least one
order from a customer in Dallas, sorted by pid from highest to lowest. (This is
not the same as asking for ids of products ordered by customers in Dallas.)
Query is hard to read. Please format your query for better reading.
- The ORDER BY is incorrectly indented
- Please correctly indent all your subqueries.
3. Get the ids and names of customers who did not place an order through agent
a01.
Incorrect output
- You are giving an additional rows incorrectly.
5. Get the ids of products not ordered by any customers who placed any order
through agent a07 in pid order from highest to lowest.
Query is hard to read. Please format your query for better reading.
- The ORDER BY is incorrectly indented
8. Tell me about check constraints: What are they? What are they good for? What
is the advantage of putting that sort of thing inside the database? Make up
some examples of good uses of check constraints and some examples of bad uses
of check constraints. Explain the differences in your examples and argue your
case.
- You did not include -actual- check constraints examples, just descriptions of
them.
In general:
- Test all your SQL statements.
- Make sure you read all the instructions for queries really well.
- PLEASE only include your queries for this lab! You included other stuff at
the end. I am a bit upset about that.
- Dr. Rivas