D426: Data Management Foundations Ch 5 - Database Design

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

1/110

flashcard set

Earn XP

Description and Tags

Flashcards for chapter 5 of WGU's Data Management Foundations course.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

111 Terms

1
New cards

What are four dimensions on which computer media can vary?

  1. Speed

  2. Cost

  3. Capacity

  4. Volatility

2
New cards

access time

the time required to access the first byte in a read or write operation

3
New cards

transfer rate

the speed at which data is read or written, following initial access

4
New cards

volatile memory

memory that is lost when disconnected from power

5
New cards

non-volatile memory

memory that is retained without power

6
New cards

main memory/RAM

the primary memory used when computer programs execute, which is fast, expensive, and has limited capacity

7
New cards

flash memory/SSD

a type of memory stored in pages of 2 - 16 kb. Writes are slower than reads.

8
New cards

magnetic disk/HDD

a type of memory stored in sectors on a track, traditionally 512 bytes, but more often 4 kb on newer formats

9
New cards

block

a uniformly sized unit used by databases and file systems when transferring data between main memory and storage media, which is usually anywhere between 2 and 64 kb

10
New cards

storage controllers

a portion of a storage system internal to the storage device that converts data between blocks and sectors or pages

11
New cards

Smaller block sizes are better for __, which access a few rows per query.

transactional applications

12
New cards

Larger block sizes are better for __, which access many rows per query.

analytical applications

13
New cards

row-oriented storage

a form of storage that stores an entire row in one block to minimize block transfers during transactional applications

14
New cards

Row-oriented storage performs best when row size is small relative to __.

block size

15
New cards

Why does row-oriented storage perform best with rows that are small in relation to the block size?

  1. Improved query performance due to more rows per block.

  2. Less wasted storage due to rows fitting more evenly into available space.

16
New cards

For tables with large columns, each row usually contains a link to the large column, which is stored __.

in files managed by the operating system or in a special storage area managed by the database.

17
New cards

How does column-oriented storage benefit analytic applications?

  1. Faster access to an entire column.

  2. Better data compression when all values have the same data type.

18
New cards

PostgreSql and Vertica

examples of relational databases that support column-oriented storage

19
New cards

heap table

a table structure where no order is imposed on rows and instead the database maintains a list of blocks assigned to the table, along with the address of the first available space for inserts

20
New cards

What type of table structure is best for optimizing insert operations and bulk loading rows?

heap table

21
New cards

Heap tables are not optimal for __.

queries that read rows in a specific order

22
New cards

sorted table

a table structure where the database designer identifies a sort column, usually the primary key, that determines physical row order on storage media

23
New cards

Sorted tables are optimal for queries that __.

read data in order of the sort column

24
New cards

How does a sorted table structure handle an attempt to insert a row into a full block?

The block splits in two and half the rows are moved to a new block.

25
New cards

hash table

a table structure where rows are assigned to buckets

26
New cards

How is the bucket containing each row in a hash table determined?

By a hash function and a hash key.

27
New cards

hash key

a column or group of columns used to determine the bucket that each row of a table is stored in

28
New cards

hash function

computes the bucket containing the row from the hash key and is designed to scramble row locations and evenly distribute rows across blocksm

29
New cards

What are the four steps of the modulo function?

  1. Convert the hash key by interpreting the key’s bits as an integer value.

  2. Divide the integer by the number of buckets.

  3. Interpret the division remainder as the bucket number.

  4. Convert the bucket number to the physical address of the block containing the row.

30
New cards

What is the disadvantage of a fixed hash function in a database that is planned to grow over time?

A fixed hash function simply allocates more rows to each bucket as tables grow, resulting in deep buckets with many blocks that a query may have to read in order to access a single row.

31
New cards

dynamic hash function

automatically allocates more blocks to a growing table, creates additional buckets, and distributes rows across all buckets to avoid deep buckets

32
New cards

Hash tables are optimal for __.

inserts and deletes of individual rows

33
New cards

Hash tables are slow on queries that select __.

many rows with a range of values

34
New cards

table clusters/multi-tables

tables that interleave rows of two or more tables in the same storage area using a cluster key

35
New cards

cluster key

a column that is available in all interleaved tables and determines the order in which rows are interleaved

36
New cards

Why are table clusters not commonly used?

They are only optimal for joining interleaved tables on the cluster key and perform poorly on many other queries.

37
New cards

single-level index

a file containing column values, along with pointers that identify either the block containing the row or the exact location of the row within the block

38
New cards

multi-column index

an index where each entry is a composite of values from all indexed columns

39
New cards

table scan

a database operation that reads table blocks directly, without accessing an index

40
New cards

index scan

a database operation that reads index blocks sequentially, in order to locate the needed table blocks

41
New cards

What are the two database operations that may be used to execute a SELECT query?

table scan or index scan

42
New cards

hit ratio/filter factor/selectivity

the percentage of table rows selected by a query

43
New cards

If hit ratio is __, a database will perform a table scan.

high

44
New cards

If hit ratio is __, a database will most likely use an index scan.

low

45
New cards

To estimate hit ratio, a database examines the __ of a SELECT query.

WHERE clause

46
New cards

What is the formula to calculate the number of blocks read in a binary search?

log2 N blocks

47
New cards

primary/clustering index

an index on a sort columns

48
New cards

secondary/nonclustering index

an index that is not on the sort column

49
New cards

All indexes of a heap or hash table are __, since they have no sort column.

secondary

50
New cards

dense index

contains an entry for every table row

51
New cards

sparse index

contains an entry for every table block

52
New cards

Why do secondary indexes have to be dense?

Because the data in the index column is not sorted, and therefore the first value of each block is meaningless for search purposes.

53
New cards

Database designers usually create a primary index on the __ of large tables.

primary key

54
New cards

What is the difference between a clustering index and a cluster key?

A cluster key refers to the column used to sort rows in a table cluster structure and is not an index.

55
New cards

In some database systems, primary and clustering indexes are indexes on __ sort columns, respectively.

unique and non-unique

56
New cards

Block splits and merges occur __ often for inserts, updates, and deletes on dense indexes than sparse ones.

more

57
New cards

How does a database with a dense index deal with deletes?

By marking the row as ‘deleted’ at the time and periodically removing deleted rows in batches.

58
New cards

multi-level index

a form of index that stores column values and row pointers in a hierarchy with each level more sparse than the one below it

59
New cards

Is the bottom level of a multi-level index sparse or dense?

Depends on whether the index column is primary or secondary. A secondary index column requires a dense index.

60
New cards

fan-out

the number of index entries per block in a multi-level index

61
New cards

Formula to calculate the number of levels in a multi-level index, assuming minimal free space

  • logfan-out(number of rows) = dense index # of levels

  • logfan-out(number of rows / rows per block) = sparse index # of levels

62
New cards

branch

each path from the top-level block to a bottom level block in a multi-level index

63
New cards

What does it mean if a multi-level index is balanced?

All of the branches are the same length

64
New cards

An insert into a table with a __ index without free space will always generate a new index level.

dense

65
New cards

What is the difference between a B+tree and a B-tree?

Index values may repeat between levels of a B+tree, which allows for pointers to table blocks only appearing in the bottom level. A B-tree does not repeat values between levels, and table pointers may appear at any level. B-trees are more compact, but harder to implement because table updates may cause table pointers to shift levels in the index.

66
New cards

hash index

an index where entries are assigned to buckets, similar to a hash table

67
New cards

Explain the difference between a hash index and a hash key.

A hash index is an index that is structured using a hash function while a hash key is a column that determines the physical location of rows in a hash table.

68
New cards

bitmap index

a grid of bits where each index row corresponds to a unique table row and each index column corresponds to a distinct value within the indexed table column

69
New cards

What does a 1 indicate in a bitmap index?

That the table row corresponding to the index row number contains the table value corresponding to the index column number.

70
New cards

A database reads the __ of a bitmap index first to find a value’s table location.

columns

71
New cards

What are the characteristics of an efficient bitmap index?

  1. The database can quickly determine the block containing a table row based on the index row number.

  2. The indexed column contains only tens or hundreds of distinct values to search.

72
New cards

physical index

a single- or multi-level index that contains pointers to table blocks

73
New cards

logical index

a single- or multi-level index in which pointers to table blocks are replaced with primary key values, which requires a separate primary index on the same table

74
New cards

How does a database locate a row containing a column value using a logical index?

  1. Looks up the column value in the logical index to find the primary key value.

  2. Looks up the primary key value in the primary index to find the table block pointer.

  3. Reads the table block containing the row.

75
New cards

What is the advantage of a logical index?

Logical indexes change only when primary key values are updated, which is much more rare than a change to physical index.

76
New cards

function index

an index where the database designer specifies a function on the column value and entries contain the result of the function applied to the column values

77
New cards

When is a function index useful?

When the values specified in the WHERE clause of queries are liable to be in a different format or unit than the values stored in the table.

78
New cards

tablespace

a database object that maps one or more tables to a single file

79
New cards

What is the syntax to create a tablespace in MySQL?

CREATE TABLESPACE TablespaceName
[ADD DATAFILE 'FileName'];

80
New cards

What is the syntax to assign a table to a tablespace?

At the end of a CREATE TABLE statement:

[TABLESPACE TablespaceName]

81
New cards

By default, most databases __ create one tablespace for each table.

automatically

82
New cards

Under what circumstances does it improve database performance to store multiple tables in one tablespace?

When the tables stored together are small to reduce overhead, commonly accessed in the same query to improve query performance, and/or they are read-only so assigning them to the same tablespace does not increase disk fragmentation.

83
New cards

partitions

subsets of table data that do not overlap with one another and are stored in separate tablespaces, specified either explicitly by the DBA or automatically by the database

84
New cards

Most relational databases partition tables __.

horizontally

85
New cards

range partition

a method of partitioning that associates each partition with a range of partition expression values

86
New cards

list partition

a method of partitioning that associates each partition with a set of partition expressions using the VALUES IN keywords

87
New cards

hash partition

a method of partitioning where the database administrator specifies the number of partitions, N, and the partition number for each row is then computed as: (partition expression value) modulo N.

88
New cards

key partition

a type of hash partition where the partition expression is determined automatically by the database

89
New cards

What aspect of queries does physical design impact?

performance

90
New cards

storage engine/storage manager

translates instructions generated by a query processor into low-level commands that access data on storage media

91
New cards

InnoDB

a storage engine with full support for transaction management, foreign keys, referential integrity, and locking

92
New cards

The default storage engine installed with the MySQL download is __.

InnoDB

93
New cards

What aspect of queries does logical design impact that physical design does not?

results

94
New cards

MyISAM

a storage engine with limited transaction management and locking capabilities that is often used for analytic applications with limited data updates

95
New cards

MEMORY

a storage engine that stores all data in main memory and is used for fast access with databases small enough to fit in main memory

96
New cards

What kinds of table structures does Oracle Database support that MySQL with InnoDB does not?

hash and cluster

97
New cards

Which storage engine allows MySQL to support both B+tree and hash indexes?

MEMORY

98
New cards

Specifying the index type for a table is a part of __ design.

physical

99
New cards

In MySQL with InnoDB, a table with a primary key will have a __ structure.

sorted

100
New cards

In MySQL with InnoDB, a table with no primary key will have a __ structure.

heap