1 / 13

Domain Restriction on Relation

Domain Restriction on Relation. 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 :

arlo
Download Presentation

Domain Restriction on Relation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Domain Restriction on Relation 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.

  2. 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 0 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 ; = 0 0 1 0 1 0 1 1 0 1 0 0 0 0 0 0 1 0 0 0 S R : M x P id (S) : M x M 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 ?!

  3. Range Restriction on Relation 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.

  4. 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 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 1 ; = 0 1 1 0 1 0 0 0 0 0 0 1 0 0 0 id (S) : P x P R S : M x P R: M x P Note that id(S) is a stretch; it is really - - - id(RAN R)\ id (RAN R- S)?

  5. 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

  6. 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 • S R = ( A \ S ) R • R T = R (B \ T )

  7. 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

  8. 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.

  9. Relational IMAGE operator • Imageoperator 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 ) • 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.

  10. Transitive Closure • Recall that earlier we defined an n-fold relation to be Rn. • Let R be a Homogeneous relation R: A x A , and A is some set. • R0 = id (A) • Rn = 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: • R0 = {(m1,m1), (m2,m2), (m3,m3)} • R1 = R; R0 = {(m1,m2), (m1,m3), (m3,m2)} • R2 = R ; R1 = { (m1,m2) } • R3 = R ; R2 = { } • Transitive Closure may be defined as: • Reflexive Transitive Closure of R, R* = R0 U R1 U R2 U - - - U Rn • Non-Reflexive Transitive Closure of R, R+ = R1 U R2 U - - - U Rn • Non-Reflexive Transitive Closure of R = Reflexive Transitive Closure of R \ R0 or R+ = R*\R0 Check the definition on page 132 – is it correct?

  11. Non-Reflexive Transitive Closure • From the example on previous slide, • Non-Reflexive Transitive Closure = R1 U R2 • Since R2 is a subset of R1 in this case R1 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 Rn is non-empty.

  12. 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

  13. Theorems involving Relations • 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.

More Related