# Domain Relational Calculus

Tom Kelliher, CS 318

Feb. 27, 2002

Collect assignment. Distribute next assignment.

### From Last Time

Tuple relational calculus.

### Outline

1. Introduction to DRC.

2. Examples.

3. Practice.

### Coming Up

The ``Big Merge.''

# Domain Relational Calculus

1. Visual query languages (QBE, Access) are based upon this.

2. Simple example DRC query:

3. General form of a TRC query:

where:

1. is a domain variable which ranges over all possible values for that domain.

2. Condition is (these are similar to TRC):
1. Atomic:
1. , asserting that the tuple formed by the s is in relation R.

2. or .

2. Two conditions combined using AND or OR, or one condition modified by NOT.

3. A condition (C), Relation (R), and domain variable (X) combined as

3. The s in the target may be the only free variables.

4. The meaning of a DRC query is similar to that of a TRC query.

## Examples

1. Retrieve names of all professors who have taught `MGT123`:

This can be abbreviated:

(Non-target free variables are implicitly existentially quantified used the universal domain.)

2. All courses that have been taken by every student:

3. Find all students who have ever taken a course from every professor who has ever taught a course.

4. Retrieve IDs of students who did not take any courses in F2001:

5. Find potential student graders for this semester's courses:

## Practice

Write DRC queries to answer the following:

1. Retrieve name of student with largest ID number.

2. Names of all professors who have taught CS318.

3. The names of all sophomores who received A's during the F2001 semester.

4. The IDs of all students who took exactly one course during the F2001 semester.

5. The IDs of all students who have taken a course with me.

6. The IDs of all students who have taken every course I've taught.

Thomas P. Kelliher
Fri Feb 22 09:44:24 EST 2002
Tom Kelliher