0
Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

# Presentation on dbms(relational calculus)

6,500

Published on

Published in: Education, Technology
3 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total Views
6,500
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
125
0
Likes
3
Embeds 0
No embeds

No notes for slide

### Transcript

• 1.   RELATIONAL CALCULUS   www.powerpointpresentationon.blogspot.com TUSHAR GUPTA
• 2. INTRODUCTION TO RELATIONAL MODEL <ul><ul><li>Invented by E.F. (Ted) Codd </li></ul></ul><ul><ul><li>Based on first-order predicate logic </li></ul></ul><ul><ul><li>Its core idea is to describe a database as a collection of predicates over a finite set of predicate variables, describing constraints on the possible values and combinations of values. </li></ul></ul>TUSHAR GUPTA
• 3. THE MODEL <ul><ul><li>Data is represented as mathematical n -ary relations, an n -ary relation being a subset of the Cartesian product of n domains. </li></ul></ul><ul><ul><li>two-valued predicate logic , meaning there are two possible evaluations for each proposition : either true or false. </li></ul></ul><ul><ul><li>Data are operated upon by means of a relational calculus (procedural) or relational algebra (descriptive), these being equivalent in expressive power . </li></ul></ul>TUSHAR GUPTA
• 4. THE MODEL <ul><ul><li>The basic relational building block is the domain or data type (or relvar). </li></ul></ul><ul><ul><li>A tuple is an set of attribute values. </li></ul></ul><ul><ul><li>An attribute is an ordered pair of attribute name and type name . </li></ul></ul>TUSHAR GUPTA
• 5. SQL AND THE RELATIONAL MODEL <ul><ul><li>Duplicate rows </li></ul></ul><ul><ul><li>Anonymous columns </li></ul></ul><ul><ul><li>Duplicate column names </li></ul></ul><ul><ul><li>Column order significance </li></ul></ul><ul><ul><li>NULL </li></ul></ul>TUSHAR GUPTA
• 6. RELATIONAL OPERATIONS <ul><ul><li>Join </li></ul></ul><ul><ul><li>Project - process of eliminating some of the columns </li></ul></ul><ul><ul><li>Restrict - process of eliminating some of the rows </li></ul></ul><ul><ul><li>Union - a way of combining two tables with similar structures </li></ul></ul>TUSHAR GUPTA
• 7. RELATIONAL OPERATIONS <ul><ul><li>Difference- lists the rows in one table that are not found in the other </li></ul></ul><ul><ul><li>Intersect - lists the rows found in both tables </li></ul></ul><ul><ul><li>Product - combines each row of one table with each row of the other </li></ul></ul>TUSHAR GUPTA
• 8. RELATIONAL CALCULUS <ul><ul><li>Comes in two flavors: Tuple relational calculus (TRC) and Domain relational calculus (DRC). </li></ul></ul><ul><ul><li>Calculus has variables, constants, comparison ops , logical connectives and quantifiers . </li></ul></ul><ul><ul><ul><li>TRC : Variables range over (i.e., get bound to) tuples . </li></ul></ul></ul><ul><ul><ul><li>DRC : Variables range over domain elements (= field values). </li></ul></ul></ul>TUSHAR GUPTA
• 9. RELATIONAL CALCULUS <ul><ul><li>Expressions in the calculus are called formulas . </li></ul></ul><ul><ul><li>An answer tuple is essentially an assignment of constants to variables that make the formula evaluate to true . </li></ul></ul>TUSHAR GUPTA
• 10. TUPLE RELATIONAL CALCULUS <ul><ul><li>Query: {T|P(T)} </li></ul></ul><ul><ul><ul><li>T is tuple variable </li></ul></ul></ul><ul><ul><ul><li>P(T) is a formula that describes T </li></ul></ul></ul><ul><ul><li>Result: the set of all tuples t for which P(t) evaluates True. </li></ul></ul><ul><ul><ul><li>Find all sailors with a rating above 7. </li></ul></ul></ul>TUSHAR GUPTA
• 11. TRC <ul><ul><li>Atomic formula </li></ul></ul><ul><ul><ul><li>R.a op S.b , op is one of </li></ul></ul></ul><ul><ul><ul><li>R.a op constant </li></ul></ul></ul><ul><ul><li>Formula </li></ul></ul><ul><ul><ul><li>Any atomic formula combined: </li></ul></ul></ul>TUSHAR GUPTA
• 12. TRC <ul><ul><li>Example </li></ul></ul><ul><ul><ul><li>Find the names and ages of sailors with a rating above 7 </li></ul></ul></ul><ul><ul><ul><li>Find the names of sailors who have reserved all boats </li></ul></ul></ul>TUSHAR GUPTA
• 13. DOMAIN RELATIONAL CALCULUS <ul><ul><li>Query has the form: </li></ul></ul><ul><ul><li>Answer includes all tuples that make the formula be true . </li></ul></ul><ul><ul><li>Atomic formula: </li></ul></ul><ul><ul><ul><li>, Where Rname is relation specified or could be as X op Y, or X op constant </li></ul></ul></ul><ul><ul><ul><li>op is one of </li></ul></ul></ul>TUSHAR GUPTA
• 14. DRC <ul><ul><li>Formula: </li></ul></ul><ul><ul><ul><li>an atomic formula, or </li></ul></ul></ul><ul><ul><ul><li>,               where p and q are formulas, or </li></ul></ul></ul><ul><ul><ul><li>,                 where variable X is free in p(X) </li></ul></ul></ul>TUSHAR GUPTA
• 15. DRC <ul><ul><li>Examples </li></ul></ul><ul><ul><li>Find all sailors with a rating above 7 </li></ul></ul><ul><ul><li>Find sailors rated > 7 who’ve reserved boat #103 </li></ul></ul>TUSHAR GUPTA
• 16. UNSAFE QUERIES, EXPRESSIVE POWER <ul><ul><li>It is possible to write syntactically correct calculus queries that have an infinite number of answers! Such queries are called unsafe . </li></ul></ul><ul><li>Eg: </li></ul><ul><ul><li>It is known that every query that can be expressed in relational algebra can be expressed as a safe query in DRC / TRC; the converse is also true. </li></ul></ul>TUSHAR GUPTA
• 17. LIMITATIONS OF THE RELATIONAL ALGEBRA / CALCULUS <ul><li>Can not do: </li></ul><ul><ul><li>Aggregate operations </li></ul></ul><ul><ul><li>Recursive queries </li></ul></ul><ul><ul><li>Complex (non-tabular) structures </li></ul></ul><ul><ul><li>Most of these are expressible in SQL, OQL, XQuery – using other special operators </li></ul></ul>TUSHAR GUPTA