Posts

Thursday, 13 September 2018

Relational Model #2


Relational Query Languages


  • Selection of tuples
  • Relation r
    after selection


    • If I want to select tuples with A=B and D>5 in relation r,
    • σA=B and D>5 (r)

  • Selection of Attributes
    • Projection
    • Π A, C (r)
after projection

  • Cartesian Product - Cross product!
relations r and s

    •  Cartesian product returns every possible pair in the result.

r ╳ s

  • Union of two relations
relations r and s

    • r ∪ s =

Union of r and s
  • Set difference between two relations
relations r and s
    • r - s = 

    differences
    • Set intersection between two relations
    relations r and s
      • r ∩ s =
    intersection

    • Natural Join
      • Let r and s be relations on schemas R and S respectively. Then, the 'natural join' of relations R and S is a relation on schema R∪ S obtain as follows:
        1. Consider each pair of tuples tr from r and tform s.
        2. If tr and thave the same value on each of the attributes in R∩ S, add a tuple t to the result, where
          • t has the same value as tr on r
          • t has the same value as ts on s
    relations r and s

      •  r ⋈ s

    Natural join r and s


    No comments:

    Post a Comment

    [ new blog ]

    new blog https://jihyo-jeon.github.io/