Database-chap 9 Flashcards
SQL (13 cards)
The relational join operation merges rows from 2 tables and returns the rows with one of
the following conditions
– Have common values in common columns (natural
joint)
– Meet a given join condition (equality or inequality)
– Have common values in common columns or have no
matching values
Relational Set Operators
-Work properly if relations are union-compatible
– Names of relation attributes must be the same and
their data types must be identical
- Inner join
– Only rows that meet a given criterion are selected - Outer join
– Returns not only matching rows but the rows with
unmatched attribute values for one table or both
tables to be joined
UNION
will exclude duplicate records
UNION ALL
will retain the duplicate rows
INTERSECT
Combine rows from two queries, returning only the rows that appear in both sets
MINUS
Combines rows from two queries and returns only the rows that appear in the first set but not
in the second
JOIN ON Clause
- If no common attribute exist in both tables
- Query will return only the rows that meet the indicated join condition
Outer Joins
- Returns not only matching rows, but also rows with unmatched attribute values for one table or
both tables to be joined - Three types
– Left
– Right
– Full
LEFT Outer Joins
Returns rows matching the join condition AND rows in the left table with unmatched values in
the table
RIGHT Outer Join
- Returns rows matching the join condition AND rows in the RIGHT table with unmatched values
in the table
FULL Outer Joins
- Returns rows matching the join condition, but also returns all of the rows with unmatched values in the table on either side
Triggers
A trigger is procedural SQL code that is automatically invoked by the RDBMS upon the occurrence of a
given data manipulation event. It is useful to remember that:
– A trigger is invoked before or after a data row is inserted,
updated or deleted.
Types of Triggers
-A statement-level trigger is assumed if you omit the FOR EACH ROW keywords.
-A row-level trigger requires use of the FOR EACH ROW keywords.