Problem

Exercise 5.8 Consider the following relations:Student(snum: integer, sname: string, major:...

Exercise 5.8 Consider the following relations:

Student(snum: integer, sname: string, major: string,level: string, age: integer)Class(name: string, meets_at: time, room: string, fid: integer)Enrolled(snum: integer, cname: string)Faculty(fid: integer, fname: string, deptid: integer)

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. Write the SQL statements required to create these relations, including appropriate versions of all primary and foreign key integrity constraints.
  2. Express each of the following integrity constraints in SQL unless it is implied by the primary and foreign key constraint; if so, explain how it is implied. If the constraint cannot be expressed in SQL, say so. For each constraint, state what operations (inserts, deletes, and updates on specific relations) must be monitored to enforce the constraint.
    1. Every class has a minimum enrollment of 5 students and a maximum enrollment of 30 students.
    2. At least one class meets in each room.
    3. Every faculty member must teach at least two courses.
    4. Only faculty in the department with deptid=33 teach more than three courses.
    5. Every student must be enrolled in the course called Math101.
    6. The room in which the earliest scheduled class (i.e., the class with the smallest meets_at value) meets should not be the same as the room in which the latest scheduled class meets.
    7. Two classes cannot meet in the same room at the same time.
    8. The department with the most faculty members must have fewer than twice the number of faculty members in the department with the fewest faculty members.
    9. No department can have more than 10 faculty members.
    10. A student cannot add more than two courses at a time (i.e., in a single update).
    11. The number of CS majors must be more than the number of Math majors.
    12. The number of distinct courses in which CS majors are enrolled is greater than the number of distinct courses in which Math majors are enrolled.
    13. The total enrollment in courses taught by faculty in the department with deptid=33 is greater than the number of Math majors.
    14. There must be at least one CS major if there are any students whatsoever.
    15. Faculty members from different departments cannot teach in the same room.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 5