6,322 views

Given two relations R1 and R2, where R1 contains N1 tuples, R2 contains N2 tuples, and N2>N1> 0, give the minimum and maximum possible sizes (in tuples) for the result relation produced by each of the following relational algebra expressions. In each case, state any assumptions about the schemas for R1 and R2 that are needed to make the expression meaningful:

1. $R1 \cup R2$ (union)
2. $R1 \cap R2$ (intersection)
3. $R1-R2$ (set difference)
4. $R1 X R2$ (cartesian product)
5. $σa=5(R1)$ (selection)
6. $\pi a(R1)$ (projection)
7. $R1/R2$ (division)

edited by
pls check whether my solution is correct or not

1. max=m+n, min=m+n

2. max=N1, min=0(no common tuples in R1 and R2)

3. max=N1(R1 and R2 are disjoint sets), min=0(all tuples of R1 are present in R2)

4. max=N1*N2, min=N1*N2

5. max=N1, min=0

6. I'm little confused here

7. Max=N1(all tuples of R1 are associated to all tuples of R2), min=0(no tuple of R1 is associated to all the tuples of R2)

pls check whether my solution is correct or not

1. Max is correct But min will be max(N1,N2) i.e. N2.

6. Max = N1 (If All the values of attribute $a$ are distinct), Min = 1 (If all the values of attribute $a$ are same.)

7. Max,Min will be Zero because $N_1 < N_2.$

@Deepakk Poonia (Dee)

In first, R1 union R2, there is no need of max(N1, N2) becuz already we know this N2>N1>0(given)

so the answer is 1.min = N2 and max=N1+N2

edited

guys i treated this question in terms of discrete mathematics concept later i found it is the question of database(by seeing tag)

Is this okay? to think like that because all of the answer I did right except selection and projection.

@Arjun is this right approach? becuz i treated tuples in relation as 2-tuple(for simplicity) and then solve it.

for eg. 1.R1 union R2

for min -:

R1={(2,3)}

R2={(2,3),(1,3),(4,5)}

min tuples =N2 ie 3

for Max

R1={(1,3)}

R2={(2,3),(4,5)}

max tuples  =  N1+N2 ie.3

this merely take seconds to think in mind.

For typing convenience, I'll use $R,S$ for $R_1,R_2$ respectively. Similarly, $m,n$ instead of $N_1,N_2$

Given $n > m>0.$

Schema assumption for expressions $R \cup S, R \cap S, R -S :$ They must be Union Compatible i.e. For these Set Operations to be valid, we require that two conditions hold:

1. The relations $R$ and $S$ must be of the same arity. That is, they must have the same number of attributes.

2. The domains of the $i-th$ attribute of $R$ and the $i-th$ attribute of $S$ must be the same, for all $i.$

Note that $R$ and $S$ can be either database relations or temporary relations that are the result of relational-algebra expressions.

1. $R \cup S :$ Max = $m+n$ (When R,S are disjoint sets) ; Min = $max(m,n)$ which is $n$ here (Min when one relation is subset of other )

2. $R \cap S :$ Max = $min(m,n) = m$ (when one relation is subset of other) ; Min = $0$ (When R,S are Disjoint sets )

3. $R -S :$ Max = $m$ (When R,S are disjoint sets) ; Min = $0$ (When R is subset of S )

4. $R \times S :$ No schema assumptions required.

Max, Min = $m.n$

5. $\sigma_{a =5}R :$

Schema Assumption : In the schema of $R,$ there should be an attribute by the name $'a'.$ Moreover, the domain of this attribute $'a'$ must contain $5.$

Max = $m$ (When all the tuples of $R$ have value of attribute $a$ as 5.)

Min = 0 (When None of the tuples of $R$ have value of attribute $a$ as 5.)

6. $\prod_aR :$

by

1 vote
1
854 views
2
637 views
3
378 views