Normalisation + relational Algebra Flashcards

(28 cards)

1
Q

What are the conditions for 1st normal form

A
  • having no mixed data types within the same column
  • a table must have a primary key
  • each row must contain one piece of data not multiple (no repeating groups - every cell must have one value (atomic))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the conditions for 2nd normal form

A
  • There must be no partial dependancies
    i.e each non-key attribute must depend entirely on the primary key
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define a transitive dependancy

A

If A -> B and B -> C, then C is transitive dependant on A via B: A -> C

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

Define Partial functional dependancy

A

Gives A -> B, if removing some attribute(s) from A, the dependency still holds.

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

Define a full functional dependancy

A

IF A -> B and B is not functionally dependant on any subset of A.

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

How do you convert to 2NF

A

must be 1NF and have no partial dependancies

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

What is a partial dependancy

A

when a non-key attribute depends on only part of the a composite primary key

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

How do you fix partial dependancies (2NF)

A

split the table so attributes that depend only on one part of the key go into their own table

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

What is 3NF

A

Must be 2NF and have no transitive dependencies

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

What is a transitive dependency

A

A non-key attribute depending on another non-key attribute

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

Give an explain of a transitive dependancy

A

A transitive dependency is when a non-key attribute depends on another non-key attribute, not directly on the key.
Example:
Table: Product(ProductID, ProductName, CategoryName, CategoryDescription)
Key = ProductID
CategoryDescription depends on CategoryName, not directly on ProductID → transitive dependency → violates 3NF.

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

What is a partial dependency? Give an example.

A

A partial dependency is when a non-key attribute depends on only part of a composite primary key, not the whole key.

Example:
Table: OrderLine(OrderID, ProductID, CustomerName, Qty)
Composite PK = (OrderID, ProductID)
CustomerName depends only on OrderID, not ProductID → partial dependency → violates 2NF.

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

When is 2NF relevant

A

only when the table has a composite primary key (otherwise it already is in 2NF)

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

What is relational algebra

A

provides a way to query the data in a database and to modify the data

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

What operator is used to select rows where a condition is true

A

Selection (σ)

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

give an example of selector age from employee table that is greater than 30

A

σ_(AGE > 30)(Employee)

17
Q

What is the operator for selecting certain columns in a table to present

A

Projection (π)

18
Q

Give an example of how you would use projection and its meaning

A

Meaning: Choose these attributes only.”
Example:
π_(CUS_NAME, CUS_PHONE)(Customer)

19
Q

What is the operator issued to rename a relation or an attribute

A

Renaming (ρ)

20
Q

How does does union select data from two tables (R and S)

A

from either R or S. Eliminate duplicate tuples

21
Q

How does does intersection select data from two tables (R and S)

A

selects rows that is from both R and S

22
Q

How does does Set Difference select data from two tables (R and S) (R-S)

A

From R, but not S

23
Q

Answer this in relational algebra: Find the lecturers who work in 01 or 03 department and age is below 50

A

r_(deptID=’01’ (or - symbol) deptID=’03’) (and-symbol) (age<50) (lecture) - this is upper case but is used to say which table you selected it from

24
Q

What is the cartesian product (x)

A

R x S: produces a relation that is the concatenation of every tuple relation of R with every tuple of relation S

  • if both R and S have the same attribute A, then use: R.A and S.A
25
What is a join operator
joins two tables over a shared attribute
26
Explain a theta join
a theta join is very similar to a join but when tables have different names for the same atribute they have to be joined by a specific condition i.e Customer ⋈_(Customer.CUS_ID = Visit.CUS_ID) Visit
27
What does DEFAULT do
sets an automatic value when none is specified
28
Show how default can be used
CREATE TABLE products ( product_id INT, product _name VARCHAR (25), price ):