CIS275 - Chapter 2: Relational Databases Flashcards

1
Q

A _____ is a conceptual framework for database software.

A

database model

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

The _____ is not optimized for big data.

A

relational model

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

Many non-relational databases have come to market since 2000, optimized for big data and are collectively called _____.

A

NoSQL databases

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

NoSQL stands for _____ and encompasses a variety of database models.

A

‘Not only SQL’

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

The _____ is a database model based on mathematical principles, with three parts:

A data structure that prescribes how data is organized.

Operations that manipulate data structures.

Rules that govern valid relational data.

A

relational model

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

A ___ is a collection of values, or elements, with no inherent order.

A

set

Sets are denoted with braces. Ex: {apple, banana, lemon} is the set containing three kinds of fruit. Since sets have no order, {apple, banana, lemon} is the same set as {lemon, banana, apple}.

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

A _____ is a named set of possible database values, such as integers, dictionary words, or logical values TRUE and FALSE.

A

domain

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

A _____ is a finite sequence of values, each drawn from a fixed domain.

A

tuple

Ex: (3, apple, TRUE) is a tuple drawn from domains (Integers, DictionaryWords, LogicalValues).

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

A _____ is a named set of tuples, all drawn from the same sequence of domains.

A

relation

Ex: The relation below is named Grocery and contains three tuples.

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

In the relational model, each tuple position is called an _____ and given a unique name.

A

attribute

Ex: In the Grocery relation, the first, second, and third positions might be named Quantity, FruitType, and OrganicCertification.

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

Domain, tuple, relation, and attribute =

A

Data type, row, table, and column

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

The relational model stipulates a set of operations on tables, collectively called _____.

A

relational algebra

Like the relational data structure, relational operations are based on set theory.

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

combines two tables with identical columns into one table.

A

Union

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

removes all rows of one table from another table.

A

Difference

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

eliminates one or more columns of a table.

A

Projection

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

selects a subset of rows of a table.

A

Selection

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

combines two tables with different columns into one table.

A

Join

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

lists all possible combinations of rows of two tables.

A

Product

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

_____, also known as integrity rules, are logical constraints that ensure data is valid and conforms to business policy.

A

Relational rules

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

_____ are relational rules that govern data in every relational database.

A

Structural rules

The relational model stipulates a number of structural rules, such as:

Unique primary key — all tables should have a column with no repeated values, called the primary key and used to identify individual rows.

Unique column names — different columns of the same table must have different names.

No duplicate rows — no two rows of the same table may be have identical values in all columns.

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

_____ are relational rules specific to a particular database and application.

A

Business rules

Example business rules include:

Unique column values — in a particular column, values may not be repeated.

No missing values — in a particular column, all rows must have known values.

Delete cascade — when a row is deleted, automatically delete all related rows.

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

A _____ is a collection of data organized as columns and rows.

A

table

A table must have at least one column and any number of rows. A table without rows is called an empty table.

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

A _____ is a set of values of the same type. Each column has a name, different from other column names in the table.

A

column

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

A ____ is a set of values, one for each column.

A

row

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

A ____ is a single column of a single row. In relational databases, each ____ contains exactly one value.

(same word in both fields)

A

cell

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

In addition to a name, each column has a_____, which defines the format of the values stored in each row.

A

data type

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

_____data types represent positive and negative integers. Several _____ data types exist, varying by the number of bytes allocated for each value.

(same word)

A

Integer

Common integer data types include INT, implemented as 4 bytes of storage, and SMALLINT, implemented as 2 bytes.

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

_____data types represent numbers with fractional values.

A

Decimal

Decimal data types vary by number of digits after the decimal point and maximum size. Common decimal data types include FLOAT and DECIMAL.

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

_____data types represent textual characters.

A

Character

Common character data types include CHAR, a fixed string of characters, and VARCHAR, a string of variable length up to a specified maximum size.

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

_____data types represent date, time, or both.

A

Time

Some time data types include a time zone or specify a time interval. Some time data types represent an interval rather than a point in time. Common time data types include DATE, TIME, DATETIME, and TIMESTAMP.

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

_____data types store data exactly as the data appears in memory or computer files, bit for bit.

A

Binary

The database manages binary data as a series of zeros and ones. Common binary data types include BLOB, BINARY, VARBINARY, and IMAGE.

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

_____data types store geometric information, such as lines, polygons, and map coordinates.

A

Spatial

Examples include POLYGON, POINT, and GEOMETRY. Spatial data types are relatively new and consequently vary greatly across database systems.

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

_____data types contain textual data in a structured format such as XML or JSON.

A

Document

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

Data types

Relational databases support many different data types. Most data types fall into one of the following categories:

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

Tables obey three rules:

A
  1. Tables are normalized — exactly one value exists in each cell.
  2. No duplicate column names — duplicate column names are not allowed in one table. However, the same column name can appear in different tables.
  3. No duplicate rows — no two rows may have identical values in all columns.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

In addition to the three rules, relational databases obey the principle of _____, which states that rows and columns of a table have no inherent order.

A

data independence

Although values in rows and columns are stored sequentially on a storage device, such as a disk drive, the sequence is arbitrary and does not affect the results of a database query.

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

a special value that represents missing data.

A

Null value

NULL represents either ‘unknown’ or ‘inapplicable’.

NULL is not the same as zero for numeric data types or blanks for character data types.

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

a symbol that computes a value from one or more other values (called operands).

A

operator

Arithmetic operators, such as +, -, *, and /, compute numeric values from numeric operands.

Comparison operators, such as , and =, compute logical values TRUE or FALSE. Operands may be numeric, character, and other data types.

Logical operators, AND, OR, and NOT, compute logical values from logical operands.

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

arithmetic functions

returns the total of selected values.

returns the average of selected values.

returns the largest selected value.

returns the smallest selected value.

A

SUM

AVG

MAX

MIN

SUM, AVG, MIN, and MAX ignore NULL values.

51
Q
A
52
Q
A
53
Q
A
54
Q
A
55
Q
A
56
Q

a column, or group of columns, used to identify a row.

A

primary key

Primary keys obey two rules:

Values must be unique within the column. This rule ensures that each value identifies at most one row.

Values may not be NULL. This rule ensures that each value identifies at least one row.

57
Q

A unique column that is not the primary key is called an:

A

alternate key

58
Q

Collectively, the primary key and all alternate keys of a table are called

A

candidate keys

59
Q
A
60
Q

A _____ key consists of a single column.

A

simple primary

61
Q

A _____ key consists of multiple columns.

A

composite primary key

Composite primary keys are denoted with parentheses. Ex: (ColumnA, ColumnB).

Composite primary keys obey three rules:

Column values, when grouped together, must be unique. Ex: The combination (2538, 1) is unique within (ID, Number).

Columns may not contain NULL.

Composite primary keys must be minimal.

62
Q

In a _____, all columns are necessary for uniqueness.

A

minimal primary key

Ex: (ID, Number, Relationship) is not minimal. Since (ID, Number) is unique, Relationship is unnecessary.

63
Q
A
64
Q

A _____ is a column or group of columns, that refers to a primary key.

A

foreign key

Foreign keys do not obey the same rules as primary keys:

Foreign key values may be repeated. Ex: Sales and Marketing have the same manager.

Foreign key values may be NULL. Ex: Technical support currently has no manager.

Non-NULL foreign key values must match some primary key value.

65
Q
A
66
Q
A
67
Q
A
68
Q
A
69
Q
A
70
Q
A
71
Q
A
72
Q

Referential integrity actions:

rejects an insert, update, or delete that violates referential integrity.

A

RESTRICT

73
Q

Referential integrity actions

sets invalid foreign keys to NULL.

A

SET NULL

74
Q

Referential integrity actions

sets invalid foreign keys to a default primary key value, specified in SQL.

A

SET DEFAULT

75
Q

Referential integrity actions

propagates primary key changes to foreign keys.

A

CASCADE

76
Q
A
77
Q
A
78
Q
A
79
Q
A
80
Q
A
81
Q

a SELECT statement that combines data from two tables, known as the left table and right table, into a single result.

A

join

The tables are combined by comparing columns from the left and right tables, usually with the = operator. The columns must have comparable data types.

82
Q
A
83
Q

An ____ selects only matching left and right table rows.

A

inner join

84
Q

A _____ selects all left table rows, but only matching right table rows.

A

left join

85
Q

A _____ selects all right table rows, but only matching left table rows.

A

right join

86
Q

A ____ selects all left and right table rows, regardless of match.

A

full join

87
Q

An _____ is any join that selects unmatched rows, including left, right, and full joins.

A

outer join

88
Q
A
89
Q

An _____ compares columns of two tables with the = operator. Most joins are _____ , including the examples above.

(same word)

A

equijoin

90
Q

A _____ compares columns with an operator other than =, such as .

A

non-equijoin

In the example below, a non-equijoin selects all buyers along with properties priced below the buyer’s maximum price.

91
Q

In a _____, a table is joined to itself.

A

self-join

A self-join can compare any columns of a table, as long as the columns have comparable data types. If a foreign key and the referenced primary key are in the same table, a self-join might compare key columns.

92
Q

An ____ is a temporary name assigned to a column or table.

A

alias

In the example below, A is the left table’s alias, and B is the right table’s alias. A.Name is the Name column of the left table, representing the employee. B.Name is the Name column of the right table, representing the employee’s manager. The result shows employees along with each employee’s manager.

93
Q

A _____ combines two tables without comparing columns.

A

cross-join

A cross-join has no WHERE or ON clause. As a result, all possible combinations of rows from both tables appear in the result.

In the example below, all configurations of iPhone models and memory appear, along with total price.

94
Q
A
95
Q

A _____ is a table name associated with a SELECT statement, called the _____.

A

view table

view query

96
Q

The _____ statement creates a view table and specifies the view name, query, and, optionally, column names.

A

CREATE VIEW

97
Q
A
98
Q

A table specified in the view query’s FROM clause is called a _____.

A

base table

99
Q

A _____ is a view for which data is stored at all times.

A

materialized view

Whenever a base table changes, the corresponding view tables can also change, so materialized views must be refreshed. To avoid the overhead of refreshing views, MySQL and many other databases do not support materialized views.

100
Q
A
101
Q

Advantages of views: protect sensitive data.

Explain

A

A table may contain sensitive data.

Ex: The Employee table contains compensation columns such as Salary and Bonus. A view can exclude sensitive columns but include all other columns. Authorizing users and programmers access to the view but not the underlying table protects the sensitive data.

102
Q

Advantages of views: save complex queries.

Explain

A

Complex or difficult SELECT statements can be saved as a view. Database users can reference the view without writing the SELECT statement.

103
Q

Advantages of views: Save optimized queries.

Explain

A

Often, the same result table can be generated with equivalent SELECT statements. Although the results of equivalent statements are the same, performance may vary. To ensure fast execution, the optimal statement can be saved as a view and distributed to database users.

104
Q
A
105
Q

When _____ is specified, the database rejects inserts and updates that do not satisfy the view query WHERE clause. Instead, the database generates an error message that explains the violation.

A

WITH CHECK OPTION

  1. Two employees are in department 51, Sales.
  2. CREATE VIEW specifies new names for SalesEmployee columns.
  3. SalesEmployee view only includes employees in department 51.
  4. The user query inserts a new employee in department 80 into the view table.
  5. The new employee is inserted into Employee but is not in department 51 and does not appear in the view table.

WITH CHECK OPTION prevents inserts and updates that do not satisfy the view query WHERE clause.

106
Q
A
107
Q

In a database, a ___ is a pair of related values, and ___ is the repetition of a fact.

A

fact

redundancy

Redundancy causes database management problems. When a fact is updated or deleted, all copies must be changed, which makes queries slow and complex. If copies are not updated or deleted uniformly, the copies become inconsistent and the correct fact is uncertain.

  1. The fact that passenger number 222 is named Elvira Yin is repeated.
  2. The fact that first class fares board first is repeated.
108
Q

_____ are rules for designing tables with less redundancy.

A

Normal forms

Normal forms are numbered, first normal form through fifth normal form. An additional normal form, named Boyce-Codd normal form, is considered an improved version of third normal form. The six normal forms comprise a sequence, with each normal form allowing less redundancy than the prior normal form.

109
Q
A
110
Q

Column A ____ column B means each B value is related to at most one A value. For a table to be in _____, all non-key columns must depend on the primary key.

A

depends on

first normal form

In a relational database, all tables with a primary key are in first normal form, as illustrated in the animation below.

111
Q
A
112
Q

For a table to be in _____, all non-key columns must depend on the whole primary key.

A

second normal form

n other words, a non-key column cannot depend on part of a composite primary key. A table with a simple primary key is automatically in second normal form.

  1. PassengerName depends on PassengerNumber. Dependence on part of the primary key causes repetition of (222, Elvira Yin).
  2. Removing PassengerName from Booking eliminates redundancy. Booking is now in second normal form.
  3. PassengerName moves to the Passenger table. The Passenger table has no redundancies, since PassengerName depends on the whole primary key.
113
Q
A
114
Q
A
115
Q

A _____ is a simple or composite column that is unique and minimal.

A

candidate key

Minimal means all columns are necessary for uniqueness. A table may have several candidate keys. The database designer designates one candidate key as the primary key.

116
Q

A _____ column is a column that is not contained in a candidate key.

A

non-key

Ex: The Employee table contains columns ID, SocialNumber, and Name:

  • ID and SocialNumber are candidate keys, since both are unique and minimal.
  • (ID, Name) is unique but not minimal, since Name is not necessary for uniqueness. Therefore (ID, Name) is not a candidate key.
  • Name is a non-key column.
117
Q

A table is in _____ if, whenever a non-key column A depends on column B, then B is unique.

A

third normal form

In this definition, columns A and B may be simple or composite. Although B is unique, B is not necessarily minimal and therefore is not necessarily a candidate key.

The definition of third normal form states that all non-key dependencies are on a unique column. The definition generalizes the informal description, above, which states that all non-key dependencies are on the primary key.

The definition of third normal form applies to non-key columns only, which allows for occasional redundancy.

118
Q

A table is in _____ if, whenever column A depends on column B, then B is unique. This definition is identical to the definition of third normal form with the term ‘non-key’ removed.

A

Boyce-Codd normal form

119
Q

A _____ is any simple or composite column that is unique. Unlike candidate keys, superkeys are not necessarily minimal.

A

superkey

An alternative definition of Boyce-Codd normal form replaces unique with superkey: A table is in Boyce-Codd normal form if, whenever column A depends on column B, then B is a superkey. This definition is equivalent to the definition above.

120
Q
A