SQL: Advanced Queries, Assertions, Triggers and Views

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/36

flashcard set

Earn XP

Description and Tags

Flashcards for reviewing advanced SQL concepts, including nested queries, joins, assertions, triggers, and views.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

37 Terms

1
New cards

Nested Queries

Complete select-from-where blocks within WHERE clause of another query.

2
New cards

Outer Query

The main query in a nested query structure.

3
New cards

IN operator

Compares a value with a set of values; evaluates to TRUE if the value is in the set.

4
New cards

= ANY (or = SOME) operator

Returns TRUE if the value is equal to some value in the set.

5
New cards

Correlated nested query

Evaluated once for each tuple in the outer query.

6
New cards

EXISTS function

Checks whether the result of a correlated nested query is empty or not.

7
New cards

Joined table

A table resulting from a join operation in the FROM clause of a query.

8
New cards

NATURAL JOIN

Implicit EQUIJOIN condition for each pair of attributes with the same name from relations R and S.

9
New cards

Inner join

Tuple is included in the result only if a matching tuple exists in the other relation (default type of join).

10
New cards

LEFT OUTER JOIN

Every tuple in the left table must appear in the result; if no matching tuple, padded with NULL values for the right table's attributes.

11
New cards

RIGHT OUTER JOIN

Every tuple in the right table must appear in the result; if no matching tuple, padded with NULL values for the left table's attributes.

12
New cards

FULL OUTER JOIN

Combines the results of both left and right outer joins.

13
New cards

Aggregate functions

Used to summarize information from multiple tuples into a single-tuple summary (COUNT, SUM, MAX, MIN, AVG).

14
New cards

GROUP BY clause

Specifies grouping attributes to partition a relation into subsets of tuples.

15
New cards

HAVING clause

Provides a condition on the summary information in a GROUP BY query.

16
New cards

CREATE TRIGGER

Specifies automatic actions that the database system will perform when certain events and conditions occur.

17
New cards

ALTER Command

Used to modify table structure using actions such as adding or dropping a column (attribute), Changing a column definition, Adding or dropping table constraints.

18
New cards

Query modification

Modify view query into a query on underlying base tables.

19
New cards

UNIQUE(Q) function

Returns TRUE if there are no duplicate tuples in the result of query Q.

20
New cards

CREATE ASSERTION

Specifies additional types of constraints outside the scope of built-in relational model constraints.

21
New cards

CREATE TRIGGER

Specifies automatic actions that the database system will perform when certain events and conditions occur.

22
New cards

DROP command

Used to drop named schema elements, such as tables, domains, or constraints.

23
New cards

ALTER Command

Used to modify table structure using actions such as adding or dropping a column (attribute), Changing a column definition, Adding or dropping table constraints.

24
New cards

CREATE VIEW command

Creates a virtual table derived from other tables.

25
New cards

View materialization

Physically create a temporary view table when the view is first queried.

26
New cards

Clause WITH CHECK OPTION

Must be added at the end of the view definition if a view is to be updated.

27
New cards

In-line view

Defined in the FROM clause of an SQL query.

28
New cards

WHERE clause

Specifies a search condition for a group or an aggregate.

29
New cards

AVG function

Returns the average value of a numeric column.

30
New cards

COUNT function

Returns the number of rows that matches a specified criterion.

31
New cards

MAX function

Returns the largest value of the selected column.

32
New cards

MIN function

Returns the smallest value of the selected column.

33
New cards

SUM function

Returns the sum of all values in a numeric column.

34
New cards

ORDER BY Clause

Used to sort the result-set in ascending or descending order.

35
New cards

JOIN Clause

Combines rows from two or more tables, based on a related column between them.

36
New cards

GROUP BY

Used with aggregate functions to group the result-set by one or more columns.

37
New cards

Define common table expressions

Allows to name a sub-query block, which can then be referenced in several places in the main SQL query.