DBMS Lecture 8
DBMS Lecture 8
(TCS 503)
Lecture- 8
B. Tech- CSE
3rd Year (5th semester)
• Character-string
• DATE: The DATE data type has ten positions, and its components are YEAR,
MONTH, and DAY in the form YYYY-MM-DD.
• Boolean: A Boolean data type has the traditional values of TRUE or FALSE.
• A timestamp
Specifying Constraints in SQL
• SQL allows NULLs as attribute values, a constraint NOT
NULL may be specified if NULL is not permitted for a
particular attribute.
• The SELECT statement is not the same as the SELECT operation of relational
algebra.
EMPLOYEE AS E(Fn, Mi, Ln, Ssn, Bd, Addr, Sex, Sal, Sssn, Dno)
• We can now join the two copies. Of course, in reality there is only one
EMPLOYEE relation, and the join condition is meant to join the relation
with itself by matching the tuples that satisfy the join condition
E.Super_ssn = S.Ssn.
Unspecified WHERE Clause
and Use of the Asterisk
• A missing WHERE clause indicates no
condition on tuple selection; hence, all tuples
of the relation specified in the FROM clause
qualify and are selected for the query result. If
more than one relation is specified in the
FROM clause and there is no WHERE clause,
then the CROSS PRODUCT—all possible tuple
combinations—of these relations is selected.
• Q1: SELECT Ssn
FROM EMPLOYEE;
• Q2: SELECT Ssn, Dname
FROM EMPLOYEE, DEPARTMENT;
• For example, Query q selects all EMPLOYEE
Ssns, and Query 10 selects all combinations of
an EMPLOYEE Ssn and a DEPARTMENT Dname,
regardless of whether the employee works for
the department or not.
• For example, the result of (FALSE AND UNKNOWN) is FALSE, whereas the result of
(FALSE OR UNKNOWN) is UNKNOWN. The result of the NOT logical operation. Notice
that in standard Boolean logic, only TRUE or FALSE values are permitted; there is no
UNKNOWN value.
• SELECT Fname, Lname
FROM EMPLOYEE
WHERE Super_ssn IS NULL;