Normalisation and Constraints Flashcards

(32 cards)

1
Q

What problem does normalisation solve?

A

It removes repeated data across many rows and prevents inconsistencies.

Normalisation is essential for maintaining data integrity in databases.

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

Why is repeating customer addresses a problem?

A

If the customer moves house, the address must be changed everywhere → causes errors.

This can lead to outdated or incorrect information in the database.

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

Why is repeating product name & price a problem?

A

Any change must be updated in every row → leads to inconsistent data.

This can result in discrepancies in product information across the database.

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

How does normalisation fix these issues?

A

By splitting data into focused tables linked by IDs.

This approach minimizes redundancy and enhances data integrity.

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

What is the core idea of normalisation?

A

Each fact is stored in one place only.

This principle helps to avoid data duplication.

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

What do other tables store instead of repeating data?

A

ID references (foreign keys).

Foreign keys maintain relationships between tables.

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

What is the typical goal of normalisation in real systems?

A

Reach Third Normal Form (3NF).

3NF is a standard for reducing redundancy and dependency.

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

What does 1NF stand for?

A

First Normal Form.

1NF is the initial step in the normalisation process.

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

What does 1NF require?

A

Each cell has one value only (atomic values).

This ensures that data is stored in its simplest form.

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

What is a violation of 1NF?

A

“Laptop, Headphones” stored in one cell.

This violates the atomicity requirement of 1NF.

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

Why is 1NF important?

A

Prevents junk cells, makes filtering and counting easy.

This improves the overall efficiency of data handling.

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

When does 2NF matter?

A

Only when the primary key is composite.

2NF addresses issues that arise from composite keys.

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

What is the rule of 2NF?

A

No partial dependencies — every non-key column must depend on the whole key.

This ensures that all attributes are fully functionally dependent on the primary key.

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

What is a partial dependency?

A

A column depends on only part of the composite key.

This can lead to redundancy and inconsistency.

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

Example of fixing 2NF?

A

Split Products, Orders, and OrderDetails into separate tables.

This helps eliminate partial dependencies.

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

Key benefit of reaching 2NF?

A

Product prices are stored once — no repeated product info.

This reduces redundancy and potential errors.

17
Q

What is the rule of 3NF?

A

No transitive dependencies.

This ensures that non-key attributes are not dependent on other non-key attributes.

18
Q

What is a transitive dependency?

A

A non-key column depends on another non-key column (not the primary key).

This can lead to unnecessary data duplication.

19
Q

Example of a 3NF violation?

A

Orders table storing CustomerName and CustomerAddress.

This violates the principle of 3NF by having non-key attributes depend on each other.

20
Q

How do you fix a 3NF violation?

A

Move customer details into a Customers table.

This separates the data into appropriate tables.

21
Q

Key benefit of 3NF?

A

Only update customer address in one place.

This enhances data integrity and reduces maintenance effort.

22
Q

Why is normalisation useful in real systems?

A

Gives clean data, fewer errors, easier reporting.

This improves the overall quality of data management.

23
Q

What is the rule of thumb?

A

Aim for 3NF, then denormalise only if needed for performance.

This approach balances data integrity with performance needs.

24
Q

What is over-normalisation?

A

Splitting info (like address) into too many tiny tables → unnecessary joins.

This can complicate queries and reduce performance.

25
What is a **primary key**?
A unique, non-NULL identifier for each row. ## Footnote Primary keys are essential for maintaining data integrity.
26
Why does a **primary key** matter?
Lets the database find rows quickly and anchors relationships. ## Footnote This is crucial for efficient data retrieval.
27
Best practice for **primary keys**?
Use an auto-generated numeric ID. ## Footnote This simplifies the management of primary keys.
28
What is a **foreign key**?
A column that points to the primary key in another table. ## Footnote Foreign keys establish relationships between tables.
29
What does a **foreign key** enforce?
Prevents orphan records and keeps relationships valid. ## Footnote This maintains referential integrity in the database.
30
What is a **unique constraint**?
Ensures no two rows have the same value in a column (e.g., email). ## Footnote Unique constraints help maintain data integrity.
31
What is a **composite primary key**?
A key made from more than one column (e.g., StudentID + CourseID + Semester). ## Footnote Composite keys are used in many-to-many relationships.
32
When is a **composite key** used?
Many-to-many linking tables. ## Footnote This allows for effective representation of complex relationships.