Lab Assignment-9: Consider The Following Tables: Table Student
Lab Assignment-9: Consider The Following Tables: Table Student
Table Student:
+------+---------+---------+-------+------+
| snum | sname | major | level | age |
+------+---------+---------+-------+------+
| 101 | Jhon | CS | SR | 19 |
| 102 | Smith | CS | JR | 20 |
| 103 | Jacob | ECE | SR | 20 |
| 104 | Tom | CS | JR | 20 |
| 105 | Sid | CS | JR | 20 |
| 106 | Harry | History | SR | 21 |
| 107 | Hellen | CS | JR | 21 |
| 108 | Bob | English | SR | 22 |
| 109 | Andy | ECE | JR | 21 |
| 110 | Charles | History | SR | 23 |
+------+---------+---------+-------+------+
Table Class:
+--------+----------+------+------+
| cname | meets_at | room | fid |
+--------+----------+------+------+
| CSC342 | Morning | R128 | 201 |
| CSC343 | Noon | R128 | 203 |
| CSC345 | Night | R154 | 204 |
| ECE300 | Morning | R111 | 202 |
| ECE301 | Noon | R111 | 203 |
| ENG366 | Morning | R154 | 203 |
| ENG367 | Evening | R111 | 205 |
| HIS320 | Evening | R128 | 205 |
+--------+----------+------+------+
Table Enrolled:
+------+--------+
| snum | cname |
+------+--------+
| 101 | CSC342 |
| 101 | CSC343 |
| 101 | CSC345 |
| 101 | ECE300 |
| 101 | ENG366 |
| 102 | CSC343 |
| 102 | CSC345 |
| 102 | ECE301 |
| 103 | ECE300 |
| 103 | ECE301 |
| 104 | CSC342 |
| 104 | ECE301 |
| 105 | CSC345 |
| 105 | ECE300 |
| 106 | ENG366 |
| 106 | HIS320 |
| 107 | CSC342 |
| 107 | ENG366 |
| 108 | ENG367 |
| 108 | HIS320 |
| 109 | ECE300 |
| 109 | ECE301 |
| 110 | ENG366 |
| 110 | HIS320 |
+------+--------+
Table Faculty:
+-----+-----------+--------+
| fid | fname | deptid |
+-----+-----------+--------+
| 201 | S. Jackson| 301 |
| 202 | M. Shanks | 302 |
| 203 | I. Teach | 302 |
| 204 | A. Zobrah | 303 |
| 205 | M. Jensen | 303 |
+-----+-----------+--------+
The meaning of these relations is straightforward; for example, Enrolled has one
record per student-class pair such that the student is enrolled in the class.
1. Find the names of all Juniors(Level = JR) who are enrolled in a class
taught by I. Teach.
2. Find the age of the oldest student who is either a History major or
enrolled in a course taught by I. Teach.
3. Find the names of all classes that either meet in room R128 or
have five or more students enrolled.
4. Find the names of all students who are enrolled in two class that
meet at the same time.
7. For each level, print the level and the average age of students for that
level.
8. For all levels except JR, print the level and the average age of
students for that level.
9. For each faculty member that has taught class only in room R128
print the faculty member’s name and the total number of classes he
or she has taught.