461 views
2 2 votes

There is a schema as follows : 

loan(custname, branch, loanno, amount) with following Functiona dependencies : 

1. custname -> loanno.

2.loanno. -> amount

based on this the schema is decomosed into two tables. as follows : 

loan1 (loanno, amount)

loan2(cname,branchname,loanno)

i understand that this has been done to eliminate transitive dependency but can someone explain why we need to eliminate that for this particular example. I.e how does that eiminate the redundancy anomalies in this. using some example data to explain would be helpful. 

1 Answer

2 2 votes

To understand why eliminating transitive dependency is important in this case and how it prevents redundancy and anomalies, let's first define what transitive dependency and the related anomalies are.

Transitive Dependency:

A transitive dependency occurs when one attribute indirectly depends on another attribute via a third attribute. In this case, the loan schema has the following functional dependencies:

  1. custname -> loanno (customer name determines loan number).
  2. loanno -> amount (loan number determines loan amount).

Thus, we have a transitive dependency: custname -> loanno -> amount. In other words, custname indirectly determines amount via loanno.

This means that the amount column in the original schema depends transitively on custname, and it leads to redundancies and anomalies.

Redundancy and Anomalies:

To illustrate how redundancy and anomalies occur in the original schema, let's consider some example data:

custname

branch

loanno

   amount

Alice

Branch1

      101

   5000

Bob

Branch2

      102          

   3000

Alice

Branch1

      101

   5000

Charlie

Branch3

      103

   8000

Redundancy:

In the above table, notice how the loan number (loanno) and amount for Alice are repeated twice. This happens because Alice has the same loan number 101, and that loan is associated with a fixed amount of 5000. So, every time Alice's data is inserted into the table, the loan amount 5000 is repeated.

Redundant data leads to unnecessary storage consumption and can increase the cost of managing the database.

Update Anomaly:

Suppose Alice's loan amount changes from 5000 to 5500. You would have to update the loan amount in every row where Alice's loan appears. If you miss updating even one row, the data will be inconsistent (some rows will show 5000, and others will show 5500).

Deletion Anomaly:

If you remove Alice's loan information entirely (by deleting the row), you'll also lose her loan number and amount details. This could be a problem if loan numbers and amounts are needed independently of customer names (for example, for financial audits or reporting).

Insertion Anomaly:

If you want to insert a new loan record for a customer without an associated loan number yet, you can't do it. The schema forces you to have a loan number and an amount, which may not be available at the time of insertion.

Eliminating the Transitive Dependency:

By decomposing the table into two tables (loan1 and loan2), we eliminate the transitive dependency and remove the above anomalies. Here’s the decomposed schema:

  1. loan1(loanno, amount): This table captures the direct relationship between loan number and loan amount.

    loannoamount
    1015000
    1023000
    1038000
  2. loan2(cname, branchname, loanno): This table captures the relationship between the customer and the loan number.

    cnamebranchnameloanno
    AliceBranch1101
    BobBranch2102
    CharlieBranch3103

How this fixes the anomalies:

  • Redundancy: The loan amount is now stored only once in the loan1 table. So, even if multiple customers are associated with the same loan, the amount won’t be duplicated.

  • Update Anomaly: If Alice’s loan amount changes from 5000 to 5500, you only need to update the loan1 table once (at loan number 101). This ensures data consistency and avoids the risk of partial updates.

  • Deletion Anomaly: Deleting Alice from loan2 (customer data) won't remove loan details from loan1. Thus, the loan details are preserved even if no customers are currently associated with the loan.

  • Insertion Anomaly: You can insert a new customer record in loan2 even if their loan amount is not yet known. As long as the loan number is not required at the moment, you can insert partial data.

Summary:

By decomposing the schema to eliminate the transitive dependency, we:

  • Reduce redundancy
  • Prevent update, deletion, and insertion anomalies
  • Improve data consistency and maintainability

This normalization makes the database more efficient and easier to manage.

4o

Position:
Show:

Related questions

1 1 vote
1 1 answer
368
368 views
Vaibdoesit asked Sep 4, 2024
368 views
The lecturer gives a set of funcional dependencies and the task is to get the canonical form.The dependencies are as follows. 1.B->C2.A->B and 3.AB->Cas proof for fd fd ...
3 3 votes
2 2 answers
798
798 views
Shubham Sharma 2 asked Sep 9, 2025
798 views
Consider a schema $\text{R(P, Q, R, S)}$ and the following functional dependencies $\text{P} \rightarrow \text{Q}, \text{Q} \rightarrow \text{R}, \text{R} \rightarrow \te...
2 2 votes
1 1 answer
121
121 views
GO Classes asked Sep 15
121 views
Consider $R(A,B,C,D,E,F)$ with $F=\{C\to D,\ A\to B,\ B\to EF,\ F\to A\}$.Suppose $R$ is decomposed into $R_1(A,B,D,E)$ and $R_2(A,B,C,F)$. The decomposition is currently...
6 6 votes
2 answers 2 answers
3.6k
3.6k views
Balaji Jegan asked Sep 26, 2018
3,560 views
Consider R(A,B,C,D,E)with the FD Set F(A->B, A->C, DE->C, DE->B, C->D)Consider this decomposition : R1(A,B,C), R2(B,C,D,E) and R3(A,E)Then, the decompositions isLossless ...