D426

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

1/188

flashcard set

Earn XP

Description and Tags

Database management - foundations

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

189 Terms

1
New cards

database administrator

responsible for securing the database system against unauthorized users. A database administrator enforces procedures for user access and database system availability.

2
New cards

database designer

determines the format of each data element and the overall database structure. Database designers must balance several priorities, including storage, response time, and support for rules that govern the data. Since these priorities often conflict, database design is technically challenging.

3
New cards

Relational operation - Select

selects a subset of rows of a table.

4
New cards

Relational operation - Project

eliminates one or more columns of a table.

5
New cards

Relational operation - Product

lists all combinations of rows of two tables.

6
New cards

Relational operation - Join

combines two tables by comparing related columns.

7
New cards

Relational operation - Union

selects all rows of two tables.

8
New cards

Relational operation - Intersect

selects rows common to two tables.

9
New cards

Relational operation - Difference

selects rows that appear in one table but not another.

10
New cards

Relational operation - Rename

changes a table name.

11
New cards

Relational operation - Aggregate

computes functions over multiple table rows, such as sum and count.

12
New cards

Relational rules - Unique primary key.

All tables have a primary key column, or group of columns, in which values may not repeat.

13
New cards

Relational rules - Unique column names.

Different columns of the same table have different names.

14
New cards

Relational rules - No duplicate rows

No two rows of the same table have identical values in all column

15
New cards

Business rules

are based on business policy and specific to a particular database. Ex: All rows of the Employee table must have a valid entry in the DepartCode column.

16
New cards

Relational rules

Rules are logical constraints that ensure data is valid.

17
New cards

SQL syntax - clause

groups SQL keywords like SELECT, FROM, and WHERE with table names like City, column names like Name, and conditions like Population > 100000.

18
New cards

SQL syntax - Statement

is a complete command composed of one or more clauses.

19
New cards

Data Definition Language (DDL)

defines the structure of the database.

20
New cards

Data Query Language (DQL)

retrieves data from the database.

21
New cards

Data Manipulation Language (DML)

Manipulates data stored in a database

22
New cards

Data Control Language (DCL)

controls database user access.

23
New cards

Data Transaction Language (DTL)

manages database transactions.

24
New cards

A tuple

is an ordered collection of elements enclosed in parentheses.

25
New cards

table

has a name, a fixed tuple of columns, and a varying set of rows.

26
New cards

Column

Has a name and a data type

27
New cards

Row

Is an unamed tuple of values. Each value corresponds to a column and belongs to the column’s data type.

28
New cards

Data type

Is a named set of values, from which column values are drawn.

29
New cards

Rules Governing Tables

  1. Exactly one value per cell. A cell may not contain multiple values. Unknown data is represented with a special NULL value.

  2. No duplicate column names. Duplicate column names are allowed in different tables, but not in the same table.

  3. No duplicate rows. No two rows may have identical values in all columns.

  4. No row order. Rows are not ordered. The organization of rows on a storage device, such as a disk drive, never affects query results.

30
New cards

Synonym - table

File, Relation

31
New cards

Synonym - Row

Record, Tuple

32
New cards

Synonym - Column

Field, Attribute

33
New cards

Synonym - Data type

Domain, Data Type

34
New cards

Literals

Explicit values that are string, numeric, or binary.

Strings must be surrounded by single quotes or double quotes.

Binary values are represented with x'0' where the 0 is any hex value.

Example: 'String'

"String"

123

x'0fa2'

35
New cards

Keywords

Words with special meaning Example: SELECT, FROM, WHERE

36
New cards

Identifiers

Objects from the database like tables, columns, etc Example: City, Name, Population

37
New cards

database programmer

develops computer programs that utilize a database. Database programmers write applications that combine database query languages and general-purpose programming languages. Query languages and general-purpose languages have significant differences, so database programming is a specialized challenge.

38
New cards

database user

a consumer of data in a database. Database users request, update, or use stored data to generate reports or information. Database users usually access the database via applications but can also submit queries directly to the database system.

39
New cards

Query processor

interprets queries, creates a plan to modify the database or retrieve data, and returns query results to the application. The query processor performs query optimization to ensure the most efficient instructions are executed on the data.

40
New cards

Storage manager

translates the query processor instructions into low-level file-system commands that modify or retrieve data. Database sizes range from megabytes to many terabytes, so the storage manager uses indexes to quickly locate data.

41
New cards

Transaction manager

ensures transactions are properly executed. The transaction manager prevents conflicts between concurrent transactions. The transaction manager also restores the database to a consistent state in the event of a transaction or system failure.

42
New cards

Metadata

data about the database, such as column names and the number of rows in each table.

43
New cards

Database design phases

  1. Analysis

  2. Logical design

  3. Physical design

44
New cards

Database design - Analysis phase

Phase 1 the phase specifies database requirements without regard to a specific database system. Requirements are represented as entities, relationships, and attributes. An entity is a person, place, activity, or thing. A relationship is a link between entities, and an attribute is a descriptive property of an entity.

45
New cards

Entity relationship diagram - Rectangle

• Rectangles represent entities. Entity names appear at the top of rectangles.

46
New cards

Database design - Logical design phase

Phase 2 - The logical design phase implements database requirements in a specific database system. For relational database systems, logical design converts entities, relationships, and attributes into tables, keys, and columns.

47
New cards

Key

is a column used to identify individual rows of a table. Tables, keys, and columns are specified in SQL with CREATE TABLE statements.

48
New cards

Database design - Physical design phase

Phase 3 The physical design phase adds indexes and specifies how tables are organized on storage media.

49
New cards

In relational databases, how does logical and physical design affect queries?

Logical design affects the query result. Physical design affects query processing speed but never affects the query result. The principle that physical design never affects query results is called data independence.

50
New cards

Data independance

Data independence allows database designers to tune query performance without changes to application programs.

The term information independence is occasionally used instead of data independence. Synonymous terms.

51
New cards

MySQL Command-Line Client

Text interface included in MySQL Server download

52
New cards

"World database”

Included with MySQL

53
New cards

Error code

Returned when an SQL Statement is syntactically incorrect or the database cannot execute the statement.

54
New cards

Database Model

Conceptual framework for database systems, 3 parts:

  • Data structures that prescribe how data is organized.

  • Operations that manipulate data structures.

  • Rules that govern valid data.

55
New cards

Cell

Single column of a single row

56
New cards

INT or Integer

Integer values

TINY INT 1 bytes

SMALLINT 2 bytes

MEDIUMINT 3 bytes

INTEGER or INT 4 bytes

BIGINT 8 bytes

57
New cards

VARCHAR(N)

Values with 0 to N characters

58
New cards

DATE

Format: YYYY-MM-DD. Range: '1000-01-01' to '9999-12-31'

59
New cards

DATETIME

Format: YYYY-MM-DD hh:mm:ss. Range: '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.

60
New cards

DECIMAL

numeric values with M digits, of which D digits follow the decimal point

DECIMAL(M,D)

FLOAT 4 bytes

DOUBLE 8 bytes

61
New cards

ALTER TABLE

Adds, deletes, or modifies columns on an existing table.

62
New cards

Data type

a named set of values from which column values are drawn.

63
New cards

Integer

data types represent positive and negative integers. Several integer data types exist, varying by the number of bytes allocated for each value. Common integer data types include INT, implemented as 4 bytes of storage, and SMALLINT, implemented as 2 bytes.

64
New cards

Operator arithmetic - % (modulo)

Divides one numeric value by another and returns

the integer remainder

65
New cards

Operator artithmetic - ^ (exponent)

Raises one numeric value to the power of another

66
New cards

Operator comparison - “=”

Compares two values for equality

67
New cards

Operator comparison - “!=”

Compares two values for inequality.

68
New cards

NULL

a special value that represents either unknown or inapplicable data.

69
New cards

INSERT statement

Statement adds rows to a table

EX: INSERT [INTO] TableName (Column1, Column2, ...)

VALUES (Value1, Value2, ...);

70
New cards

UPDATE statement

The UPDATE statement uses the SET clause to specify the new column values.

71
New cards

DELETE statement

The DELETE statement deletes existing rows in a table. The FROM keyword is followed by the table name whose rows are to be deleted

72
New cards

TRUNCATE statement

The TRUNCATE statement deletes all rows from a table. TRUNCATE is nearly identical to a DELETE statement with no WHERE clause except for minor differences that depend on the database system.

73
New cards

MERGE statement

The MERGE statement selects data from one table, called the source, and inserts the data to another table, called the target.

74
New cards

Primary Key

is a column, or group of columns, used to identify a row. The primary key is usually the table's first column

75
New cards

Simple Primary Key

A simple primary key consists of a single column.

76
New cards

Composite Primary Key

Consists of multiple columns.

77
New cards

Auto-increment column

A numeric column that is assigned an automatically incrementing value when a new row is inserted.

78
New cards
79
New cards

What errors do users occasionally make when inserting primary keys?

  • Inserting values for auto-increment primary keys.

  • Omitting values for primary keys that are not auto-increment columns.

    MySQL allows insertion of a specific value to an auto-increment column. However, overriding auto-increment for a primary key is usually a mistake.

80
New cards

Foreign Key

Is a column , or group of columns that refer to a primary key.

81
New cards

FOREIGN KEY constraint

A foreign key constraint is added to a CREATE TABLE statement with the FOREIGN KEY and REFERENCES keywords. When a foreign key constraint is specified, the database rejects insert, update, and delete statements that violate referential integrity.

82
New cards

Referential integrity action - RESTRICT

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

83
New cards

Referential integrity action - SET NULL

Sets invalid foreign keys to NULL

84
New cards

Referential integrity action - SET DEFAULT

Sets invalid foreign keys to NULL

85
New cards

Referential integrity action - CASCADE

Propagates primary key changes to foreign keys.

86
New cards

Constraint

A constraint is a rule that governs allowable values in a database. Constraints are based on relational and business rules, and implemented with special keywords in a CREATE TABLE statement.

87
New cards

UNIQUE constraint

The UNIQUE constraint ensures that values in a column, or group of columns, are unique.

88
New cards

CHECK constraint

The CHECK constraint specifies an expression on one or more columns of a table.

89
New cards

How are Constraints added or dropped?

Constraints are added and dropped with the ALTER TABLE TableName followed by an ADD, DROP, or CHANGE clause.

90
New cards

Operators and Clauses - IN operator

The IN operator is used in a WHERE Clause to determine if a value matches one of several values.

91
New cards

Operators and Clauses - BETWEEN operator

The BETWEEN operator provides an alternative way to determine if a value is between two other values.

92
New cards

Operators and Clauses - LIKE operators

The LIKE operator, when used in a WHERE clause matches text against a pattern using the two wildcard characters % and _.

• % matches any number of characters. Ex: LIKE 'L%t' matches "Lt", "Lot", "Lift", and "Lol cat".

matches exactly one character. Ex: LIKE 'Lt' matches "Lot" and "Lit" but not "Lt" and "Loot".

93
New cards

Operators and Clauses - DISTINCT clause

Is used with a SELECT statement to return only unique or ‘distinct’ values.

94
New cards

Operators and Clauses - ORDER BY clause

A SELECT statement selects rows from a table with no guarantee the data will come back in certain order. THE ORDER BY clause orders selected rows by one or more columns in ascending (alphabetic or increasing) order. The DESC keyword with the ORDER BY clause orders rows in descending order.

95
New cards

Numeric functions - Function

A function operates on an expression enclosed in parentheses called an argument, and returns a value.

96
New cards

Numeric functions - ABS(n)

Returns the absolute value of n

EX: SELECT ABS(-5)

returns 5

97
New cards

String functions

String functions manipulate string values.

98
New cards

String function - LOWER(s)

Returns the lowercase (s)

EX: SELECT LOWER (‘MYSQL’);

returns ‘mysql’

99
New cards

String function - TRIM(s)

Returns the string s without leading and trailing spaces

EX: SELECT TRIM(‘ test ‘);

returns ‘test’

100
New cards

Date and Time functions

Operate on DATE, TIME, and DATETIME datatypes