BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Decomposition in DBMS – Lossless and Lossy with examples

Last Updated: August 22, 2022 by Chaitanya Singh | Filed Under: DBMS

Decomposition is a process of dividing a relation into multiple relations to remove redundancy while maintaining the original data. In this guide, you will learn decomposition in DBMS with the help of examples.

Types of decomposition:

1. Lossless decomposition
2. Lossy decomposition

1. Lossless decomposition

A lossless decomposition of a relation ensures that:

a) No information is lost during decomposition. This is why the term lossless is used in this decomposition as no information is lost.

b) If a relation R is divided into two relations R1 and R2 using lossless decomposition then the natural join of R1 and R2 would return the original relation R.

Rules of Lossless decomposition: For these rules, we are assuming that a relation R is divided into two relations R1 and R2.

1. Natural join of R1 and R2 should return the original relation R.

R1 U R2 = R

2. The intersection of R1 and R2 should not be null. This is because there are some common attributes present in relation R1 and R2.

R1 ∩ R2 ≠ 0

3. The intersection of R1 and R2 is either a super key of R1 or R2, or both the relations R1 and R2.

R1 ∩ R2 = super key of R1 or R2 or both

Let’s say a relation R (A, B, C), where A is primary key is divided into two relations R1 (A, B) and R2 (C, A).

Let’s check whether this decomposition is loss-less decomposition or not:
Rule 1:
R1 U R2 = (A, B) U (C, A) = (A, B, C)
Union or R1 and R2 gives the original relations, thus first rule of lossless decomposition applies here.

Rule 2:
R1 ∩ R2 = (A, B) ∩ (C, A) = (A)
Result is not null so the second rule also applies here.

Rule 3:
R1 ∩ R2 = (A, B) ∩ (C, A) = (A)
Result is a super key of both the relations thus third rule also applies here.

Rule 4: Dependency preserving
The dependencies that exists in the original relation, exists after decomposition.

Example of LossLess decomposition

StudentCourse Table:

Student_Id  Student_Name  Course_Id  Course_Detail
----------  ------------- ---------  -------------
S101        Chaitanya      C01       Maths
S102        Ajeet          C01       Maths
S103        Rahul          C02       Science
S104        Steve          C02       Science
S105        John           C03       English
S101        Chaitanya      C03       English
S102        Ajeet          C02       Science

The primary key of given relation is {Student_Id, Course_Id}

This table has redundant data as the Course_Id and Course_Detail are common for several students. Let’s decompose this relation into two relations.

Student Table:
The primary key of this table is {Student_Id, Course_Id}

Student_Id Student_Name  Course_Id
---------- ------------  ---------
S101       Chaitanya      C01            
S102       Ajeet          C01           
S103       Rahul          C02           
S104       Steve          C02           
S105       John           C03            
S101       Chaitanya      C03            
S102       Ajeet          C02

Course Table:
The primary key of this table is {Course_Id}

Course_Id  Course_Detail
---------  -------------
C01        Maths
C02        Science
C03        English

Let’s check all the three rules of lossless decomposition to check whether this decomposition is lossless or not.
Rule 1:

{Student} U {Course}

Union Result:

Student_Id  Student_Name  Course_Id  Course_Detail
----------  ------------- ---------  -------------
S101        Chaitanya      C01       Maths
S102        Ajeet          C01       Maths
S103        Rahul          C02       Science
S104        Steve          C02       Science
S105        John           C03       English
S101        Chaitanya      C03       English
S102        Ajeet          C02       Science

The union results in the original relation StudentCourse so we can say that the first rule holds true.

Rule 2 & 3:

R1 ∩ R2

Result:

Course_Id 
C01           
C02           
C03

The result is not null so rule 2 holds true.

The result is a super key of the second relation R2 so the third rule also applies here.

Rule 4: Dependencies in original relation:

Student_Id -> {Student_Name}
Course_Id -> {Course_Detail}

These dependencies are still present in the decomposed relations. Thus we can say that this decomposition is dependency preserving.

Since all the three rules applies here, the decomposition of relation StudentCourse into Student and Course is a lossless decomposition.

2. Lossy Decomposition

As the name suggests, in lossy decomposition, the information is lost during decomposition. The three rules that we discussed above would not apply in lossy decomposition. In lossy decomposition, one or more rules will fail.

Let’s take the same example that we discussed above.
StudentCourse Table:

Student_Id  Student_Name  Course_Id  Course_Detail
S101        Chaitanya     C01        Maths
S102        Ajeet         C01        Maths
S103        Rahul         C02        Science
S104        Steve         C02        Science
S105        John          C03        English
S101        Chaitanya     C03        English
S102        Ajeet         C02        Science

Now if we divide this relation like this:
Student Table:
The primary key of this table is {Student_Id}

Student_Id   Student_Name 
S101         Chaitanya                      
S102         Ajeet                             
S103         Rahul                            
S104         Steve                            
S105         John

Course Table:
The primary key of this table is {Course_Id}

Course_Id  Course_Detail
C01        Maths
C02        Science
C03        English

This is a lossy decomposition as the intersection of Student and Course relation will return null so the second and third rule of lossless decomposition will fail here.

In this decomposition, the relation of Student and Course is lost, there is no way to form the original relation from these two relations as the information that suggests who is attending which course is lost during decomposition.

❮ DBMS Tutorial

Top Related Articles:

  1. Introduction to Relational algebra & Relational calculus
  2. Deadlock in DBMS
  3. Instance and schema in DBMS
  4. DBMS – First Normal Form (1NF)
  5. Candidate Key in DBMS

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

DBMS Tutorial

Basics

  • DBMS Tutorial
  • DBMS Introduction
  • Database Applications
  • DBMS vs File System
  • DBMS vs RDBMS
  • DBMS Architecture
  • Three-level DBMS architecture
  • View in DBMS
  • Abstraction
  • Instance & Schema
  • DBMS languages

Data Models

  • Data Models
  • ER Diagram
  • ER Design issues
  • Convert ER to table
  • DBMS Generalization
  • DBMS Specialization
  • DBMS Aggregration
  • Relational Model
  • Hierarchical Model
  • Constraints
  • Cardinality

Relational Database

  • RDBMS concepts
  • Relational Algebra
  • Relational Calculus
  • Keys Index
  • Primary Key
  • Super Key
  • Candidate Key
  • Foreign Key
  • Composite Key
  • Alternate Key

Normalization

  • Normalization
  • Functional dependency

Transaction Management

  • Transaction Management
  • ACID properties
  • Transaction States
  • DBMS Schedules
  • Serializability
  • Conflict Serializability
  • View Serializability
  • Recoverability Of Schedule
  • Failure Classification
  • Log based Recovery
  • DBMS Checkpoint
  • Deadlock

Concurrency Control

  • Concurrency Control
  • Lock based protocol
  • Timestamp based protocol
  • Validation based protocol

File Organization

  • File Organization
  • Sequential File Organization
  • Heap File Organization
  • Hash File Organization
  • DBMS ISAM
  • B+ File Organization
  • Cluster File Organization

SQL Introduction

  • SQL Introduction
  • SQL Characteristics
  • Advantages of SQL
  • SQL Commands
  • SQL Operators
  • SQL CREATE
  • SQL DROP
  • SQL SELECT
  • SQL INSERT

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap