Chapter 7 Flashcards
don't forget to make missing slides 57 - 63 flashcards.
What is the SQL Query to check if an attribute value is NULL?
Where {attribute name} IS NULL
or
Where {attribute name} IS NOT NULL
Which comparison operator compares values v with a set cor multiset) of values V and evaluates TRUE if v is one of the elements in V?
Comparison operator IN
___________ are complete select-from-where blocks within WHERE clause of another query. It includes an outer query and nested subqueries.
Nested queries
Which operator returns TRUE if the value v is equal to some value in the set V and is hence equivalent to IN?
= ANY
or
= SOME
__________ expresses all values in the database.
ALL
T/F: A correlated nested query is evaluated once for each tuple in the outer query.
true
________ and ________ function checks whether the result of a correlated nested query is empty or not. They are Boolean functions that return TRUE or FALSE result.
EXISTS, NOT EXISTS
T/F: EXISTS and NOT EXISTS functions are typically used in conjunction with a correlated nested query.
True.
________ function returns TRUE if there are no duplicate tuples in the result of query Q.
UNIQUE (Q)
T/F: we use explicit set of values in SELECT clause.
False, in WHERE clause.
(Ex:
Select distinct Essn
From WORKS_ON
where Pno IN (1,2,3); )
Use qualifier ________ rolled by desired new name to rename any attribute that appears in the result of a query.
AS
________ permits users to specify a table resulting from a join operation in the FROM clause of a query.
Joined table
JOIN may also be
called ________.
INNRT JOIN
__________ JOIN on two relations R and S has no join condition specified.
NATURAL
_________ JOIN is equivalent to an implicit EQUIJOIN condition for each pair of attributes with same name from R and S.
NATURAL
[NOTE: An equi-join is a join based on equality or matching column values.]
T/F: It is not possible to use NATURAL JOIN on two relations that have the same attribute names.
false, you can rename the attributes of one relation so it can be joined with another using NATURAL JOIN.
(EX:
SELECT Fname, Lname, Address
FROM (EMPLOYEE NATURAL JOIN
(DEPARTMENT AS DEPT (Dname, Dno, Mssn,
Msdate)))
WHERE Dname=‘Research’; )
Rewrite the following query using an implicit join condition:
SELECT Fname, Lname, Address
FROM (EMPLOYEE NATURAL JOIN
(DEPARTMENT AS DEPT (Dname, Dno, Mssn,
Msdate)))
WHERE Dname=‘Research’;
EMPLOYEE.Dno = DEPT.Dno
[Note: remember that natural join is equivalent to an implicit join condition.]
_________ is the default type of join in a joined table.
INNER JOIN
In a _________ JOIN, a tuple is included in the result onlu if a matching tuple exists in the other relation.
INNER
In a __________ JOIN, every tuple in the left table must appear in the result.
LEFT OUTER
T/F: If there are no matching tuples in an LEFT OUTER JOIN then the query will not execute.
False, if there are no matching tuples, the right table will be padded with NULL values for attributes. This applies for both RIGHT and LEFT OUTER JOIN.
In a ________ JOIN, every tuple in the right table must appear in the result.
RIGHT OUTER
If there are no matching tuples in a RIGHT OUTER JOIM, the (right/left) table attributes will be padded with ________ values.
Left, NULL.
__________ are used to summarize information from multiple tuples into a single-tuple summary.
aggregate functions
Built-in aggregate functions include _____, _____, ____, _____, and _____.
COUNT, SUM, MAX, MIN, AVG.
________ create subgroups of tuples before summarizing.
Grouping
To select entire groups, a _________ clause is used.
HAVING