0% found this document useful (0 votes)
22 views

Assignment2 1

The document provides information on relational algebra operations including join, union, difference, selection, projection, and division. It discusses the minimum and maximum cardinalities of each operation given certain assumptions about the relations. It also covers functional dependencies, candidate keys, decomposition to Boyce-Codd normal form, and analyzing relations for violations of BCNF.

Uploaded by

samia lachgar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Assignment2 1

The document provides information on relational algebra operations including join, union, difference, selection, projection, and division. It discusses the minimum and maximum cardinalities of each operation given certain assumptions about the relations. It also covers functional dependencies, candidate keys, decomposition to Boyce-Codd normal form, and analyzing relations for violations of BCNF.

Uploaded by

samia lachgar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Assignment 2:

Part 1:
Question 1:
1. RUS:

 Minimum cardinality: r When R have all the set of tuples of S


 Maximum cardinality: r+s. When S and R are distinct.
 Assumption: The schemas of relations R and S must be the same. they must have the
same set of attributes, and corresponding attributes must have the same data types.

2.R∩S:

 Minimum cardinality: 0 The intersection operation results in tuples that are common
to both R and S. If there are no common tuples, the result is an empty set.
 Maximum cardinality: s happens when R contains all the values of S
 Assumption: The schemas of relations R and S must be the same. That is, they must
have the same set of attributes, and corresponding attributes must have the same
data types.
2.

3. R-S:
 Minimum cardinality: r-s Subtraction involves removing tuples from R that also exist
in S. The minimum occurs when all tuples in S match with tuples in R, resulting in the
removal of 's' tuples from 'r'.
 Maximum cardinality: r when tuples in R doesn’t match with any tuple of S.
 Assumption: the schemas must be the same.
4. S-R:
 Minimum cardinality: 0 The difference S-R includes tuples that are in S but not in R.
If there are no such tuples (iow S contains tuples that are in R), the result is an
empty set.
 Maximum cardinality: s The maximum occurs when every tuple in S is not present in
R, resulting in 's' tuples in the result.
 Assumption: the schemas of R and S must be the same.

5. σ a=5(R):
 Minimum cardinality: 0 The selection operation filters tuples based on a condition. If
there are no tuples satisfying the condition, the result is an empty set.
 Maximum cardinality: r if all the tuples has 5 as value of the attribute a.
 Assumption: The attribute a must exist in relation R. Otherwise, we can't project
onto an attribute that doesn't exist.
6. πa(R):
 Minimum cardinality: 1 (the attribute has the same value in all the tuples)
 Maximum cardinality: r (distinct values for the a attribute).
 Assumption: R must have a as an attribute.

7. R/S
 Minimum cardinality: 0 The result can be empty if no tuples in R satisfy the
condition of being combined with any tuple in S.
 Maximum cardinality: E(r/s), maximal when s=1 which gives us r. The maximum
occurs when each tuple in S matches with the max nb of tuples from R which is [r/s].
 Assumption: S should be a subset of R.

8. S/R:
 Minimal cardinality=Minimal cardinality= 0 because r>s so it is impossible for any
tuple of S to have r matching tuples with R.
 Assumption: R should be a subset of S.

9. R ⋈R.a = S.a S:
 Minimal cardinality: 0 The result can be empty if there are no matching tuples based
on the equality of attribute 'a'.
 Maximal cardinality: rxs he maximum occurs when every tuple in R matches with
every tuple in S based on the equality of attribute 'a'.
 Assumption: The attribute a must exist in both relations R and S.

10. R ⟕R.a = S.a S loj:


 Minimal cardinality: r Every tuple in R is included in the result, even if there are no
matching tuples in S.
 Maximal cardinality: rxs The maximum occurs when every tuple in R matches with
every tuple in S based on the equality of attribute 'a'.
 Assumption: The attribute a must exist in both relations R and S.

11. .R ⟖R.a = S.a S:


 Minimal cardinality: s if there isn’t matching values .
 Maximal cardinality: rxs The maximum occurs when every tuple in S matches
with every tuple in R based on the equality of attribute 'a'.
 Assumption: The attribute a must exist in both relations R and S.
12. R ⟗R.a = S.a S:
 Minimal cardinality: r+s Every tuple in R is included in the result, even if there are
no matching tuples in S and Every tuple in S is included in the result, even if there
are no matching tuples in R. that gives us r+s padded with NULL.
 Maximal cardinality: r.s Every tuple in R is matching every tuple in S.
 Assumption: The attribute a must exist in both relations R and S

Question 2:

1) returns the names of students (sname) who are enrolled in the "Data Management 1" class.
2) returns the student IDs (sid) of students never scored "A".
3) Computes the set student and professor IDs and names but the tuples should be distinct
because the duplicates are removed.
4) Computes the names of students who are enrolled in all courses taught by the professor
named "Echihabi".

Part B:
1) Answer:
a. Candidate key: {U1}, {U3}:
for U: U1 determines U2, U3, U4 and determines U1 too (it’s trivial), so it
determines all the attributes and it’s minimal so U1 is the candidate key.
U3 is a candidate key because it uniquely determines U1 which is a
candidate key too.
b. candidate keys: {V1, V5, V6, V7}
 For V: v1 determines both V2 and V3 and in the other hand V1,V2 and V3
determine V4 so by transitivity V1 determines V1,V2,V3 and V4 but given the
provided functional dependencies, it's not clear whether V1 is a candidate
key for V, as the dependencies don't explicitly state the relationships
involving V5, V6, and V7. The set {V1, V5, V6, V7} is a superkey because it
uniquely determines all attributes. Therefore, {V1, V5, V6, V7} is a candidate
key for relation V.

c. Candidate keys: {W1}, {W6}


{W1}: W1 uniquely determines W2, W3, W4, W5, W6 based on the given
functional dependencies (W1 → W2, W3 and W1, W3 → W4, W5, W6).
{W6}: W6 uniquely determines W1, W2 based on the functional dependency
(W6 → W1, W2).
Both {W1} and {W6} are minimal superkeys, and they uniquely determine all
other attributes.
d. Candidate keys: {X2, X3}
{X2, X3} uniquely determines X4 based on the functional dependency X2X3
→ X4.
{X2, X3} also uniquely determines X5 based on the functional dependency
X2X3 → X5.
{X2,X3} determine X2 and X3 it is trivial.
No smaller subset of attributes uniquely determines all other attributes,
making {X2, X3} a minimal superkey, and thus, a candidate key for relation X.
2) Answer:
a) Relation U:
Given Functional Dependencies:
U1 → U2, U3, U4
U3 → U1, U2
Minimal Cover:
U1 → U2, U3, U4 (No change)
U3 → U1 (we removed U2 from the right side )
Justification:
We know that U3 determines U1 and U1 determines U2
b) Relation V:
Given Functional Dependencies:
V1 → V2, V3
V1, V2, V3 → V4
Minimal Cover:
V1 → V2, V3, V4 (Combined the two dependencies)
Justification:
The second dependency is redundant because V1 → V4 is already implied
by the first one. So, we can remove V1, V2, V3 → V4 and keep only V1 →
V2, V3, V4.
c) Relation W:
Given Functional Dependencies:
W1 → W2, W3
W1, W3 → W4, W5, W6
W6 → W1, W2
Minimal Cover:
W1 → W2, W3, W4, W5, W6
W6 → W1 (Removed W2 from the right side)
Justification:
We remove the dependency W1, W3 → W4, W5, W6 because W1 → W3,
and thus W1 already determines W4, W5, W6.
We remove the dependency W6 → W1, W2 because W1 → W2 already
exists, and adding W2 to the right side is redundant.
d) Relation X:
Given Functional Dependencies:
X2X3 → X4
X4X5 → X1X6
X2X3 → X5
Minimal Cover:
X2X3 → X4, X5 (Combined the third dependency into the first one)
X4X5 → X1X6 (No change)
Justification:
The third dependency is redundant because X2X3 → X5 is already implied
by X2X3 → X4, so we can remove it.
These minimal covers ensure that we retain the same closure (the set of
all attributes functionally determined by a given set of dependencies) as
the original set of functional dependencies.
3) Candidate Key: {V1, V5, V6, V7}
Checking for BCNF Violations:

V1→ V 2, V 3 V1 is not a superkey because it is not included in the


candidate key. This dependency violates BCNF.
V1,V2,V3→V4: V1,V2,V3 is not a superkey. This dependency also violates
BCNF.

v4,V5→V1: V4,V5 is not a superkey. This dependency violates BCNF.

Decompose to V’(V1,V5,V6,V7) and


V’’(V1,V2,V3,V4)
4) X4X5 → X1X6 is a violation of bcnf because X4X5 is not a superkey we will 
decompose it to X’(X1,X6,X4,X5) and X’’(X2,X3,X4,X5).

Part C:
The relation U:
 It respects the conditions of bcnf because all the determinants are superkeys
containing U3 or U1 , then it also respects the conditions of 3nf.

The relation V:
 It doesn’t respect the conditions of bcnf because V1,V2,V3→V4 and V1,V2,V3 is
not a superkey and it doesn’t respect the 3nf neither conditions because V4 is
not prime (not part of the candidate key)
 Isn’t 2NF , because for each FD X-> A, X(V1-> V2,V3 for example) it is a partial
function dependencies,because we have a subset of a candidate key wich is
VIV5V6V7 that determines a non prime attribute
 Is 1NF by default every relation that contains a set of attributes is in INF

The relation W:
 It respects the conditions of bcnf because all the determinants are superkeys
containing W3 or W6 which are the candidate keys , then it also respects the
conditions of 3nf automatically.

The relation X:
 X is not in bcnf because X4X5 → X1X6 and {X4, X5} is not a superkey
 {X1,X6} is not part of any candidate key so it is not 3nf either.
 Is 2 NF because there is not partial function dependencies for each FD X-A .

You might also like