Week 3 Flashcards

1
Q

What is the functional dependency theory?

A

It quantifies the degree of “goodness”.

X uniquely determines Y holds if whenever two tuples have the same value for X, they must have the same value for Y.

Definition: for any two tuples t1 and t2 in the relation R:
if t1[X]=t2[X] then t1[Y] = t2[Y]

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

What is the Normalization Theory?

A

It is for transforming a relational schema into a set of “good” and “efficient” relations.

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

What is the Boyce-Codd Normal Form (BCNF)?

A

We can transform any relation into this.

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

What metrics are used to judge whether we are dealing with a good relational schema?

A

1) goodness - whether the attributes (e.g. FK/PK) for a “good” relation
2) quantify the degree of goodness
3) What pitfalls exist?
4) efficiency in insert/delete/update operations
5) convey as much info as possible minimising redundancy (minimise repetition of data)

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

What are the four guidelines for a good design?

A

1) the attributes of a relation should make sense (and reflect the context of entities!)
2) avoid redundant tuples: it can be costly for storage, we might have inconsistency
3) Relations should have as few NULL values as possible - avoids wasting storage.
4) Design relations to avoid fictitious tuples after join - i.e. tuples that weren’t there before.

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

What is the definition of the join algorithm?

A

For each tuple q in Q, join with each tuple p in P iff q.Plocation=p.Plocation.
Result: r=(p,q).

Challenge: once p and q have been split into sub relations, we need to be careful not to create fictitious tuples when rejoining back.

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

Functional Dependency Lemma: if K is a candidate key, then…

A

K functionally determines all attributes in relation R, i.e.

FD: K -> {R}

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

What is the transitive characteristic of functional dependency?

A

If X–> Y (i.e X functionally determines Y) and Y–> Z, then X–> Z

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

If we have functional dependencies, can we derive the candidate key(s) of a relation?

A

yes. Use transitive characteristics of functional dependencies to figure out the candidate keys.

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

What is the theory of normalisation?

A

Progressive decomposition of unsatisfactory relations by breaking up their attributes into smaller “good” relations.

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

What is a prime attribute?

A

An attribute that belongs to some candidate key of the relation.

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

What is a non-prime attribute?

A

It’s not a prime attribute, i.e. it is not a member of any candidate key

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

What is the first normal form?

A

The domain Di of each attribute Ai in a relation R refers only to atomic (simple/indivisible) values.

1NF disallows:

  • nested attributes
  • multivalued attributes: you have to introduce new tuples. Not a good relation though because you’ll get lots of duplicates.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the second normal form?

A

Assume that X is the primary key.
Definition: full functional dependency X on Y means that if we remove any prime attribute A from the primary key X, then:
X{A} is not a FD on Y.

“Full” FD means that we need both primary keys in the composite PK.
“Partial” FD means that we can take one of the PKs and it will determine the attribute Y.

Defn of 2NF: a relation R is in 2NF if every non-prime attribute A in R is fully functionally dependent on the primary key of R.

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

How do we move from 1NF to 2NF?

A

We need to remove all prime attributes from the primary key, which cause partial dependencies.
Methodology:
1) Identify all the partial FDs in the original relation.
2) For each partial FD, create a new relation such that all non-prime attributes in there are fully functionally dependent on the new primary key:
i.e. the prime attribute in the original relation causing partial FDs.
3) The relation will be 2NF.

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

What is 3NF?

A

Definition: transitive FD means that given a Primary Key X and non-prime attributes Z and Y such that X->Z and Z->Y, then the non-prime Y is transitively dependent on the primary key X via the non-prime Z.

eg if we have courseID being the PK and:
FD1: courseID –> lecturer
FD2: lecturer –> school
FD3: courseID –> School (via the non-prime lecturer)

Definition of 3NF: for X,Y,Z attributes, where X is a PK, we consider this as a problem iff Z is a non-prime attribute.

Generalised 3NF: Every non-prime attribute A in the relation R:

1) is fully functionally dependent on every candidate key in R
2) is non-transitively dependent on every candidate key in R

17
Q

what is the Boyce-Code Normal Form (BCNF)?

A

The most efficient relational schema.
The idea is to remove all inherent dependencies: any attribute should be FD only on the PK.
A relation is in BCNF iff whenever there exists a FD:X–>A then X is a PK, i.e. the LHS should be a PK.

18
Q

what is the Boyce-Code Normal Form (BCNF) decomposition theorem?

A

Purpose: to mitigate fictitious tuples.
Theorem 1: Let relation R not in BCNF and let X–>A be the FD which causes a violation in BCNF.

Then, the relation R should be decomposed into two relations:

1) R1 with attributes: R{A} (all attributes in R apart from A)
2) R2 with attributes: {X} U {A} (put together X and A)
(i. e create a new relation with the violating attribute A)

If either R1 or R2 is not in BCNF, repeat the process.

19
Q

How do we determine a non-prime transitive attribute in a 3NF functional dependency?

A

1) doesn’t belong to any candidate key
2) belongs to the LHS of the functional dependency

i.e. the middle man that’s responsible for a transitive FD.

20
Q

How do you find out if you can further normalise a set?

A

If you can firstly identify functional dependencies, you can figure out if you can further normalise.

21
Q

Is the aim of the 3NF to remove every transitive FD in a relation?

A

Yes

22
Q

What risk do you face if you are not in the Boyce-Code Normal Form (BCNF)?

A

You run the risk of your system not being efficient (avoid having update anomalies) and fictitious tuples.