Test 2 Study Guide Flashcards

1
Q

Define “relation”.

A

A relation is a named, two-dimensional table of data.

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

What are the requirements for a table to qualify as a relation?

A

It must have a unique name.
Every attribute value must be atomic (not multivalued).
Every row must be unique.
Attribute columns must have unique names.
The order of the rows and columns must be irrelevant.

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

What do relations correspond to in the E-R model?

A

Relations correspond with entity types and with M:N relationship types.

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

What do rows correspond to in the E-R model?

A

Rows correspond with entity instances and with M:N relationship instances.

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

What do columns correspond to in the E-R model?

A

Columns correspond with attributes.

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

How are primary keys notated in a relational schema?

A

Primary keys are underlined with a solid line.

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

How are foreign keys notated in a relational schema?

A

Foreign keys are underlines with a dotted line.

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

Define “domain constraint”.

A

A domain constraint is a way to limit what data values can be placed in an attribute (such as integers, max digits, etc).

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

Define “entity integrity”.

A

Entity integrity is when no primary key attributes are allowed to be null, and all primary key fields have data.

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

Define “referential integrity constraint”.

A

Referential integrity constraint is where any foreign key value (on the “many” side) must match a primary key value on in the relation of the “1” side.

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

When converting from an ERD to a relational schema, what happens to composite attributes?

A

Composite attributes are split into their individual component attributes.

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

When converting from an ERD to a relational schema, what happens to multivalued attributes?

A

Multivalued attributes are split off into their own relation with a foreign key relating back to the superior entity.

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

When converting from an ERD to a relational schema, what happens to weak entities?

A

Weak entities are broken off into a separate relation, with a foreign key taken from the strong entity. The primary key of this relation is a partial identifier of the weak entity, and the primary key of the strong entity.

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

When converting from an ERD to a relational schema, what happens to a 1:M relationship?

A

The primary key on the 1 side of the relationship becomes a foreign key on the many side.

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

When converting from an ERD to a relational schema, what happens to a M:N relationship?

A

A new relation is created with a primary key made of the primary keys of each side. These do not act as foreign keys.

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

When converting from an ERD to a relational schema, what happens to a 1:1 relationship?

A

The primary key on the mandatory side becomes a foreign key of the optional side.

17
Q

When converting from an ERD to a relational schema, what happens to an associative entity?

A

If the identifier of the associative entity isn’t assigned, then it defaults to the a composite primary key made of the primary keys of the two entities. Otherwise, the primary keys of the two many entities become foreign keys.

18
Q

When converting from an ERD to a relational schema, what happens to a unary relationship?

A

A 1:M unary relationship becomes a recursive foreign key in the same relation (so, two EMP_IDs, although with different names).
A M:N unary relationship becomes two relations, one for the entity type, and one for an associative relation, in which the primary key has two attributes, one taken from the primary key of the entity, the other created for the relation. So, if you have an item that can have multiple components (also items), it would be broken into two relations, ITEM and COMPONENT. Component would have its primary keys set as Item_No and Component_No.

19
Q

When converting from an ERD to a relational schema, what happens to ternary and N-ary relationships?

A

Ternary and N-ary relationships have a relation created for each entity, and one for the associative entity. The associative entity has a foreign key to each entity in the relationship.

20
Q

When converting from an ERD to a relational schema, what happens to supertype/subtype relationships?

A

The supertype is converted to a relation, and so is each subtype, each keeping their respective attributes. Each subtype inherits its parent’s primary key, with the determinator character prepended to it.

21
Q

Define “data normalization”.

A

Data normalization is the process of decomposing relations with anomalies to produce smaller, well-structured relations. It’s a tool to validate and improve logical designs, so that they avoid unnecessary data duplications.

22
Q

What are the three types of data anomalies?

A

There are three types of data anomalies:
Insertion anomalies: Adding new rows forces the user to create duplicate data.
Deletion anomalies: Deleting rows may cause a loss of data that would be needed for other future rows.
Modification anomalies: Changing data in a row forces changes in other rows due to duplication.

23
Q

What is the “rule of thumb” for good normalization?

A

The general rule of thumb is that a table should never pertain to more than one entity type.

24
Q

What is functional dependency?

A

Functional dependency is when the value of one attribute (also called the determinant) determines the value of another.

25
Q

Define “determinant”.

A

A determinant is an attribute that defines the value of another in a functional dependency.

26
Q

Define “candidate key”.

A

A candidate key is a unique identifier. These are ideal to become primary keys. Any non-key attribute is functionally dependent on every candidate key.

27
Q

What does 1st normal form look like?

A

In 1st normal form, or 1NF, there are no multivalued attributes. That’s all.
By default, all relations are in 1NF.

28
Q

What does 2nd normal form look like?

A

In 2nd normal form, or 2NF, it is the same as 1NF, with the addition that every non-key attribute is fully-functionally-dependent on the entire primary key. If there is an attribute that is unrelated to the entire primary key, it is not in 2NF.

29
Q

What are the steps to convert from 1NF to 2NF?

A

Create a new relation for each primary key attribute that is a determinant in a partial dependency. That attribute becomes that relation’s primary key.
Move the non-key attributes dependent on the new primary key to the new relation.

30
Q

What does 3rd normal form look like?

A

In 3rd normal form, or 3NF, it is the same as 2NF, but with the additional stipulation that there are no transitive dependencies. That means that there are no functional dependencies on non-primary-key attributes.

31
Q

What is a transitive dependency?

A

A transitive dependency is a functional dependency, once removed; that is, a functional dependency that is dependent on a non-primary key, which is in turn dependent on a primary key.

32
Q

What are the steps to convert from 2NF to 3NF?

A

Non-key determinants with transitive dependencies go into a new relation as a primary key, but also stays as a foreign key in the old relation. It’s dependents go along with it.

33
Q

What are the three types of functional dependency?

A

Full - Where the attribute is dependent on the entire primary key.
Partial - Where the attribute is dependent on only part of a composite primary key.
Transitive - Where the attribute is dependent on a non-key attribute, which in turn is dependent on a key attribute.

34
Q

What is denormalization?

A

Denormalization is the process of reversing normalization. It’s useful in that there are some situations where an unnormalized table is a better choice for a database. Normalization of a table usually creates more tables, which requires joins, which are tricky as far as system speed.