1 / 12

Relational Algebra Example Queries: Recap, Operators, and Banking Enterprise Schema

This learning session covers a recap on the operators of relational algebra and explores example queries using the banking enterprise schema.

emarson
Download Presentation

Relational Algebra Example Queries: Recap, Operators, and Banking Enterprise Schema

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. Session 3 Welcome: To session 3-the fourth learning sequence “Relational algebra “ Recap : In the previous learning sequences, we discussed the four operators of relational algebra. Present learning: We shall explore the following topic: - Example Queries

  2. Relational Algebra

  3. Relational Algebra • A basic expression in the relational algebra consists of either one of the following: • A relation in the database • A constant relation

  4. Relational Algebra Let E1 and E2 be relational-algebra expressions; the following are relational-algebra expressions: E1 E2 E1  E2 E1 - E2 E1 x E2 p (E1), P is a predicate on attributes in E1 s(E1), S is a list consisting of some of the attributes in E1 x(E1), x is the new name for the result of E1 The assignment operation ()

  5. Relational Schema for the Banking Enterprise branch (branch-name, branch-city, assets) customer (customer-name, customer-street, customer-only) account (account-number, branch-name, balance) loan (loan-number, branch-name, amount) depositor (customer-name, account-number) borrower (customer-name, loan-number)

  6. Example Queries Find all loans of over $1200. amount> 1200 (loan) • Find the loan number for each loan of an amount greater than $1200. loan-number (amount> 1200 (loan))

  7. Example Queries Find the names of all customers who have a loan, an account, or both, from the bank. customer-name (borrower)  customer-name (depositor) • Find the names of all customers who have a loan and an account at bank. customer-name (borrower)  customer-name (depositor)

  8. Find the names of all customers who have a loan at the Perryridge branch. Example Queries customer-name (branch-name=“Perryridge” (borrower.loan-number = loan.loan-number(borrower x loan))) • Find the names of all customers who have a loan at the Perryridge branch but do not have an account at any branch of the bank. customer-name (branch-name = “Perryridge” (borrower.loan-number = loan.loan-number(borrower x loan))) – customer-name(depositor)

  9. Find the names of all customers who have a loan at the Perryridge branch. Example Queries • Query 1customer-name(branch-name = “Perryridge”( borrower.loan-number = loan.loan-number(borrower x loan)))  Query 2 customer-name(loan.loan-number = borrower.loan-number( (branch-name = “Perryridge”(loan)) x borrower))

  10. Find the largest account balance Rename account relation as d The query is: Example Queries balance(account) - account.balance (account.balance < d.balance(account x rd (account)))

  11. Relational Algebra Summary: In this learning sequence, we discussed some example queries.

  12. END

More Related