sname rating 8 .forward Relational Algebra Operator Precedence Sample Query 0 Example Schema bid 103 sname( ( Sailors) Relational Algebra Queries

Similar documents
Comp115: Databases. Relational Algebra

SQL Aggregate Queries

Database Management Systems. Chapter 5

CSIT5300: Advanced Database Systems

CS 461: Database Systems. Relational Algebra. supplementary material: Database Management Systems Sec. 4.1, 4.2 class notes

RESERVATION.Sid and RESERVATION.Bid are foreign keys referring to SAILOR.Sid and BOAT.Bid, respectively.

SQL language: set operators

RESERVATION.Sid and RESERVATION.Bid are foreign keys referring to SAILOR.Sid and BOAT.Bid, respectively.

CSIT5300: Advanced Database Systems

Couples, Relations and Functions

Solution: Homework 2: Relational Algebra Due at 5pm on Monday, February 5, 2018

Homework 2: Relational Algebra and SQL Due at 5pm on Wednesday, July 20, 2016 NO LATE SUBMISSIONS WILL BE ACCEPTED

The Coach then sorts the 25 players into separate teams and positions

Xactix XeF2 OPERATION MANUAL

HOW TO SETUP ROUND ROBIN IN DARTS FOR WINDOWS

Relational Schema Design. Part II: Schema Decomposition. Example of Bad Design. Result of bad design: Anomalies

Prerequisites: Layout:

GHSA Swimming/Diving POP School User s Guide

Horse Farm Management s Report Writer. User Guide Version 1.1.xx

Background Information. Project Instructions. Problem Statement. EXAM REVIEW PROJECT Microsoft Excel Review Baseball Hall of Fame Problem

Homework Exercises Problem Set 1 (chapter 2)

The following steps take you through creating a hytek database for a new season May 1 st to April 30 th.

Dive Planet. Manual. Rev Basic User Interface. 2 How to organize your dives. 3 Statistics. 4 Location Service and Map View.

{ } Plan#for#Today# CS#133:#Databases# RelaKonal#Calculus# Rel.#Alg.#Compound#Operator:# Division# A B = x y B( x, y A)

Table Football. Introduction. Scratch. Let s make a world cup football game in Scratch! Activity Checklist. Test your Project.

Lesson 20: Estimating a Population Proportion

Table of Contents. 1 Command Summary...1

You are going to learn how to make a game, in which you ll use the mouse to navigate a boat to a desert island.

Felix and Herbert. Level

[XACT INTEGRATION] The Race Director. Xact Integration

Managing Timecard Exceptions

Lab 4: Root Locus Based Control Design

CS Problem Solving and Object-Oriented Programming Lab 2 - Methods, Variables and Functions in Alice Due: September 23/24

SCW Web Portal Instructions

Administration and IT Assignment Assessment Task: Sounds on the Shore

Boat Race. Introduction. Scratch. You are going to learn how to make a game, in which you ll use the mouse to navigate a boat to a desert island.

Working with Object- Orientation

Lesson 20: Estimating a Population Proportion

Look again at the election of the student council president used in the previous activities.

Guide to Using I CSA TechScore

Boat Race. Introduction. Scratch

For clarification or assistance with TDM-web or any USTA web-based application,

How to Setup and Score a Tournament. May 2018

DUTCH5 USER GUIDE February 2013

Hot Springs Village Member Portal User Guide

CprE 281: Digital Logic

Smart Card based application for IITK Swimming Pool management

Student Population Projections By Residence. School Year 2016/2017 Report Projections 2017/ /27. Prepared by:

Excel 2013 Pivot Table Calculated Field Greyed Out

Monday Tuesday Wednesday Thursday

Prescot SC & Everton SA

EXAM # 2. First Name Last Name CIRCLE YOUR LECTURE BELOW: INSTRUCTIONS

TEAM MANAGER LITE ENTRY INSTRUCTIONS

Tension Cracks. Topics Covered. Tension crack boundaries Tension crack depth Query slice data Thrust line Sensitivity analysis.

2019 Team Registration UCI Mountain Bike Teams UCI DataRide Teams Registration process

Navigate to the golf data folder and make it your working directory. Load the data by typing

CS 341 Computer Architecture and Organization. Lecturer: Bob Wilson Cell Phone: or

ALGE DIVE! ALGE. ALGE-TIMING GmbH & Co

FIBA Europe Coaching Website. Manual. Practice Section

ADULT/SENIOR RANKING RULES, REGULATIONS AND REQUIREMENTS

Prescot SC & Everton SA

Lab 11 Density and Buoyancy

Mac Software Manual for FITstep Pro Version 2

Homework 4 PLAYERS, TEAMS, MATCHES, PENALTIES, COMMITTEE_MEMBERS

2017 Census Reporting To access the SOI s Census Reporting web site go to:

Prescot SC & Everton SA

RUNNING MEET MANAGER IN SUPPORT OF MEETS (2016) Greg Wright(6/3/16) First, YOU DO NOT NEED TO DO THIS UNLESS YOU ARE THE HOME TEAM

PHYS 1020 LAB 8: Buoyancy and Archimedes Principle. Pre-Lab

ECE 140: Linear Circuits (Whmis Test) Lab Instructors: Nizar Messaoudi & Mike Foulger

Team Manager's Manual

Using a double entry table "Temperature graph"

District Supplemental Rules for: South Atlantic Interscholastic Sailing Association (SAISA)

LEVEL 9 REQUIREMENTS

CSE 154: Web Programming Spring 2017 Homework Assignment 5: Pokedex. Overview. Due Date: Tuesday, May 9th

The Beginner's Guide to Mathematica Version 4

Williams, Justin à Player name (last name, first name) CAR

Iteration: while, for, do while, Reading Input with Sentinels and User-defined Functions

Extra: What is the minimum (fewest) number of train cars that it would take to hold all those passengers at once, if each car holds 12 passengers?

USA Jump Rope Regional Tournament Registration User Guide 2014 Edition

GOLF LIFE MANAGEMENT SYSTEM Member Manual

MyCricket User Manual

ADULT/SENIOR RANKING RULES, REGULATIONS AND REQUIREMENTS

STAT 625: 2000 Olympic Diving Exploration

Contents DE LA SALLE COLLEGE OLLIE USAGE GUIDE 2

Summary and Comparison of the Data Used by the TTO and CRS Reelection Analyses

Missouri Hockey Youth Division Scheduling Web Site Club Coach & Manager Manual Updated - 9/5/2013

New Coach Handbook

Instruction Guide for using Dive Tables (draft)

7th Annual National YMCA Virtual Invitational Swim Meet Swim Locally Compete Nationally

Chapter 6 Handicapping

Rig Math. Page 1.

Notice of Race HEAT 1

NOTICE OF RACE Posted 6/28/2017

[CROSS COUNTRY SCORING]

Personal Study Plan (PSP) Student Instructions

THE DOINGS. August Commodore s Corner

November 1, Greetings Cyclocross Race Directors:

Town of Wakarusa. Americans with Disabilities Act Transition Plan: Pedestrian Facilities in the Public Right-of-Way

PGA Tour, Champions Tour & Web.com Tour LED Scoreboard Graphical Style Guide and Tournament Instructions. (Revised 4/1/2018) Section 1: Introduction

The next criteria will apply to partial tournaments. Consider the following example:

Transcription:

.forward Please put your preferred email address in.forward file of your login directory at cs.umb.edu, for example: Relational Algebra Queries cat >.forward joe@gmail.com <control-d> Then email to joe@cs.umb.edu will be forwarded to joe@gmail.com, allowing us to use the class email list cs630-1@cs.umb.edu. In particular, I will use this list to announce new homework, corrections to it, etc. <control-d> is a single character produced on the keyboard by depressing the control key and then the D key. C430/630 Lecture 3 lides based on Database Management ystems 3 rd ed, Ramakrishnan and Gehrke Relational Algebra Basic operations: election elects a subset of rows from relation Projection Deletes unwanted columns from relation Cross-product Allows us to combine several relations Join Combines several relations using conditions Division A bit more complex, will cover later on et-difference Union Intersection Renaming Helper operator, does not derive new result, just renames relations and fields ( R( F), E) F contains oldname newname pairs Operator Precedence In decreasing order of priority: 1. election Projection 2. Cross-product Join 3. et-difference Intersection 4. Union Example: means not bid 103 ( ) bid 103 ( ) bid 103 Example chema ample Query 0 Find names of sailors who have ratings at least 8. Detail of sailor sid Another sailor detail sname( ( ) rating 8 sname rating8

Join sname rating age 22 101 10/10/9 dustin 7 45.0 6 58 103 11/12/9 6 rusty 10 Each sid in is filled out with ailor attributes ample Query 1 bid only, no Boat deta Find names of sailors who ve reserved boat #103 Detail of sailor sid sid, bid in reserves table sname(( ) ) bid 103 sname ( ( bid 103 Example chema ample Query 2 Find names of sailors who ve reserved a red boat sname( (( ( B R) ) color ' sname (( serves color ' red ' ) Re ) ample Query 2 Find names of sailors who ve reserved a red boat One way that s right: sname (( serves color ' red ' ) Re ) but this next is Wrong!: Watch out for precedence! sname color' ( sname( color' empty! ample Query 3 Find names of sailors who ve reserved a red or a green boat ( Tempboats, ( color ' red ' color ' green' sname( Tempboats ) sname ( B R ) color ' red color ' green'

ample Query 4 Find names of sailors who ve reserved a red and a green boat ( Tempred, (( ) Re serves sid color ' red ' ( Tempgreen, (( ) Re serves sid color ' green' sname (( Tempred Tempgreen) ) ample Query 5 Find names of sailors who ve reserved only red boats ( Tempred, (( ) Re serves sid color ' red ' ( Tempothers, (( ) sid color' sname(( Tempred Tempothers) ) Time to try it yourself Try the exercises on the handed-out sheet You can confer with neighbors this is not graded Turn in completed paper for the 3 points Lab sheet (olution) (olution posted later) Note: you need to attend class to get credit for this work it is a form of class participation. An Example of elf-joins Find sailors with maximum age No max operator in RA (QL has this) Need a trick: self join with left age smaller than right age This will list rows for all ages for left side but the max age row(s) Then use all-sailors this list An Example of elf-join: cross-product with rows eliminated by condition LeftHalf sid1 sname1 rating1 age1 sid2 sname2 rating2 age2 Join condition: left age smaller than right age An Example of elf-join: Max ages ( 1, ) ( 2, ) ( f1,2 f 2,3 f 3,4 f 4), 1 age 2. age ( LeftHalf, f TempJoin) 1, f 2, f 3, f 4 Finally, subtract the resulting left hand side from the initial relation, and you get sailors with maximum ages Final result is LeftHalf

More on Natural Joins Natural Joins match all same-named columns Consider two tables T1 and T2: T1(id1, attr1, city) T2(id2, id1, attr2, city) Probably want to join on id1, a key for T1 showing up in both tables But T1 and T2 have id1 and city in common, so a natural join T1 T2 matches both If we don t want non-key columns matched like this We can use a theta join with an explicit condition: T1 t1.id1=t2.id1 T2 Or project out city before one of the joins Consider the Example chema, modified to have a name attribute for two entities sid name rating age ample Query 2 on modified schema sid name rating age Find names of sailors who ve reserved a red boat Old solution: sname (( color ' red ' ) Re serves ) Returns an empty relation! It s looking for matches on name as well as bid, sid ample Query 2 on modified schema sid name rating age Find names of sailors who ve reserved a red boat Old solution for unmodified schema: returns empty table here sname (( serves color ' red ' ) Re ) Here we can project out boat names before join to name ((( B) R) ) bid color ' Another self join: Close competitors Find pairs of sailors (sids) with ratings that differ by no more than one. ( 1, ) ( 2, ) We don t want a lot of these results 28 yuppy 9 44 58 guppy rusty 5 10 ( sid1,5 sid, 1 rating2. rating1^ rating2. rating1 TempJoin sid1, sid2 sid1 sid2 28 28 28 31 28 58 31 28 Another self join Find pairs of different sailors (sids) with ratings that differ by no more than one, listing each unordered pair once. ( 1, ) ( 2, ) ( sid1,5 sid, 1 TempJoin sid1, sid2 That s better! 28 yuppy 9 44 58 guppy rusty 5 10 rating 2. rating 1^ rating 2. rating 1^ sid 2. sid sid1 sid2 28 31 28 58

Like Query 0 Find colors of boats with names starting with C Detail of Boat Another Boat detail (assume lowercase names) (( ) color name' c'^name' d' color name' c'^name' d' Like Query 3 Find names of sailors who ve reserved a red or a green boat. List names and the boat color (two rows if the sailor rented both color boats) ( Tempboats, ( color ' red ' color ' green', ( Tempboats ) sname color