Week 5 Flashcards

1
Q

What is an aggregate function?

A

A function that operates on a multi-set of values in a column of a relation and return a single value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the six aggregate functions?

A
<ul>
<li>Avg</li>
<li>Min</li>
<li>Max</li>
<li>Sum</li>
<li>Count</li>
<li>Group_concat</li>
</ul>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Are nulls counted in count(*)?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the only aggregate function that would return a number if a collection only had null values?

A

Count

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the set operations?

A
<ul>
<li>Union</li>
<li>Intersect</li>
<li>Except</li>
</ul>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do set operations deal with duplicates?

A

Automatically eliminates them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What operations can you use if you wish to use set operations without ignoring duplicates?

A
<ul>
<li>Union all</li>
<li>Intersect all</li>
<li>Except all</li>
</ul>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What do all the set operations require?

A

Identical attributes in the two operands

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Which query in a nested query is performed first?

A

The inner query

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the some operator?

A

Contains at least one row

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the exists operation?

A

Returns a value true if the argument relation is nonempty

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the unique operation do?

A

Constructs tests whether a subquery has any duplicate tuples in its result, evaluates to true on an empty set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a scalar subquery?

A

One where a single value is expected

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Where can you use a scalar subquery that is fun?

A

In the select clause

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What do join relations do?

A

Take two relations and return as a result another relation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the join condition?

A

Defines that the tuples in the two relations match and what attributes are presented in the result of the join

17
Q

What is the join type?

A

Define how tuples in each relation that do not match are going to be treated based on the join condition

18
Q

What are the four types of joins?

A
<ul>
<li>Inner join</li>
<li>Left outer join</li>
<li>Right outer join</li>
<li>Full outer join</li>
</ul>
19
Q

What is the using keyword used for?

A

When two relations match on multiple attributes and you want to specify what attribute to join on

20
Q

How do inner and outer joins differ?

A

An inner join discards tuples when they don’t match and an outer join keeps tuples by filling the missing information with nulls

21
Q

What do left and right refer to?

A

Keep the X matching tuples even if they don’t appear in the other table

22
Q

What happens when you use on on a join?

A

Duplicate of attributes you used for join

23
Q

What is the equivalent for on in a full join?

24
Q

What are integrity constraints used for?

A

To ensure accuracy of data stored by making sure authorized changs do not result in the loss of data consistency

25
What are the four integrity constraints that can be applied on a single relation?
```
  1. Primary key
  2. Not null
  3. Unique
  4. check(P)
```
26
What are referential integrity constraints used for?
To ensure that a value that appears in one relation also appears in another relation for a related set of attributes
27
What are the three referential actions?
```
  1. Cascade
  2. Restrict
  3. Set null
```
28
What does cascade do?
Updates or deletes cascade to the referencing table
29
What does restrict do?
Prevents updates of attrbute values or deletions of rows that are referenced by rows in this table (not allowed if affect relations with foreign keys)
30
What does set null do?
Updates or set attribute values in referencing relation to null
31
What are assertions?
Conditions that the database must always satisfy