0 Up votes0 Down votes

278 views5 pagesrelational algebra

Jan 12, 2017

© © All Rights Reserved

DOCX, PDF, TXT or read online from Scribd

relational algebra

© All Rights Reserved

278 views

relational algebra

© All Rights Reserved

- T8 B17 FAA Trips 1 of 3 Fdr- FAA Document Index
- REA diagram
- Itech 2004 Data Modelling Assignment 1
- File Processing System and Its Disadvantages
- NC New River Inlet 20130513 TM Geo (1)
- Raster Data
- solutions manual fundamentals.pdf
- 3.Relational Model
- Chapter_2
- 15 Slide
- Ppt Security
- Table Expressions.docx
- Adaptive Object-Modeling: Patterns, Tools and Applications
- Dbms Notes
- DATABASE NORMALIZATION 2
- 06 Database Concepts
- Lecture 15bs
- Rajanoopschap5and6.pdf
- Data Processing
- Week3 - Lec2 - Data Modeling Using ER Model and Its Extensions

You are on page 1of 5

Person ( name, age, gender )

Frequents ( name, pizzeria )

Eats ( name, pizza )

Serves ( pizzeria, pizza, price )

name is a key

(name, pizzeria) is a key

(name, pizza) is a key

(pizzeria, pizza) is a key

Write relational algebra expressions for the following nine queries. (Warning: some of

the later queries are a bit challenging.)

If you know SQL, you can try running SQL queries to match your relational algebra

expressions. We've created a file for download with schema declarations and sample

data. (See our quick guide for SQL system instructions.) To check your queries, the

correct results are found in the answers section below.

a.

Find all pizzerias frequented by at least one person under the age of 18.

b.

Find the names of all females who eat either mushroom or pepperoni pizza (or both).

c.

Find the names of all females who eat both mushroom and pepperoni pizza.

d.

Find all pizzerias that serve at least one pizza that Amy eats for less than $10.00.

e.

Find all pizzerias that are frequented by only females or only males.

For each person, find all pizzas the person eats that are not served by any pizzeria the person frequents.

f.

g.

Find the names of all people who frequent only pizzerias serving at least one pizza they eat.

h.

Find the names of all people who frequent every pizzeria serving at least one pizza they eat.

i.

Find the pizzeria serving the cheapest pepperoni pizza. In the case of ties, return all of the cheapest-peppero

2. Consider a schema with two relations, R(A, B) and S(B, C), where all values are

integers. Make no assumptions about keys. Consider the following three relational

algebra expressions:

Two of the three expressions are equivalent (i.e., produce the same answer on all

databases), while one of them can produce a different answer. Which query can

produce a different answer? Give the simplest database instance you can think of

where a different answer is produced.

3. Consider a relation R(A, B) that contains r tuples, and a relation S(B, C) that

contains s tuples; assume r > 0 and s > 0. Make no assumptions about keys. For each

of the following relational algebra expressions, state in terms of r and s the minimum

and maximum number of tuples that could be in the result of the expression.

the semijoin and antijoin. Semijoin is the same as natural join, except only attributes

of the first relation are returned in the result. For example, if we have

relations Student(ID, name) and Enrolled(ID, course), and not all students are enrolled

in courses, then the query "Student Enrolled" returns the ID and name of all

students who are enrolled in at least one course. In the general case, E 1 E2 returns

all tuples in the result of expression E 1 such that there is at least one tuple in the result

of E2 with matching values for the shared attributes. Antijoin is the converse:

E1 E2 retuns all tuples in the result of expression E 1 such that there are no tuples in

the result of E2 with matching values for the shared attributes. For example, the query

"Student Enrolled" returns the ID and name of all students who are not enrolled in

any courses.

Like some other relational operators (e.g., intersection, natural join), semijoin and

antijoin are abbreviations - they can be defined in terms of other relational operators.

"E1 E2 = ??", where ?? on the right-hand side is a relational algebra expression that

doesn't use semijoin. Similarly, give an equation "E 1 E2 = ??", where ?? on the righthand side is a relational algebra expression that doesn't use antijoin.

5. Consider a relation Temp(regionID, name, high, low) that records historical high

and low temperatures for various regions. Regions have names, but they are identified

by regionID, which is a key. Consider the following query, which uses the linear

notation introduced at the end of the relational algebra videos.

State in English what is computed as the final Result. The answer can be articulated in

a single phrase.

1. Sample solutions; in general there are many correct expressions for each query.

a.

b.

c.

d.

e.

f.

g.

h.

i.

Amy, Fay

Amy

Little Caesars, Straw Hat, New York Pizza

Little Caesars, Chicago Pizza, New York Pizza

Amy: mushroom, Dan: mushroom, Gus: mushroom

Amy, Ben, Dan, Eli, Fay, Gus, Hil

Fay

Straw Hat, New York Pizza

2. Query (c) is different. Let R = {(3, 4)} and S = {(1, 2)}. Then query (a) and (b)

produce an empty result while (c) produces {(3, 2)}.

3. a. Minimum = max(r, s) (if one relation is a subset of the other)

Maximum = r + s (if the relations are disjoint)

b. Minimum = 0 (if there are no shared B values)

Maximum = r x s (if all of the B values are the same)

c. Minimum = 0 (if there are no shared B values)

Maximum = min(r, s)

(if one relation's B values are a subset of the other's, and all B values are

distinct)

d. (equivalent to R)

Minimum = r, Maximum = r

e. Minimum = 0 (if A = B in all tuples of R)

Maximum = r (if A <> B in all tuples of R)

4.

5. Names of regions with the highest high temperature and/or lowest low temperature

- T8 B17 FAA Trips 1 of 3 Fdr- FAA Document IndexUploaded by9/11 Document Archive
- REA diagramUploaded byMikhail B Israfel
- Itech 2004 Data Modelling Assignment 1Uploaded byPrabin Bhusal
- File Processing System and Its DisadvantagesUploaded byKamalakar Sreevatasala
- NC New River Inlet 20130513 TM Geo (1)Uploaded byLin
- Raster DataUploaded byRolando Tomy Salas Lopez
- solutions manual fundamentals.pdfUploaded byHadia Nadeem
- 3.Relational ModelUploaded byrar234886
- Chapter_2Uploaded byZainora Kamal Ludin
- 15 SlideUploaded byArpit Gupta
- Ppt SecurityUploaded byxxx
- Table Expressions.docxUploaded byshiv naren
- Adaptive Object-Modeling: Patterns, Tools and ApplicationsUploaded byHugo Sereno Ferreira
- Dbms NotesUploaded byBalkrishna
- DATABASE NORMALIZATION 2Uploaded byVinodKumar
- 06 Database ConceptsUploaded bySimao
- Lecture 15bsUploaded byGulfam Shahzad
- Rajanoopschap5and6.pdfUploaded byRajan Bagale
- Data ProcessingUploaded bykexonlagod
- Week3 - Lec2 - Data Modeling Using ER Model and Its ExtensionsUploaded byzainussami
- UML - Class DiagramUploaded byNiño Francisco Alamo
- AccessingUploaded byRavi Teja
- Sq l TutorialUploaded byTamer Ahmed Salem
- Ch2 Data ModelsUploaded byOlubunmi Alabi
- DBMS Chapter 2 - Data ModelsUploaded byJM Rosaldes
- Introduction to RDBMSUploaded byBalakrishna Allu
- Postgres SQL RefUploaded byV8Lover
- Intro Data ModelingUploaded bySanjiv Verma
- Hidrological modelingUploaded byeddisonfh
- Seminar 8 SolutionUploaded bySamuKereszty

- Application Security Exec Summary AWUploaded bySofia Lively
- Review QuestionsUploaded bySofia Lively
- SADUploaded byynn
- finnnnUploaded bySofia Lively
- Triggers in SQL ServerUploaded byBhargav Labishetty
- paper5Uploaded bySofia Lively
- Funksioni Deterministic vs JodeterministikUploaded bySofia Lively
- 2_StoredProceduresUploaded bySofia Lively
- 2 FunctionsUploaded bySofia Lively
- 1_XQUERY_PRINT.pdfUploaded bySofia Lively
- Xquery TutorialUploaded byjaet4eva
- 1 Katz XqueryUploaded bySofia Lively
- 1_FullTextExamplesUploaded bySofia Lively
- Configuring DBMail With Win Live MailUploaded byVidya Sagar
- ArimaUploaded bySofia Lively
- Relational AlgebraUploaded byAnuragGupta
- umlexsol.pdfUploaded bySofia Lively
- Exercises w2Uploaded bybadsmile
- Homework#1Uploaded bySofia Lively
- Chapter 1Uploaded bySofia Lively
- E Commerce5E Ch01Uploaded byAdrianFraser
- 01 Ec TutorialUploaded bySofia Lively
- Ip Packet Fragmentation TutorialUploaded byAmjath Khan
- fragmentation exampleUploaded bySofia Lively
- Fragmentimi UshtrimeUploaded bySofia Lively
- SCAF Exec SummaryUploaded bySofia Lively
- the-use-of-databases-for-information-storage-and-retrieval-in-selected-banks-in-delta-state-nigeriaUploaded byIJSTR Research Publication
- Database Backup Cloud Service 2577691Uploaded bySofia Lively

- Intrapartum period.docxUploaded byanon_915924422
- VIP ModuleUploaded byJohnny Does
- Degenerative MyopiaUploaded bySekar Ciptaningrum
- Electrifying Fuck With ElectricianUploaded byainspicture
- C730 Lean tools (hi).pdfUploaded byAnthony Quiñonez
- Climate Gate EmailsUploaded byjrod
- IAIDO TermsUploaded byKawadasan
- Price Effects on Consumer Behavior_ a Status Report by Jerry FUploaded byGhulam Mustafa
- BUP EMBA Prospectus 30-Jun-2015Uploaded bytouhedur
- Toxicity of Ocimum Gratissimum Leaf Extract on the Developmental Stages of Different Mosquito Species.Uploaded byresearchanimalsciences
- IP-Ebiz_-_Session_1Uploaded byNitish Garg
- Exercise Stage09Uploaded byGloria García Tudela
- RP-C201Uploaded byAnonymous GVfe64N
- DeVry University FIN 516 Complete CourseUploaded byjustquestionanswer
- Business Advantage Advanced Teachers Book Sample PagesUploaded byRodj Eli Mikael Viernes-Incognito
- January 22, 2017Uploaded bySt. Columba Church
- Workshop ObjectivesUploaded byAlexie Dagaerag Miraflor
- The Trimmed Lamp, and other Stories of the Four Million by Henry, O., 1862-1910Uploaded byGutenberg.org
- Portfolio EssayUploaded bydmporter
- hpeb 553 final presentationUploaded byapi-334815878
- AnaesthesiaUploaded byFlighterdoc
- Fifty initiatives by SHRI KANCHI KAMAKOTI PEETHAMUploaded byR.V Gopalan
- Shaheed Banda Singh Bahadur Ji (2)Uploaded bygunmeet
- Congenital and neonatal pneumonia PAEDIATRIC RESPIRATORY REVIEWS (2007) 8, 195–203 Michael D. NissenUploaded byroggers72
- People vs Cadag G.R. No. L-13830Uploaded byKaren Haley
- sargassumalginate.pdfUploaded byJ L López Martínez
- Psychology Notes – April 19Uploaded by4tygames
- scl 90 validaciónUploaded byJavier Higareda
- Definition of Terms (Magnetism)Uploaded byTeresa Pulga
- Lecture 2Uploaded byBaba Butt

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.