CS 327e Databases Midterm

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/178

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

179 Terms

1
New cards

What are some effects of poor database design?

1. Data inconsistency

2. Unnecessary duplicated data

3. Retrieving inaccurate data

4. Untimely queries

2
New cards

What are the three types of data relationships?

1. One-to-one

2. One-to-many

3. Many-to-many

3
New cards

What kind of identifiers should a primary key use?

Arbitrary identifiers or concatenation of arbitrary identifiers

4
New cards

Entity

An object represented by a database; it is represented in relations and tables once the database is constructed

5
New cards

Columns

Describes the properties of a specific entity; it represents fields or attributes

6
New cards

Row

An instance of an entity; represented as a tuple

7
New cards

Schema

The structure of a database such as the name of the table, the columns and their types, the domain of the columns, etc. It also includes entity relationships.

8
New cards

Keys

Identifiers for tables

9
New cards

Primary Keys

Every table needs one; they uniquely identify each row in a table; by convention, they are usually underlined

10
New cards

Foreign Keys

How parent tables are related to child tables

11
New cards

SQL

Structured Query Language; language used by every relational database

12
New cards

DDL

Data Definition Language; actions that cannot be rolled back in SQL such as create table and alter table

13
New cards

DML

Data Manipulation Language; commands that can be rolled back such as inserts, updates, and deletes

14
New cards

What are the three types of data anomalies?

1. Insertion Anomaly

2. Update Anomaly

3. Deletion Anomaly

15
New cards

Insertion Anomaly

When the design of the table prevents the user from inserting new elements when necessary. Instead, restrictions on insertion force the user to wait until a certain event occurs (i.e. a user can't create a new item until someone orders it).

16
New cards

Update Anomaly

Occurs when there is too much duplication within a database such that it causes an error when some but not all of the duplicates are updated after a change in state of an entity.

17
New cards

Deletion Anomaly

Occurs when removing one entity or variable causes the deletion of other information that the user does not want to remove.

18
New cards

Instance

A group of attributes that describes a single real-world occurrence of an entity.

19
New cards

Entity Identifier

An attribute that uniquely identifies an entity occurrence.

20
New cards

Natural Indentifier

Entities that are already assigned arbitrary identifiers such as invoices or customer numbers

21
New cards

Constraint

Allows the user to disallow various inputs such as null values or non-uniqueness; helps to maintain data consistency and accuracy

22
New cards

Single-Valued Attribute

For a given instance of an entity, each attribute can have only one value.

23
New cards

Multivalued Attribute

An entity cannot have one of these, so the user must handle these attributes by creating an entity to hold them in. These types of values slow down searching and place unnecessary restrictions on the amount of data that can be stored.

24
New cards

Entity-Relationship Diagrams (ERD)

Provide a way to document the entities in a database along with the attributes that describe them.

25
New cards

What are the three major ERDs?

1. The Chen Model

2. Information Engineering (IE)

3. Unified Modeling Language (UML)

26
New cards

Unified Modeling Language (UML)

Specifically intended for the object-oriented environment and is usually the choice when objects are included

27
New cards

Domain

An expression of the permissable values for an attribute.

28
New cards

Data Dictionary

Stores the domains and their constraints.

29
New cards

BLOB

Binary Large Object; can store anything binary such as graphic; supported by most DBMSs

30
New cards

What do the relationships in a database describe?

The relationships between instances of entities

31
New cards

Weak Entity

An entity that cannot exist in the database unless a related instance of another entity is present and related to it; it must use a foreign key in conjunction with its attributes to create a primary key. The foreign key is typically a primary key of an entity it is related to.

32
New cards

Mandatory Relationship

When one entity occurrence requires a corresponding entity occurrence.

33
New cards

|| (On an IE Style Diagram)

Means one and one only (mandatory relationship)

34
New cards

0| (On an IE Style Diagram)

Zero or one

35
New cards

>1 (On an IE Style Diagram)

One or more (mandatory relationship)

36
New cards

>0 (On an IE Style Diagram)

Zero, one, or more

37
New cards

Relationship Data

Data that apply to the relationship between two entities, rather than to the entities themselves.

38
New cards

Composite Entities

Exist to represent the relationship between two or more entities.

39
New cards

Data Flow

Shows how data are handled within an organization, including who handles that data, where the data is stored, and what is done to the data.

40
New cards

Data Model

Depicts the internal, logical relationships between the data without regard to who is handling the data or what is being done with them.

41
New cards

Relation

A table with columns (attributes) and rows (tuples).

42
New cards

Column Homogeneous

When the values in a column are drawn from one and only one domain.

43
New cards

Base Tables

Relationships that are actually stored in the database; they are described by a schema

44
New cards

What are the requirements for a column?

1. A name that is unique within the tables

2. A domain

3. Columns can be viewed in any order without affecting the meaning of the data

45
New cards

What are the requirements for a row?

1. Only one value at the intersection of a column and row (no multi-valued attributes)

2. Uniqueness

3. Primary key

4. The rows can be viewed in any order without affecting the meaning of the data

46
New cards

Virtual Tables

Copies of data in the base tables and are never stored in the database

47
New cards

Can primary keys have null values?

No (entity integrity)

48
New cards

Candidate Key

The possible primary keys in a table.

49
New cards

What are the requirements of a primary key?

1. Should have a value that is highly unlikely to ever be null

2. Should be immutable

3. Should avoid meaningful data - use arbitrary identifiers

50
New cards

Referential Integrity

Every non-null foreign key value must match an existing primary key value

51
New cards

Normalization

Creating relations that avoid most of the problems that arise from bad relational design.

52
New cards

Decompose

Taking projections of a relation to create more than one relation.

53
New cards

Normal Forms

Represent an increasingly stringent set of rules; the higher the level, the better the design of the relation.

54
New cards

What is the most common normal form?

Third (3NF)

55
New cards

First Normal Form Criterira

1. The data are stored in a two-dimensional table

2. There are no repeating groups

56
New cards

What is the order of the normal forms from least specific to most?

1. First NF

2. Second NF

3. Third NF

4. Boyce-Codd NF

5. Fourth NF

6. Fifth NF

57
New cards

Repeating Group

An attribute that has more than one value in each row of a table; analogous to a multivalued attribute in an ER diagram

58
New cards

How should you handle a repeating group?

Create another table to handle multiple instances of the repeating group.

59
New cards

Second Normal Form Criterira

1. The relation is in first normal form

2. All non-key attributes are functionally dependent on the entire primary key

60
New cards

Functionally Dependent

One-way relationship between two attributes such that at any given time, for each unique value of attribute A, only one value of attribute B is associated with it throughout the relation.

61
New cards

Determinant

An attribute that determines the value of other attributes.

62
New cards

Third Normal Form Criterira

1. The relation is in second normal form

2. There are no transitive dependencies

63
New cards

Transitive Dependencies

Exist when you have the functional dependency pattern:

A -> B and B-> C therefore A -> C

64
New cards

Boyce-Codd Normal Form Criterira

1. The relation is in third normal form

2. All determinants are candidate keys

65
New cards

Multivalued Dependency

Exists when for each value of attribute A, there exists a finite set of values of attribute B that are associated with it, and a finite set of values of attribute C that are also associated with it. Attributes B and C are independent of each other.

66
New cards

Join Dependency

Occurs when a table can be put together correctly by joining two or more tables, all of which contain only attributes from the original table

67
New cards

Can you delete a table with the CREATE TABLE SQL statement?

No

68
New cards

Conceptual Diagrams

Represent the entities, attributes, and relationship types of a database

69
New cards

Physical Diagrams

Show the keys, junction tables, datatypes of a database

70
New cards

What is the hierarchy of a database from lowest to highest?

Columns and rows -> tables and views -> schemas -> catalogs -> clusters

71
New cards

Permanent Base Tables

Tables whose contents are stored in the database and remain permanently in the database unless they are explicitly deleted.

72
New cards

Global Temporary Tables

Tables for working storage that are destroyed at the end of a SQL session; must be loaded with data each time they are going to be used

73
New cards

Local Temporary Tables

They are visible only to the specific program module in which they are created

74
New cards

CASCADE

Delete or update all foreign key rows

75
New cards

RESTRICT

Does not allow deletions of primary key rows

76
New cards

ALTER TABLE

How you can modify almost any characteristic of a table

77
New cards

MODIFY

SQL command that can replace a complete column definition and make new column characteristics

78
New cards

PostgresSQL

Open source object relational database management system

79
New cards

CREATE TABLE

Can clone a table, can be used to materialize the result of the SELECT statement to boost performance, or to create a new table in the database

80
New cards

\dt:

Looks at a list of tables in a database

81
New cards

\c:

Connects to a database

82
New cards

\i:

Runs the commands in a script

83
New cards

\?:

Help

84
New cards

\copy:

Loads the dataset into a table as long as a table already exists

85
New cards

TRUNCATE

Removes all of the rows of data but not the actual table in a database

86
New cards

DROP

Removes all the data in a table along with the table itself

87
New cards

How do you create a foreign key in SQL?

REFERENCES Table(column)

88
New cards

How do you select all of the data from a file in SQL?

SELECT * FROM column_name

89
New cards

How do you create aliases in SQL?

FROM column_name AS alias

90
New cards

DISTINCT

Only unique rows from the input dataset will be returned

91
New cards

ALL

Returns all rows and is the default in SQL

92
New cards

Cartesian Product

All possible combinations of records.

93
New cards

Inner Join

Includes rows in the query only when the joined field matches records in both tables

94
New cards

Full Outer Join

A join in which all rows from both tables will be included regardless of whether they match rows from the other table

95
New cards

Left Outer Join

Where the query includes all of the rows from the table on the left and only those records from the table on the right that match the join field in the left table.

96
New cards

Right Outer Join

Where the query includes all of the rows from the table on the right and only those rows from the table on the left that match the join field in the right table.

97
New cards

Natural Join

Creates an implicit join clause for you based on the common columns in the two tables being joined. Common columns are columns that have the same name in both tables; can be an INNER join, a LEFT OUTER join, or a RIGHT OUTER join.

98
New cards

Which types of joins return null values?

Outer joins

99
New cards

How do you filter rows in SQL?

Using the WHERE clause

100
New cards

Grouping

Splitting the whole input set of records into several groups with a view to have only one result row for each group.