LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

25
LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University

Transcript of LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

Page 1: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

LOSSLESS DECOMPOSITION

Prof. Sin-Min Lee

Department of Computer Science

San Jose State University

Page 2: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 3: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

Definition of Decomposition

A decomposition of a relation R is a set of relations { R1, R2,…, Rn } such that each Ri is a subset of R and the union of all of the Ri is R

Page 4: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

Example of Decomposition

From R( A B C ) we can have two subsets as:

R1( A C ) and R2( B C )

if we union R1 and R2 we will get R

R = R1 U R2

Page 5: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 6: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 7: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 8: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 9: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 10: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 11: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 12: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 13: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 14: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 15: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 16: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

Definition of Lossless Decompotion

A decomposition {R1, R2,…, Rn} of a relation R is called a lossless decomposition for R if the natural join of R1, R2,…, Rn produces exactly the relation R.

Page 17: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 18: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Page 19: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

Example

R( A1, A2, A3, A4, A5 )

R1( A1, A2, A3, A5 ); R2( A1, A3, A4 );

R3( A4, A5 ) are subsets of R.

We have FD1: A1 --> A3 A5

FD2: A2 A3 --> A2

FD3: A5 --> A1 A4

FD4: A3 A4 --> A2

Page 20: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

A1 A2 A3 A4 A5

a(1) a(2) a(3) b(1,4) a(5)

a(1) b(2,2) a(3) a(4) b(2,5)

b(3,1) b(3,2) b(3,3) a(4) a(5)

Page 21: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

By FD1: A1 --> A3 A5

we have a new result table

A1 A2 A3 A4 A5

a(1) a(2) a(3) b(1,4) a(5)

a(1) b(2,2) a(3) a(4) a(5)

b(3,1) b(3,2) b(3,3) a(4) a(5)

Page 22: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

By FD2: A2 A3 --> A4

we don’t have a new result table because we don’t have any equally elements. Therefore, the result doesn’t change.

Page 23: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

By FD3: A5 --> A1 A4

we have a new result table

A1 A2 A3 A4 A5

a(1) a(2) a(3) a(4) a(5)

a(1) b(2,2) a(3) a(4) a(5)

b(3,1) b(3,2) b(3,3) a(4) a(5)

Page 24: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

By FD4: A3 A4 --> A2

we get a new result table

A1 A2 A3 A4 A5

a(1) a(2) a(3) a(4) a(5)

a(1) a(2) a(3) a(4) a(5)

b(3,1) b(3,2) b(3,3) a(4) a(5)

tuple1 and tuple2 are lossless because they have all a(I)

Page 25: LOSSLESS DECOMPOSITION Prof. Sin-Min Lee Department of Computer Science San Jose State University.

Summary

A decomposition { R1, R2,…, Rn } of a relation R is called a lossless decomposition for R if the natural join of R1, R2,…, Rn produces exactly the relation R

NOTE: not every decomposition is lossless. It is possible to produce a decomposition that is lossy, one that losses information.