Implement in Python / Java
Implement in Python / Java
Input: A universal relation R, a decomposition D = { R1, R2, R3, ….. Rm } of R, and a set F of functional dependencies.
1. Create an initial matrix S with one row i for each relation in Ri in D, and one column j for each attribute Aj in R.
2. Set S(i, j) := bij for all matrix entries. (* each bij is a distinct symbol associated with indices (i, j) * )
- {for each column j representing attribute Aj
- {if (relation Ri includes attribute Aj ) then set S(I, j):=aj;};};
- (* each aj is a distinct symbol associated with index (j) *)
3. For each row i representing relation schema Ri
- {for each functional dependency X → Y in F
- {for all rows in S which have the same symbols in the columns
- corresponding to attributes in X
- {make the symbols in each column that correspond to
- an attribute in Y be the same in all these rows as
- follows: if any of the rows have an "a" symbol for the
- the column set the other rows to that same "a" symbol
- the column. If no "a" symbol exists for the attribute
- in any of the rows, choose one of the "b" symbols
- that appear in one of the rows for the attribute and set
- the other rows to that same "b" symbol in the
- column ;};};};
4. Repeat the following loop until a complete loop execution results in no changes to S
5. If a row is made up entirely of "a" symbols, then the decomposition has the lossless join property; otherwise, it does
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images