Assignment2 1
Assignment2 1
Part 1:
Question 1:
1. RUS:
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.
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.
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 .