Showing posts with label Normal Forms. Show all posts
Showing posts with label Normal Forms. Show all posts

Monday, February 17, 2025

3NF and BCNF Compared

Third normal form and boyce-codd normal form a comparison


Difference between 3NF and BCNF


Assume the following things;
A and B are set of attributes.
A is non-key attribute and B is the primary key.
FD – { A B. }
The above Functional Dependency is about the dependency of primary key on a non-key attribute. This functional dependency is permitted in Third Normal Form (3NF). 3NF tries to identify and eliminate Non-key Non-key dependency.

This Functional Dependency is not permitted in Boyce-Codd Normal Form (BCNF), because BCNF expects the determiner should be a candidate key. In our example, A is not a candidate key. This is why BCNF is termed as strict 3NF.

3NF is always achievable. BCNF is not. BCNF may result in Loss-less Join Decomposition and lead to loss of Dependency Preserving Decompositions.

Properties
3NF
BCNF
Achievability
Always achievable
Not always achievable
Quality of the tables
Less
More
Non-key Determinants
Can have non-key attributes as determinants
Cannot have.
Proposed by
Edgar F. Codd
Raymond F.Boyce and Edgar F.Codd jointly proposed
Decomposition
Loss-less join decomposition can be achieved
Sometimes Loss-less join decomposition cannot be achieved
Table 1 – 3NF – BCNF Comparisons


*********

Related Links



Compare third normal form 3nf and boyce codd normal form bcnf

Exam Questions - Normalization, File Organization, Indexing and Hashing

Exam Questions - Normalization, File Organization, Indexing and Hashing

  1. List some advantages of DBMS over File Processing System.
  2. Define the different levels of data abstraction
  3. What do you mean by degree of relationship set?
  4. What does DDL interpreter do?
  5. What is Multi-valued dependency?
  6. Define Loss-less join decomposition.
  7. What do you mean by Full Functional Dependency?
  8. Define Domain Key Normal Form (DKNF)
  9. Define Query Optimization
  10. What do you mean by Data transfer rate? How does it helpful in query processing?
  11. Define average latency time, mean time to failure, and average seek time.
  12. What are the responsibilities of Buffer manager?
  13. Discuss the Toss-immediate buffer management strategy with an example.
  14. Why the Most Recently Used (MRU) block replacement is considered the optimal one in database?
  15. Define heap file organization, sequential file organization, and hash file organization.
  16. How do we handle insertion of new records in Sequential file organization?
  17. List down various information stored in the Data dictionary.
  18. Does the allocation of records to blocks affect database-system performance? Why?
  19. Define Dangling pointer.
  20. List and define the types of indices.
  21. Are primary index and clustering index meaning the same thing?
  22. List and define the types of ordered indices.
  23. List some advantages of dense index.
  24. List some advantages of sparse index.
  25. Why the sequential scan in primary index is efficient?
  26. List some disadvantages of sequential file organization.
  27. Why do we need a hash function which can both distribute uniformly and randomly?
  28. Define skew.
  29. What are the various issues one should consider while choosing File organization and Indexing techniques?
  30. For executing a query which specifies a range of values in the WHERE clause, among Ordered indexing and Hash indexing, which is preferable? Why?
  31. What would be the result of the SQL statement CREATE UNIQUE INDEX idxA ON TabA(A), if the column A is not a candidate key?
  32. Differentiate Primary and Secondary index.
  33. How could we reduce the occurrence of bucket overflows in hash file organization?
  34. How does a database index work?
  35. What is hash table?
  36. What are the problems with static hashing?
  37. What does an index record contain?
  38. For a query like ‘SELECT * FROM Emp WHERE EmpNo = ‘E1’’, hashing is the best choice. Why?
  39. How does Denormalization help in improving performance of the system?
  40. How does Dynamic hashing manage file expansion?

Normalization - TRUE/FALSE Questions with Proofs

Normalization TRUE/FALSE Questions with explained proofs for understanding / TRUE/FALSE Questions with answer discussion on Normalization / TRUE/FALSE Questions on Normal Forms Discussion


TRUE/FALSE Questions – Normalization and Normal Forms

1. For a relation schema R(A, B, C, D), if AB C and C D, then AB is a key.
Ans: TRUE
Proof: Try to find (AB)+, ie., closure of (AB).
Step 1: result = AB
Step 2: If you know AB, then using AB C, result = ABC
Step 3: If you know AB and C, and using C D, the result = ABCD
At this stage, result included all the attributes of R. Hence, (AB) is a key for R.

2. If a relation is in 3NF, then it is also in BCNF.
Ans: FALSE
Proof: 3NF permits Non-key Key dependency. That is, it accepts a dependency where a non-key attribute can determine the value of a key attribute. But in BCNF, it expects only candidate keys to be determiner, not non-key attribute. Hence, a relation that is in 3NF, not in BCNF too.

3. From A B, we can derive AC BC, which can further lead to A BC.
Ans: FALSE
Proof: From the question, A determines the value of B. According to Armstrong’s Augmentation rule AC BC is true for any attribute C. this is because C C is a trivial functional dependency. But, this augmentation cannot lead to the dependency A BC where A alone determine both B and C.

4. BCNF decomposition of a relation R(A, B, C, D) with functional dependencies A B and C D leads to three relations, R1(A, B), R2(C, D), and R3(C, A).
Ans: TRUE
Proof: According to the rule of BCNF, all the functional dependencies should have keys as determiners (keys as left hand side attributes of any FDs). For the given relation R and according to the set of FDs given, the key is AC which is composite. Hence, we break the relation into a relation R1 with attributes A and B [from FD A B], a relation R2 with attributes C and D [from FD C D], and a relation R3 with attributes C and A [to link R1 and R2].

5. A relation R(A, B, C) with the functional dependencies AB C and C B is in BCNF.
Ans: FALSE
Proof: From AB C, it is clear that AB is the key. But, one of the key attributes is determined by a non-key attribute C according to C B. Hence, the relation R is not in BCNF.

6. A relation R which is in 3NF is also in 4NF.
Ans: FALSE
Proof: 3NF uses the functional dependencies of Single valued facts. That is, they are about one or more attributes uniquely determine the values of one or more other attributes. But 4NF is about a different kind of functional dependency called Multi-valued functional dependencies. That is, functional dependencies about multi-valued facts.

7. For a relation R with attribute ABCDE and set of functional dependencies F = {A B, BC D, D E}, the closure for attribute combination {AC} is ABCDE.
Ans: TRUE
Proof: Find the closure of (AC)
Step 1: result = AC
Step 2: from A B, A can determine the value of B. hence, result = AC U B = ACB.
Step 3: through BC D, result becomes ABCD.
Step 4: as we know D, then through D E, result = ABCDE.
Hence, the closure of (AC) is ABCDE.

8. For a relation R with attribute ABCDE and set of functional dependencies F = {A B, BC E, ED A}, the attribute combination {ACE} is one of the keys.
Ans: FALSE
Proof: Let us find the closure of (ACE)
Step 1: result = ACE
Step 2: from A B, result = ABCE.
Step 3: from BC E, result = ABCE, does not change.
The result is not ABCDE (all the attributes). Hence, (ACE) is not a key for R.

9. In a relation R(A, B, C, D), if AC CB then A B.
Ans: FALSE
Proof: As per the given FD AC CB, we can understand both A and C together identifies the value of B. We cannot say, by removing C from both sides, A alone can determine B. We would say AC B.

10. In a relation R with attributes ABC, if a FD A B holds, then AC B also holds.
Ans: TRUE
Proof: Attribute A alone can determine B. Adding another attribute C would not change the determination of B by A.

Steps to decompose a non-2NF relation to a 2NF relation



How to decompose a non-2NF relation into a 2NF relation? / Decomposing a relation that consists partial functional dependencies / Steps in decomposing a table into a 2nf table


2NF properties:


-Relation should be in 1NF.

-No partial functional dependency must present. (All the non-key attributes must depend on the whole key / key attribute)

Decomposition steps:
If any partial functional dependency (partial FD is considered only when the key is a composite key) present in a table/relation that you normalize, then you should decompose (break) that relation into two or more relations depend on the set of functional dependencies. To decompose the relation, you can follow these simple steps;

Step 1: Create a separate relation for each partial dependency


Step 2: Remove the right hand side attribute of the partial dependency from the relation that is being decomposed.

Example 1:
Flight_ID
Flight_Day
Pilot
Boarding_Gate
IC123
Monday
Kesav
2
IC123
Tuesday
Mark
2
IC217
Wednesday
Kesav
3
IA156
Monday
Steve
1

For this Flight_Schedule table, the following is the set of functional dependencies;
F = { Flight_ID Flight_Day Pilot Boarding_Gate, Flight_ID Boarding_Gate}
This table is in 1NF, but not in 2NF because of the FD Flight_ID Boarding_Gate. In our example, the key is (Flight_ID, Flight_Day). These two attributes together can identify the Pilot value uniquely. But for identifying the other attribute Boarding_Gate, the attribute Flight_Day is enough [Flight_Day is part of the composite key of this relation].

Now, let us apply the steps shown above.

Step 1: Create a separate relation for each partial dependency. In our example, Flight_ID Boarding_Gate is the partial dependency. Hence we need to create a separate relation for this FD. Let us name this relation as Boarding.
Boarding ( Flight_ID, Boarding_Gate)

Step 2: Remove the right hand side attribute of the partial dependency from the relation that is being decomposed. In the relation Flight_Schedule (Flight_ID, Flight_Day, Pilot, Boarding_Gate), the attribute Boarding_Gate should be removed as per this condition. The reason is, Boarding_Gate is the right hand side (RHS) attribute of the partial dependency, Flight_ID Boarding_Gate. Hence,
Flight_Schedule (Flight_ID, Flight_Day, Pilot).

Thus, Flight_Schedule (Flight_ID, Flight_Day, Pilot, Boarding_Gate) is decomposed into Flight_Schedule (Flight_ID, Flight_Day, Pilot) and Boarding ( Flight_ID, Boarding_Gate).

Example 2:

Assume a relation R (A, B, C, D, E) with the following set of functional dependencies;
F = {AB C, B D, E D}
The key for this relation is ABE. Then, all three given FDs are partial dependencies, viz., AB C, B D, and E D.
Step 1: separate tables for partial dependencies; hence, R1 (ABC), R2 (BD) and R3 (ED).

Step 2: remove RHS of these two partial FDs from R; hence, R4(A, B, E).

Thus, we have four tables R1 (ABC), R2 (BD), R3 (ED) and R4 (ABE).



Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents