Solution to the Assignment 2



Similar documents
Solution to B561 Assignment 4

Quiz 2: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354

A New PoE Application: Power Backup For Desktop Computers. Steve Robbins

Microsoft SQL Server 2008 R2 Express.

CAMAvision v18.5.x System Specification Guide 7/23/2014

INSIDE. Preventing Data Loss. > Disaster Recovery Types and Categories. > Disaster Recovery Site Types. > Disaster Recovery Procedure Lists

PVTC Technical Requirements

USER PROGRAMMABLE AUTHORIZE USERS AT THE CLICK OF A MOUSE AUDIT TRAIL AND TIME ZONE CONTROL LOCK SYSTEM MANAGEMENT SOFTWARE:

QHR Accuro EMR IT Hardware Requirements

Efficiently Identifying Inclusion Dependencies in RDBMS

Introduction to Databases

Meridian 1 Meridian 1 Attendant PC LAN Interface Installation Guide

Exercise 1: Relational Model

Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification

Module1. x y 800.

8 9 +

COMMUNICATION SERVER 1000 COMMUNICATION SERVER 1000 TELEPHONY MANAGER

Elena Baralis, Silvia Chiusano Politecnico di Torino. Pag. 1. Physical Design. Phases of database design. Physical design: Inputs.

An introduction to Hosted SQL database applications

FedEx Ship Manager Software. Installation Guide

Relational Database: Additional Operations on Relations; SQL

Hard Disk Drive vs. Kingston SSDNow V+ 200 Series 240GB: Comparative Test

11. RESOURCE REQUIREMENT FOR COMPUTER ENGINEERING AND INFORMATION TECHNOLOGY DEPARTMENT

What are Hosted Desktops?

SMALL BUSINESS OUTSOURCING


Dualog Connection Suite Hardware and Software Requirements

types, but key declarations and constraints Similar CREATE X commands for other schema ëdrop X name" deletes the created element of beer VARCHARè20è,

Microsoft Office Outlook 2013: Part 1

How do I Check if My Computer is Compatible with Windows 7

Query Processing in Data Integration Systems

HARDWARE AND SOFTWARE REQUIREMENTS

MN POS TM. Hardware & Peripherals. All required hardware may be purchased from Home Office.

Hardware & Software Requirements for BID2WIN Estimating & Bidding, the BUILD2WIN Product Suite, and BID2WIN Management Reporting

Great IT for small businesses

Computer, Phone, and Network Guidelines at Lipscomb University. Mike Green, VP and CIO Lipscomb University

Juris Installation & Upgrade Guide. Version 2.6.1

The computer's internal components

Distributed Databases. Concepts. Why distributed databases? Distributed Databases Basic Concepts

Detecting false users in Online Rating system & Securing Reputation

Product Data Sheet.

Hardware and system requirements ADULO GS

Answers to Your Frequently Asked Questions About the Microsoft Office365 Program for Pasadena City College Faculty and Staff

CBE system requirements

Servant Keeper Frequently Asked Questions

Network Activation Key Installation Guide. Unilab COILS 7.x. Network Activation Key Installation Guide

Major upgrade versions. To see which features each version of Windows 7 has, go to Microsoft's Compare Windows page.

Grant Management. System Requirements

Comp 5311 Database Management Systems. 3. Structured Query Language 1

Software Installation and Quick Start Guide. EnergyMax -USB/RS Sensor System

Be sure to connect the USB cable from TonePort into your computer s USB port, and then proceed with the following steps

SUPPLY CHAIN ELECTRONIC COMMERCE PARTNER GUIDE

System Requirements for Microsoft Dynamics GP 2013

Chapter 5: Overview of Query Processing

Chapter 2 Data Storage

Using Virtual PC 7.0 for Mac with GalleryPro

Answer Key. UNIVERSITY OF CALIFORNIA College of Engineering Department of EECS, Computer Science Division

MapReduce and the New Software Stack


COMP 5138 Relational Database Management Systems. Week 5 : Basic SQL. Today s Agenda. Overview. Basic SQL Queries. Joins Queries

How To Set Up Safetica Insight 9 (Safetica) For A Safetrica Management Service (Sms) For An Ipad Or Ipad (Smb) (Sbc) (For A Safetaica) (

7. Show that the expectation value function that appears in Lecture 1, namely

Answers to Review Questions

Notebook Computer Framework (School Notebook) Pricing and Overview March 2012

Cisco Unified CallConnector for Microsoft Windows

Local Area Networks: Software

Click to Continue 9/3/2013

WAMLocal. Wireless Asset Monitoring - Local Food Safety Software. Software Installation and User Guide BA/WAM-L-F

Chapter 23. Database Security. Security Issues. Database Security

PROTECTION SERVICE FOR BUSINESS WELCOME TO THE BUSINESS OF FREEDOM

Lexia Network Installation Instructions

Abila Grant Management. System Requirements

Table of Contents. 2 Getting Started Guide

Rolltalk Designer 7.0

Upgrading to Windows 8.1 A Guide for Windows 7 Users Version 1.2

Desktop PC Buying Guide

INSTALLATION AND UPGRADE

Oracle to SQL Server 2005 Migration

Before deploying SiteAudit it is recommended to review the information below. This will ensure efficient installation and operation of SiteAudit.

Technology Partners. Acceleratio Ltd. is a software development company based in Zagreb, Croatia, founded in 2009.

NATIONAL HOME MORTGAGE FINANCE CORPORATION TERMS OF REFERENCE PURCHASE OF IT EQUIPMENT PROJECT

Embedded Software development Process and Tools: Lesson-3 Host and Target Machines

MedInformatix System Requirements

Updated: May Copyright DBA Software Inc. All rights reserved. 2 Getting Started Guide

Programmes offered by School of Computer Science

The Education Edge / The Financial Edge 7.85

Using MS Excel V Lookups

Nu-kote 's Spreadsheet Linear-Programming Models for Optimizing Transportation Nu-kote International manufactures ink-jet, laser, and toner

Foundations of Information Management

An overview of the project tasks that we manage can be seen on the task sheet shown on pages 2 and 3 of this document.

Adonis Technical Requirements

Transcription:

Solution to the Assignment 2 Dirk Van Gucht & Mo Zhou September 29, 2008 Relational Algebra - We write r(abc) for a relational schema with relation name r and attributes (or fields) A, B, and C. The underlined attribute is the primary key. Basic Algebra 1. Given following relational schema, write expressions of relational algebra to answer the following queries. Relational schema of question 1. Product(model, maker, type) PC(model, speed, ram, hd, price) Laptop(model, speed, ram, hd, screen, price) Printer(model, color, type, price) 1

The sample data for relations of question 1. These data are not used to calculate results of following questions. Product: model maker type 1001 A PC 3001 B Printer 2001 C laptop PC: model speed ram hd price 1001 2.66 1024 250 2114 1002 1.42 512 250 955 1003 3.20 2048 160 1049 Laptop: model speed ram hd screen price 2001 2.00 1024 250 15 2114 2002 1.73 512 80 24 955 2003 1.83 2048 60 20 1049 Printer: model color type price 3001 true ink-jet 99 3002 false laser 239 3003 true laser 899 2

(a) What PC models have a speed of at least 3.00? π model (σ model 3.00 (P C)) (b) Find the model numbers of all color laser printers. π model (σ type=laser color=true (P rinter)) (c) Which manufacturers make laptops with a hard disk of at least 100GB? π maker (P roduct σ hd 100 (Laptop)) (d) Find the model number and price of all products (of any type) made by manufacturer B. π model,price (σ maker=b (P roduct)) (π model,price (P C) π model,price (Laptop) π model,price (P rinter)) (e) Find those manufacturers that sell Laptops, but not PC s. π maker (σ type=laptop (P roduct)) π maker (σ type=p C (P roduct)) (f) Find those manufacturers that sell all models of PCs and lazer Printers. π maker (P roduct/(π model (P C) π model (σ type=lazer (P rinter)))) (g) Find those manufacturers whose laptops have all ram sizes that manufacturer B s laptops have. (π maker,ram (P roduct Laptop)) / (π ram (σ maker=b (P roduct) Laptop)) (h) Find those manufacturers of at least two different computers (PC s or laptops) with speeds of at least 2.80. ρ(t EMP 1, π model (σ speed 2.80 (P C)) π model (σ speed 2.80 (Laptop))) ρ(t EMP 2, P roduct T EMP 1) π maker (σ T EMP 2.maker=T EMP 3.maker T EMP 2.model T EMP 3.model (T EMP 2 ρ(t EMP 3, T EMP 2))) (i) Find the manufacturers of PC s with at least two different speeds. π R1.maker (σ R1.speed R2.speed R1.maker=R2.maker ((ρ(r1, (P roduct P C)) ρ(r2, (P roduct P C))))) (j) Find the manufacturers who sell exactly two different models of PC. π R1.maker (σ R1.model R2.model R1.maker=R2.maker (ρ(r1, (P roduct P C)) ρ(r2, (P roduct P C)))) π R1.maker (σ R1.model R2.model R1.model R3.model R2.model R3.model R1.maker=R2.maker R1.maker=R3.maker 3

(ρ(r1, (P roduct P C)) ρ(r2, (P roduct P C)) ρ(r3, (P roduct P C)))) (k) Find those pairs of PC models that have both the same speed and RAM. A pair should be listed only once; e.g., list (i, j) but not (j, i). Hint: The model numbers can be compared. π P C1.model,P C2.model (σ P C1.speed=P C2.speed P C1.ram=P C2.ram P C1.model>P C2.model (ρ(p C1, P C) ρ(p C2, P C))) (l) Find the manufacturer(s) of the computer (PC or laptop) with the highest available speed. Hint: the highest speed means that it is not smaller than any other speeds. If you can find all the speeds which are smaller than some speed, you can solve this problem. ρ(computer, (π model,speed (P C) π model,speed (Laptop))) ρ(highestspeedmodel, π model (Computer) π model (σ P 1.speed<P 2.speed (ρ(p 1, Computer) ρ(p 2, Computer)))) π maker (P roduct HighestSpeedModel) 4

Constraints 2. Express the following constraints about the relations below. Product(model,maker, type) PC(model, speed, ram, hd, price) Laptop(model, speed, ram, hd, screen, price) Printer(model, color, type, price) (a) A PC with a processor speed less than 2.00 must not sell for more than $500. σ speed<2.00 price>500 (P C) = (b) No manufacturer of PC s may also make laptops. π maker (P roduct P C) π maker (P roduct Laptop) = OR π maker (σ type=p C (P roduct)) π maker (σ type=laptop (P roduct)) = (c) A manufacturer of a PC must also make a laptop with at least as great a processor speed. Find the highest speed of PC for each manufacturer. ρ(t emp, π maker,speed (P roduct P C)) ρ(t emp2, T emp π T 1.maker,T 1.speed (σ T 1.speed<T 2.speed T 1.maker=T 2.maker (ρ(t 1, T emp) ρ(t 2, T emp)))) Find the highest speed of Laptop for each manufacturer ρ(t emp3, π maker,speed (P roduct Laptop)) ρ(t emp4, T emp3 π T 3.maker,T 3.speed (σ T 3.speed<T 4.speed T 3.maker=T 4.maker (ρ(t 3, T emp) ρ(t 4, T emp)))) For the same manufacturer, the highest speed of the laptop must as great as the one of the PC. σ T emp2.maker=t emp4.maker T emp2.speed T emp4.speed (T emp2 T emp4) = 5

3. Express the following constraints in relational algebra. The constraints are based on the following relations. Classes(class, type, country, numguns, bore, displacement) Ships(shipname, class, launched) Battles(battlename, date) Outcomes(shipname, battlename, result) (a) No country may have both battleships and battlecruisers.(battleship and battlecruiser are values of attribute type in relation Classes) π contry (σ type=battlecruiser (Classes)) π contry (σ type=battleship (Classes)) = (b) No ship with more than 9 guns may be in a battle with a ship having fewer than 9 guns that was sunk. (sunk is a value of attribute result in relation Outcomes) π battlename ((σ numguns>9 (Classes) Ships) Battles) π battlename ((σ numguns<9 (Classes) Ships) (σ result=sunk (Battles))) = 6

Special algebra 4. Suppose relations R and S have n tuples and m tuples, respectively. Give the minimum and the maximum numbers of tuples that the results of the following expressions can have. (a) R S (b) R S (c) σ C (R) S, for some condition C. (d) π L (R) S, for some list of attributes L. Expression Max Min R S n+m max(m,n) R S min(m,n) 0 σ C (R) S m n 0 π L (R) S n 0 5. The semijoin of relations R and S is the set of tuples t in R such that there is at least one tuple in S that agrees with t in all attributes that R and S have in common. Give three different expressions of relational algebra equivalent to semijoin. Suppose that R has n domains and S has m domains. And the first k domains are the same for both R and S. (a) π 1,...,n (R S) (b) π 1,...,n (σ R.1=S.1... R.k=S.k (R S)) (c) R π 1,...,k (S) 6. The antisemijoin is the set of tuples t in R that do not agree with any tuple of S in the attributes common to R and S. Give an expression of relational equivalent to antisemijoin. R π 1,...,n (R S) 7. An operator on relations is said to be monotone if whenever we add a tuple to one of its arguments, the result contains all the tuples that it contained before adding the tuple, plus perhaps more tuples. Are semijoin and antisemijoin monotone? For each, either explain why it is monotone or give an example showing it is not. 7

Solution: Semijoin is monotone. Antisemijoin is not monotone. 8