1 / 8

TRC vs DRC

TRC vs DRC. 2003. 10. 12 한욱신. Queries in TRC and DRC. TRC Q = {t| f(t)} where t is a (free) tuple variable and f(t) is a well-formed formula DRC Q = {x 1 ,x 2 ,..,x k | f(x 1 ,x 2 ,..,x k )} where x i is a (free) domain variable and f(x 1 ,x 2 ,..,x k ) is a well-formed formula.

finola
Download Presentation

TRC vs DRC

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. TRC vs DRC 2003. 10. 12 한욱신

  2. Queries in TRC and DRC • TRC • Q = {t| f(t)} where t is a (free) tuple variable and f(t) is a well-formed formula • DRC • Q= {x1,x2,..,xk| f(x1,x2,..,xk)} where xi is a (free) domain variable and f(x1,x2,..,xk) is a well-formed formula

  3. Well-formed formula • Wffs are constructed using the following rules • Each atomic formula is a wff • If P, Q are wffs, then so are NOT P, (P AND Q), (P OR Q), and (P  Q) • If x is a (tuple or domain) variable and P is a wff, then so are x P, and x P

  4. Atomic formulas in TRC and DRC • TRC • R(t) where R is a relation name and t is a tuple variable • ti[A]  tj[B] where ti and tj are tuple variables; A and B are attributes names;  is a comparison operator (=, <, >, , , ) • ti[A]  constant • DRC • R(x1,x2,…,xk) where R is a relation name and xi is a domain variable or constant • x  y where x and y are domain variables • x  constant where x is a domain variable

  5. Example Schema • Sailors(sid, sname, rating, age) • Boats(bid, bname, color) • Reserves(sid, bid, date)

  6. Q1) Find sailors who’ve reserved at least one boat Relational Algebra sid(SailorsReserves) TRC {p|(r)(s)(Reserves(r) AND Sailors(s) AND /* initiate tuple variables */ r[sid] = s[sid] AND /* join condition */ p[1st attr] = s[sid])} /* projection */ DRC {s| (b)(d)(s2)(sn)(r)(a)(Reserves(s,b,d) AND Sailors(s2, sn, r,a) AND /* initiate tuple variables */ s = s2) /* join condition */ }

  7. Q2) Find sid’s of sailors who’ve reserved a red or a green boat Relational Algebra TRC {p|(r)(s)(b)(Reserves(r) AND Sailors(s) AND Boats(b) AND /* initiate tuple variables */ r[sid] = s[sid] AND /* join condition */ r[bid] = b[bid] AND /* join condition */ (b[color] = ‘red’ OR b[color] = ‘green’) AND /* selection condition */ p[1st attr] = s[sname])} /* projection */ DRC {s| (b)(d)(s2)(sn)(r)(a)(b2)(bn)(c)(Reserves(s,b,d) AND Sailors(s2, sn, r,a) AND Boats(b2, bn, c) AND /* initiate tuple variables */ s = s2 AND b=b2 AND /* join condition */ (c = ‘red’ OR c = ‘green’))}

  8. Q3) Find sid’s of sailors who’ve reserved a red and a green boat Relational Algebra TRC {p|(r)(s)(b)(Sailors(s) AND Boats(b1) AND Reserves(r1) AND Boats(b2) AND Reserves(r2) AND /* initiate tuple variables */ s[sid]=r1[sid] AND r1[bid]=b1[bid] AND s[sid]=r2[sid] AND r2[bid]=b2[bid] AND (b1[color]=‘red’ AND b2[color]=‘green’ AND p[1st attr] = s[sname])} /* projection */ DRC {s| (b)(d)(s2)(sn)(r)(a)(b2)(bn)(c) )(s2’)(sn’)(r’)(a’)(b2’)(bn’)(c’) ( Reserves(s,b,d) AND Sailors(s2, sn, r,a) AND Boats(b2, bn, c) AND Sailors(s2’, sn’, r’,a’) AND Boats(b2’, bn’, c’) AND /* initiate tuple variables */ s = s2 AND b=b2 AND s = s2’ AND b=b2’ AND/* join condition */ (c = ‘red’ AND c’ = ‘green’))}

More Related