Chapter 08
Chapter 08
Navathe 1
Chapter 8
SQL-99: SchemaDefinition,
Constraints, and Queries and Views
Data Definition, Constraints, and
Schema Changes
■Used to CREATE, DROP, and ALTER the
descriptions of the tables (relations) of a
database
■EMPLOYEE.LNAME, DEPARTMENT.DNAME
Q1C: SELECT *
FROM EMPLOYEE
WHERE DNO=5
Q1D: SELECT *
FROM EMPLOYEE, DEPARTMENT
WHERE DNAME='Research' AND
DNO=DNUMBER
E.FNAME=D.DEPENDENT_NAME
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe 35
CORRELATED NESTED QUERIES
(contd.)
■ The original SQL as specified for SYSTEM R also had a
CONTAINS comparison operator, which is used in
conjunction with nested correlated queries
■ This operator was dropped from the language, possibly
because of the difficulty in implementing it efficiently
■ Most implementations of SQL do not have this operator
■ The CONTAINS operator compares two sets of values, and
returns TRUE if one set contains all values in the other set
■Reminiscent of the division operation of algebra
FNAME=DEPENDENT_NAME)
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe 40
THE EXISTS FUNCTION (contd.)
■ Query 6: Retrieve the names of employees who have no
dependents.