Carnegie mellon univ dept of computer science 15 415 database applications
Download
1 / 43

Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications - PowerPoint PPT Presentation


  • 76 Views
  • Uploaded on

Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications. C. Faloutsos Relational domain calculus. General Overview. relational model Formal query languages relational algebra rel. tuple calculus rel. domain calculus. Overview - detailed. rel. tuple calculus dfn

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications' - quinta


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Carnegie mellon univ dept of computer science 15 415 database applications

Carnegie Mellon Univ.Dept. of Computer Science15-415 - Database Applications

C. Faloutsos

Relational domain calculus


General overview
General Overview

  • relational model

  • Formal query languages

    • relational algebra

    • rel. tuple calculus

    • rel. domain calculus

15-415 - C. Faloutsos


Overview detailed
Overview - detailed

  • rel. tuple calculus

    • dfn

    • details

    • equivalence to rel. algebra

  • rel. domain calculus + QBE

15-415 - C. Faloutsos


Rel domain calculus rdc
Rel. domain calculus (RDC)

  • Q: why?

  • A: slightly easier than RTC, although equivalent - basis for QBE.

  • idea: domain variables (w/ F.O.L.) - eg:

  • ‘find STUDENT record with ssn=123’

15-415 - C. Faloutsos


Rel dom calculus
Rel. Dom. Calculus

  • find STUDENT record with ssn=123’

15-415 - C. Faloutsos


Details
Details

  • Like R.T.C - symbols allowed:

  • quantifiers

15-415 - C. Faloutsos


Details1
Details

  • but: domain (= column) variables, as opposed to tuple variables, eg:

ssn

address

name

15-415 - C. Faloutsos


Reminder our mini u db
Reminder: our Mini-U db

15-415 - C. Faloutsos


Examples
Examples

  • find all student records

RTC:

15-415 - C. Faloutsos


Examples1
Examples

  • (selection) find student record with ssn=123

15-415 - C. Faloutsos


Examples2
Examples

  • (selection) find student record with ssn=123

or

RTC:

15-415 - C. Faloutsos


Examples3
Examples

  • (projection) find name of student with ssn=123

15-415 - C. Faloutsos


Examples4
Examples

  • (projection) find name of student with ssn=123

need to ‘restrict’ “a”

RTC:

15-415 - C. Faloutsos


Examples cont d
Examples cont’d

  • (union) get records of both PT and FT students

RTC:

15-415 - C. Faloutsos


Examples cont d1
Examples cont’d

  • (union) get records of both PT and FT students

15-415 - C. Faloutsos


Examples5
Examples

  • difference: find students that are not staff

RTC:

15-415 - C. Faloutsos


Examples6
Examples

  • difference: find students that are not staff

15-415 - C. Faloutsos


Cartesian product
Cartesian product

  • eg., dog-breeding: MALE x FEMALE

  • gives all possible couples

=

x

15-415 - C. Faloutsos


Cartesian product1
Cartesian product

  • find all the pairs of (male, female) - RTC:

15-415 - C. Faloutsos


Cartesian product2
Cartesian product

  • find all the pairs of (male, female) - RDC:

15-415 - C. Faloutsos


Proof of equivalence
‘Proof’ of equivalence

  • rel. algebra <-> rel. domain calculus

    <-> rel. tuple calculus

15-415 - C. Faloutsos


Overview detailed1
Overview - detailed

  • rel. domain calculus

    • why?

    • details

    • examples

    • equivalence with rel. algebra

    • more examples; ‘safety’ of expressions

15-415 - C. Faloutsos


More examples
More examples

  • join: find names of students taking 15-415

15-415 - C. Faloutsos


Reminder our mini u db1
Reminder: our Mini-U db

15-415 - C. Faloutsos


More examples1
More examples

  • join: find names of students taking 15-415 - in RTC

15-415 - C. Faloutsos


More examples2
More examples

  • join: find names of students taking 15-415 - in RDC

15-415 - C. Faloutsos


Sneak preview of qbe
Sneak preview of QBE:

15-415 - C. Faloutsos


Sneak preview of qbe1
Sneak preview of QBE:

  • very user friendly

  • heavily based on RDC

  • very similar to MS Access interface

15-415 - C. Faloutsos


More examples3
More examples

  • 3-way join: find names of students taking a 2-unit course - in RTC:

join

projection

selection

15-415 - C. Faloutsos


Reminder our mini u db2
Reminder: our Mini-U db

_x

.P

_y

2

_x

_y

15-415 - C. Faloutsos


More examples4
More examples

  • 3-way join: find names of students taking a 2-unit course

15-415 - C. Faloutsos


More examples5
More examples

  • 3-way join: find names of students taking a 2-unit course

15-415 - C. Faloutsos


Even more examples
Even more examples:

  • self -joins: find Tom’s grandparent(s)

15-415 - C. Faloutsos


Even more examples1
Even more examples:

  • self -joins: find Tom’s grandparent(s)

15-415 - C. Faloutsos


Even more examples2
Even more examples:

  • self -joins: find Tom’s grandparent(s)

15-415 - C. Faloutsos


Even more examples3
Even more examples:

  • self -joins: find Tom’s grandparent(s)

15-415 - C. Faloutsos


Hard examples division
Hard examples: DIVISION

  • find suppliers that shipped all the ABOMB parts

15-415 - C. Faloutsos


Hard examples division1
Hard examples: DIVISION

  • find suppliers that shipped all the ABOMB parts

15-415 - C. Faloutsos


Hard examples division2
Hard examples: DIVISION

  • find suppliers that shipped all the ABOMB parts

15-415 - C. Faloutsos


More on division
More on division

  • find students that take all the courses that ssn=123 does (and maybe even more)

15-415 - C. Faloutsos


More on division1
More on division

  • find students that take all the courses that ssn=123 does (and maybe even more)

15-415 - C. Faloutsos


Safety of expressions
Safety of expressions

  • similar to RTC

  • FORBIDDEN:

15-415 - C. Faloutsos


Overview detailed2
Overview - detailed

  • rel. domain calculus + QBE

    • dfn

    • details

    • equivalence to rel. algebra

15-415 - C. Faloutsos


ad