### The existenial (∃) and universal (∀) quantifiers

• The existential quantifier ( ∃ ) and the universal quantifier ( ∀ )

• The existential quantifier:

 ``` The expression: (∃t) ( Condition(t) ) evaluates to true if there is some (at least one) tuple t that satisfies the condition Condition(t) false otherwise ```

Examples:

 ``` (∃t) ( Employee(t) and t.fname='John' and t.lname='Smith') This expression is true if there is an employee named "John Smith" (∃d) ( Department(d) and d.dname='Research' ) This expression is true if there is a department named "Research" ```

• Universal quantifier ∀:

 ``` (∀t) ( Condition(t) ) evaluates to evaluates to true if all tuples t satisfies the condition Condition(t) false otherwise ```

Example:

 ``` (∀t) ( Employee(t) and t.salary > 40000 ) This expression is true if all employees earn more than \$40000 ```

• Using ∃ and ∀ in Relational Calculus queries

• The and operators are used as a searching (matching) mechanism.

Example:

 Find the department number of the Research department

Solution 1: without using the existential quantifier

 ``` { d.dno | Department(d) and d.dname='Research' } ```

Solution 2: with the existential quantifier ∃

 ``` { d.dno | Department(d) and ( ( ∃ t ) ( Department(t) and t.dname = 'Research' and t.dno = d.dno ) ) } ```

Explanation:

• The expression

 ``` ( ∃ t ) ( Department(t) and t.dname = 'Research' ) ```

is true for the tuple t belonging to the Research department

• Then the expression:

 ``` ( ∃ t ) ( Department(t) and t.dname = 'Research' and t.dno = d.dno ) ```

is true only when:

 ``` t.dno = d.dno and t is the tuple of the Research department ```

In other words: d.dno is the department number of the Research department

• Therefore:

 ``` { d.dno | Department(d) and ( ( ∃ t ) ( Department(t) and t.dname = 'Research' and t.dno = d.dno ) ) } ```

is the department number of the Research department.

• Note:

• The example:

 ``` { d.dno | Department(d) and ( ( ∃ t ) ( Department(t) and t.dname = 'Research' and t.dno = d.dno ) ) } ```

is awfully contrived

• It means to show you how to "export" the dnumber of the department with dname = "Research"

 We will use this "exported" dnumber in a more realitic query next.