# Domain Restriction on Relation domain restriction operator,, restricts a relation to only those members whose domain is in a specified set. domain restriction.

## Presentation on theme: "Domain Restriction on Relation domain restriction operator,, restricts a relation to only those members whose domain is in a specified set. domain restriction."— Presentation transcript:

Domain Restriction on Relation domain restriction operator,, restricts a relation to only those members whose domain is in a specified set. domain restriction operator,, restricts a relation to only those members whose domain is in a specified set. Let R: M x P be { (m1, p1), (m2, p2), (m3, p1), (m3, p3), (m4, p3) } and S = { m1,m3}, then : – S R = { (m1, p1), (m3,p1), (m3, p3) } – this can be an example of restricting to only those packages that contain module 1 and module 3. Note that S must be a subset of M in order for this to be sensible.

Domain Restriction Given a set S and a relation R, domain restriction operation may also be expressed as id(S) ; R – S R = id(S) ; R Consider the previous example of S and R in matrix form: 1 10 1 0 0 000 0 000 0 0000 0 0 1 0 1 01 0 10 0 1 0 0 0 000 1 0 10 id (S) : M x MR: M x P S R : M x P = ; Note that id(S) is a bit of a stretch here ; it is really - - id(DOM R)\id(DOM R - S) ?? - - - - - - this is still not quite right ?!

Range Restriction on Relation range restriction operator,, restricts a relation to only those members whose range is in a specified set. range restriction operator,, restricts a relation to only those members whose range is in a specified set. Let R: M x P be { (m1, p1), (m2, p3), (m3, p2), (m3, p3), (m4, p3) } and S = { p1,p2}, then : – R S = { (m1, p1), (m3,p2) } – this can be an example of restricting to only those modules that are packaged in package 1 and package 2. This time, S needs to be a subset of P to make sense.

Range Restriction Given a set S and a relation R, range restriction operation may also be expressed as R ; id(S) – R S = R ; id(S) Consider the previous example of S and R in matrix form: 1 10 1 0 0 00 00 0 0 0 0 0 0 0 1 0 1 1 1 1 0 0 0 000 0 0 01 id (S) : P x P R: M x P R S : M x P = ; Note that id(S) is a stretch; it is really - - - id(RAN R)\ id (RAN R- S)?

Additional Domain and Range restrictions Domain restriction may be modified to restrict the relation, R, to only those members whose domain is NOT in the specified set S. – S R Similarly, range restriction may be modified to restrict the relation, R, to only those members whose range is NOT in the specified set S. – R S

NOT restrictions on domain and range Let R: A x B, S be a proper subset of A, and T be a proper subset of B. Then Let R: A x B, S be a proper subset of A, and T be a proper subset of B. Then – S R = ( A \ S ) R – R T = R (B \ T )

Override Operator The override operator over two relations R and S, where both relations are defined over the same sets A x B, is defined as follows: R S = (domS R) U S R S = (domS R) U S

Override Operator Example Let R = { (J, m1), (T,m3), (K, m4), (S,m5) } and S = { (T,m2), (K,m3), (Q,m3) } defined over the same sets A x B where A = {J,T,K,S,Q} and B = { m1,m2,m3,m4,m5} – then R S = { (J,m1), (T,m2), (K,m3), (Q,m3), (S,m5) } Note that the original relation R is “modified” with the members in S via: –Looking at the domain of S = T, K, Q –Consider only those members in R whose domain is NOT T,K, or Q –That leaves (J,m1) and (S,m5) in R. –Union of { (j,m1), (S,m5) } and S gives us the above result. The override operator is very much like the file update capability that is often encountered in a software File System.

Relational IMAGE operator Image operator applied to a relation, R, is the same as asking for the range of R. If the Image operator is further restricted to a set S to be applied to the domain of R, then we have the Relational Image Operator, R( S ) If the Image operator is further restricted to a set S to be applied to the domain of R, then we have the Relational Image Operator, R( S ) –Relational Image Operator applied to a relation R as restricted by a set S returns the range of those members of R whose domain is in the set S. –Let R = {(a,2), (b,23), (c,11), (d,45)}, S= {b,c} Then R (|S |) = { 23, 11 } Imagine the above R was a “table” of name and address. Then R( S ) would be the equivalent to a “query” look-up for the addresses of people specified in S.

Transitive Closure Recall that earlier we defined an n-fold relation to be R n. –Let R be a Homogeneous relation R: A x A, and A is some set. –R 0 = id (A) –R n = R ; R n-1 Consider an example : A= {m1, m2, m3} and R is defined : AxA as R = {(m1,m2), (m1,m3), (m3, m2)}, then: –R 0 = {(m1,m1), (m2,m2), (m3,m3)} –R 1 = R; R 0 = {(m1,m2), (m1,m3), (m3,m2)} –R 2 = R ; R 1 = { (m1,m2) } –R 3 = R ; R 2 = { } Transitive Closure may be defined as: – Reflexive Transitive Closure of R, R* = R 0 U R 1 U R 2 U - - - U R n – Non-Reflexive Transitive Closure of R, R + = R 1 U R 2 U - - - U R n –Non-Reflexive Transitive Closure of R = Reflexive Transitive Closure of R \ R 0 or R + = R*\R 0 Check the definition on page 132 – is it correct?

Non-Reflexive Transitive Closure From the example on previous slide, –Non-Reflexive Transitive Closure = R 1 U R 2 –Since R 2 is a subset of R 1 in this case R 1 becomes the non-reflexive transitive closure. Depending on the interpretation one puts on the relation, different answers may be obtained. –If R, in this case, means module calling other modules, then the “max levels of calls” is the same as the largest n where R n is non-empty.

A Theorem Involving Relation Let: R1 be T1 x T2 and R2 be T2 x T3 ├ (R1;R2) -1 = R2 -1 ; R1 -1 –(R1;R2) -1 means x (R1; R2) -1 y –x (R1; R2) -1 y implies that y (R1; R2) x –y (R1; R2) x means there is a z in T2 such that y R1 z and z R2 x –y R1 z implies z R1 -1 y and –z R2 x implies x R2 -1 z –z R1 -1 y “and” x R2 -1 z is the same as x R2 -1 z “and” z R1 -1 y x R2 -1 z and z R1 -1 y means R2 -1 ; R1 -1

Theorems involving Relations See page 134 of your text. See page 134 of your text. You will not be held accountable of these theorems, but at least read them. They will be given to you if ever needed.

Download ppt "Domain Restriction on Relation domain restriction operator,, restricts a relation to only those members whose domain is in a specified set. domain restriction."

Similar presentations