Section 3

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/24

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:42 AM on 5/6/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

25 Terms

1
New cards

Operator

A symbol that computes a value from 1+ other value (operands).

  • Arithmetic operators compute numeric values from numeric operands

  • Comparison operators compute logical values TRUE or FALSE

  • Logical operands compute logical values from logical operands

2
New cards

Unary operator

Has 1 operand

3
New cards

Binary operator

Has 2 operands.

Most operators are binary.

4
New cards

Expression

A string of operators, operands, and parentheses that evaluates to a single value.

Operands may be column names or fixed values.

5
New cards

Operator precedence

Determines the order in which expressions are evaluated.

<p>Determines the order in which expressions are evaluated.</p>
6
New cards

Condition

An expression that evaluates to a logical value

7
New cards

When arithmetic/comparison operators have 1+ NULL operands, what is the result?

NULL

8
New cards

What happens when a WHERE clause evaluates to NULL?

The row is not selected.

9
New cards

Can comparison operators select NULL values?

No

10
New cards

When either operand is null, what do comparison operators return?

NULL

11
New cards

Function

Operates on an expression enclosed in parentheses (an argument) and returns a value

Each operates on, and evaluates to, different data types.

Can have one, several, or no args.

Args are usually a simple expression.

12
New cards

Aggregate Function

Processes values from a set of rows and returns a summary value.

Appear in SELECT clauses and process all rows that satisfy the WHERE clause condition.

If no WHERE clause, it processes all rows.

Ignores NULL values
eg. SUM(Salary) adds all non-NULL salaries and ignores rows containing a NULL salary

<p>Processes values from a set of rows and returns a summary value.</p><p>Appear in SELECT clauses and process all rows that satisfy the WHERE clause condition.</p><p>If no WHERE clause, it processes all rows.</p><p>Ignores NULL values<br>eg. <span style="background-color: transparent;">SUM(Salary) adds all non-NULL salaries and ignores rows containing a NULL salary</span></p>
13
New cards

Equijoin

Compares columns of 2 tables with the “ = “ operator.

Most joins are equijoins.

14
New cards

Non-equijoin

Compares columns with an operator other than “ = “

eg. > , <

eg. Price > Cost

15
New cards

Self-join

Joins a table to itself.

Can compare columns as long as they have comparable data types.

If the foreign key and referenced primary key are in the same table, a self-join commonly compares those key columns.

Aliases are necessary to distinguish left and right tables

<p>Joins a table to itself.</p><p>Can compare columns as long as they have comparable data types.</p><p>If the foreign key and referenced primary key are in the same table, a self-join commonly compares those key columns.</p><p>Aliases are necessary to distinguish left and right tables</p>
16
New cards

Views

Restructure table columns and data types without changes to the underlying database design

17
New cards

View Table

A table name associated with a SELECT statement (the view query).

Table data not normally stored

18
New cards

Base Table

A table specified in the view query’s FROM clause.

Are always source tables, created as tables rather than views.

Whenever it changes, the corresponding view tables also change.
Materialized views must be refreshed.

19
New cards

Materialized View

A view for which data is stored at all times.

Many DBs (including MySQL) do not support these to avoid the overhead of refreshing views.

20
New cards

Can a view table be defined on another view table?

Yes when the query FROM clause additional view tables.

21
New cards

1) What happens when queries are executed against view tables?

2) Does this also happen when queries are executed against materialized views?

1) The changes are reflected in the base tables. The queries are converted to a merged query and, then executed (this is for non-materialized view tables).

2) Yes, queries are also executed on the view table

22
New cards

What are 3 advantages of using views?

1) Protect sensitive data - a view can exclude sensitive columns and include all others

2) Save complex queries - complex SELECT statements can be saved as a view
DB users can reference the view without writing the SELECT statement.

3) Save optimized queries - optimally performing SELECT statements can be saved as a view and distributed to DB users

23
New cards

What are 3 problems with using INSERT, UPDATE, and DELETE statements with views?

1) Primary keys - if a base table primary key doesn’t appear in a view, the insert to the view generates a NULL primary key value.
Since primary keys cannot be NULL, this insert isn’t alowed.

2) Aggregate values - a view query can contain aggregate functions (eg. AVG(), SUM() ); an update/insert to the view may create a new aggregate value, which must be converted to many base tables

  • The conversion is undefined, so the insert/update is not allowed

  • One aggregate value corresponds to many base table values

3) Join views - The effect of a join view delete is undefined, and therefore, not allowed
In a join view, foreign keys of one table may match primary keys of another.
A delete from a view might delete foreign key rows only, primary keys only, or both primary and foreign keys

24
New cards

What are views best for?

Reading data.

Avoid inserts/updates/deletes

25
New cards

What may make inserts/updates appear to fail?

When they create a row that does not satisfy the view query WHERE clause.

In this case, the row doesn’t appear on the view table, even though the table may have been successfully changed.

Use WITH CHECK OPTION to prevent this.