Native Relational Operations (Cont.)


Selection
Give a table S with Head(S)=A1…An, the selection operation creates a new table, denoted by S where C, with the same set of attributes, and consisting of those tuples of S that obey the selection condition denoted by C. A condition of selection determines, for each given tuple of the table, whether that tuple is qualified to remain in the set of selected rows making up the answer. The form a condition C can take is defined recursively as follows.
  1. C can be any comparison of the form Ai∝Aj or Ai∝a, where Ai and Aj are attributes of S having the same domain, a is a constant from Dom(Ai), and is one of the comparison operations <, >, <=, >=, and <>. The table S where Ai∝Aj consists of all rows t of S with the property that t[Ai]∝t[Aj]; the table S where Ai∝a contains all rows t of S with the property t[Ai]∝a.

  2. If C and C’ are conditions, then new conditions can be formed by writing C and C’, C or C’, and finally not C, possibly enclosing any such newly formed conditions in parentheses. If U:=S where C1 and V:=S where C2 then we have

    • The and connector: S where C1 and C2 means U∩V.

    • The or connector: S where C1 or C2 means U∪V.
    • The not connector: S where not C1 means S–U.
Query: Find all customers based in Kyoto.

customer
cid cname city discnt
c001 TipTop Duluth 10.00
c002 Basics Dallas 12.00
c003 Applied Dallas 8.00
c004 ACME Duluth 8.00
c006 ACME Kyoto 0.00

CUSTOMER where city='Kyoto'
cid cname city discnt
c006 ACME Kyoto 0.00




      Love in the real world means saying you’re sorry 10 times a day.    
      — Kathie Lee Gifford