# Homework 1: Relational Algebra and SQL (due February 10 th, 2016, 4:00pm, in class hard-copy please)

Save this PDF as:

Size: px
Start display at page:

Download "Homework 1: Relational Algebra and SQL (due February 10 th, 2016, 4:00pm, in class hard-copy please)"

## Transcription

1 Virginia Tech. Computer Science CS 4604 Introduction to DBMS Spring 2016, Prakash Homework 1: Relational Algebra and SQL (due February 10 th, 2016, 4:00pm, in class hard-copy please) Reminders: a. Out of 100 points. Contains 6 pages. b. Rough time-estimates: 3~6 hours. c. Each HW is supposed to be done individually. d. Please type your answers. Illegible handwriting may get no points, at the discretion of the grader. Only drawings may be hand-drawn, as long as they are neat and legible. e. There could be more than one correct answer. We shall accept them all. f. Whenever you are making an assumption, please state it clearly. g. Unless otherwise mentioned, you may use any SQL/RA operator seen in class/in textbook. h. Unless otherwise specified, assume set-semantics for RA and bag-semantics for SQL. i. Feel free to use the linear notation for RA and create intermediate views for SQL. j. Lead TA for this HW: Sorour Amiri. Q1. RA: Warming up [12 points] Consider the following three tables, T1, T2 and T3: T1 A B C D 10 a b a 6 0 T2 E B 1 b 5 c 6 b T3 A N 10 b 25 c 10 b Show the results of the following relational algebra queries (3 points each): Q1.1. Q1.2. Q1.3. Q1.4. σ!!! (T1) σ!!!!!! (T2) σ!!! (T1 T2 T3) T1 T1.C=T2.E T2 Q2. RA: Monotone Operators [15 points] 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, 1

2 plus perhaps more tuples. Which of the 5 fundamental RA operators we saw in class (see Lecture 2) are monotone? For each either explain why it is monotone, or give a small example showing it is not. Q3. RA: Products and Manufacturers [22 points] Consider the following relational database that stores information about computer hardware products (keys are underlined, field types are omitted): Product (maker, model, type) PC (model, speed, ram, hd, price) Laptop (model, speed, ram, hd, screen, price) Printer (model, color, type, price) The Product relation gives the manufacturer, model number and type (PC/laptop/printer) of various products. The PC relation gives for each model number that is a PC the speed (of the processor, in gigahertz), the amount of RAM (in GB), the size of hard disk (in GB), and the price. The Laptop relation is similar, with screen size included. The Printer relation records whether it is a color printer or not (Yes/No), and the type (laser/ink-jet) and the price. Write the following queries in relational algebra: Q3.1. Q3.2. Q3.3. Q3.4. Q3.5. (2 points) Find the model numbers of all color laser printers. (3 points) Find the model number and price of all products (of any type) made by manufacturer HP. (5 points) Find those manufacturers of at least two different computers (PCs or laptops) with speeds of at least Hint: You may need a self Cartesian product and a join. (6 points) Find the manufacturers who sell exactly three different models of PC. Hint: Similar in spirit to Q3.3, but you may have to use the set difference as well. (6 points) Find the manufacturers who sell PCs with at least all the RAM sizes seen in laptops. Q4. SQL: The Restaurant DB [21 points] The following relational database schema stores information about a restaurant. The primary keys are underlined and field types are omitted. Study the schema and its corresponding description to answer the questions. 2

3 Customer (cid, cname, cage, caddress, cphone) Table(tno, capacity, availability) Item(iid, iname, price) Order( oid, cid, iid, tno, quantity) Employee(eid, ename, eaddress, eage, salary) Reservation(rid, eid, cid, date, time) The customer is someone who eats in the restaurant. The Customer relation provides customer id, the name, age, address and phone number information. The Table relation gives the restaurant s occupancy information that includes the table number, the number of people who can sit on the table, and the table s availability information. The restaurant serves several items. Each of the Items has an identification number (e.g., 82285), name (e.g., salad), and unit price (e.g., \$15). Soon after arrival in the restaurant a customer places an order. Order relation contains order id, customer id, ordered items id, each item s quantity. Each order contains one or more items, and the quantity of each item (e.g., order 10 contains one soup and two salads). Here we are assuming that a customer can visit the restaurant at most once in a day and can t place multiple orders at a time. Restaurant employees serve customers. The Employee relation contains employee id, name, address, age, and salary information. The customer can make a reservation in the restaurant beforehand. The Reservation relation records reservation, employee, and customer ids, and reservation date and time. In this assignment, you will only deal with querying part of SQL. You are NOT allowed to tamper with (change the contents of) the database, i.e., CREATE, INSERT, DELETE, ALTER, UPDATE etc. Write SQL queries that answer the questions below (one query per question). The query answers must not contain duplicates, but you should use the SQL keyword distinct only when necessary. For this question, creation of temporary tables is NOT allowed, i.e., for each question you have to write exactly one SQL statement (possible using nested SQL). Q4.1. (3 points) Find the customer names that ordered Steak. Q4.2. (3 points) Find the name of the employee who made the reservation for both customers James Schlitt and Nicole Diamond. Q4.3. (4 points) Find the name of the highest paid employee(s) whose age is more than 30. Q4.4. (5 points) How many customers ordered more than three items? Q4.5. (6 points) Find those table numbers where people ordered more than \$30 worth of food. 3

4 Q5. SQLite: Storing Employee Information [30 points] This question is on a consumer complaint database that stores information about the complaints government has received about financial products and services. Download and install SQLite3 from Feel free to use SQLite3 for testing and practicing SQL queries in general. Warm-up Follow the documentation and load the small sample database at: It has a table complaints which includes Complaint ID (Primary Key), Date received, Product, Issue, Consumer complaint narrative, Company public response, Company, State, ZIP code, Date sent to company, Company response to consumer, Timely response? (Yes-No), Consumer disputed? (Yes-No). As a sanity check that you have the correct database, running the following command at a Unix/Linux/Cygwin prompt: your-machine% sqlite3 cs4604-hw1.db select count(*) from complaints; should return 50 We want to write SQL queries to do the following: Query1: Return distinct Issues about Credit Karma Inc. company. Hint: you have to look at the Company column. Query2: Count the number of Products in the database. Larger CSV file A bigger raw comma separated value (csv) file is given here: It is a subset from consumer complaint dataset (if you are curious, the official dataset is at We want to write queries to do the following: Query3: List companies which have at least one product in common with Equifax company. Query4: Return all states and total number of complaints reported from them. 4

6 your-machine% wc -l complaints.csv should return 2081 complaints.csv 6

### Homework 6: FDs, NFs and XML (due April 13 th, 2016, 4:00pm, hard-copy in-class please)

Virginia Tech. Computer Science CS 4604 Introduction to DBMS Spring 2016, Prakash Homework 6: FDs, NFs and XML (due April 13 th, 2016, 4:00pm, hard-copy in-class please) Reminders: a. Out of 100 points.

### Homework 6: FDs, NFs and XML (due April 15 th, 2015, 4:00pm, hard-copy in-class please)

Virginia Tech. Computer Science CS 4604 Introduction to DBMS Spring 2015, Prakash Homework 6: FDs, NFs and XML (due April 15 th, 2015, 4:00pm, hard-copy in-class please) Reminders: a. Out of 100 points.

### Homework 2: Query Processing/Optimization, Transactions/Recovery (due February 16th, 2017, 9:30am, in class hard-copy please)

Virginia Tech. Computer Science CS 5614 (Big) Data Management Systems Spring 2017, Prakash Homework 2: Query Processing/Optimization, Transactions/Recovery (due February 16th, 2017, 9:30am, in class hard-copy

### Homework 7: Transactions, Logging and Recovery (due April 22nd, 2015, 4:00pm, in class hard-copy please)

Virginia Tech. Computer Science CS 4604 Introduction to DBMS Spring 2015, Prakash Homework 7: Transactions, Logging and Recovery (due April 22nd, 2015, 4:00pm, in class hard-copy please) Reminders: a.

### Database Systems CSE 303. Outline. Lecture 06: SQL. What is Sub-query? Sub-query in WHERE clause Subquery

Database Systems CSE 303 Lecture 06: SQL 2016 Subquery Outline What is a Subquery Subquery in WHERE clause >ALL, >ANY, >=ALL,

### Assignment #2. CS Spring 2015 Due on Friday, June 19, 2015, 9 AM For instructions on how to submit your assignment check the course website.

Assignment #2 CS 348 - Spring 2015 Due on Friday, June 19, 2015, 9 AM For instructions on how to submit your assignment check the course website. 1 CS 348 - Spring 2015 : Assignment #2 QUESTION 1. Question

### Announcements. Relational Model & Algebra. Example. Relational data model. Example. Schema versus instance. Lecture notes

Announcements Relational Model & Algebra CPS 216 Advanced Database Systems Lecture notes Notes version (incomplete) available in the morning on the day of lecture Slides version (complete) available after

### 1 (10) 2 (8) 3 (12) 4 (14) 5 (6) Total (50)

Student number: Signature: UNIVERSITY OF VICTORIA Faculty of Engineering Department of Computer Science CSC 370 (Database Systems) Instructor: Daniel M. German Midterm Oct 21, 2004 Duration: 60 minutes

### Example Examination. Allocated Time: 100 minutes Maximum Points: 250

CS542 EXAMPLE EXAM Elke A. Rundensteiner Example Examination Allocated Time: 100 minutes Maximum Points: 250 STUDENT NAME: General Instructions: This test is a closed book exam (besides one cheat sheet).

### MASSACHUSETTS INSTITUTE OF TECHNOLOGY Database Systems: Fall 2015 Quiz I

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.830 Database Systems: Fall 2015 Quiz I There are 12 questions and 13 pages in this quiz booklet. To receive

### Basic operators: selection, projection, cross product, union, difference,

CS145 Lecture Notes #6 Relational Algebra Steps in Building and Using a Database 1. Design schema 2. Create schema in DBMS 3. Load initial data 4. Repeat: execute queries and updates on the database Database

### Database Management Systems Paper Solution

Database Management Systems Paper Solution Following questions have been asked in GATE CS exam. 1. Given the relations employee (name, salary, deptno) and department (deptno, deptname, address) Which of

### 3. Relational Data Model 3.5 The Tuple Relational Calculus

3. Relational Data Model 3.5 The Tuple Relational Calculus forall quantification Syntax: t R(P(t)) semantics: for all tuples t in relation R, P(t) has to be fulfilled example query: Determine all students

### CSE 344 Final Examination

CSE 344 Final Examination December 12, 2012, 8:30am - 10:20am Name: Question Points Score 1 30 2 20 3 30 4 20 Total: 100 This exam is open book and open notes but NO laptops or other portable devices.

### CSC 261/461 Database Systems Lecture 5. Fall 2017

CSC 261/461 Database Systems Lecture 5 Fall 2017 MULTISET OPERATIONS IN SQL 2 UNION SELECT R.A FROM R, S WHERE R.A=S.A UNION SELECT R.A FROM R, T WHERE R.A=T.A Q 1 Q 2 r. A r. A = s. A r. A r. A = t. A}

### The data structures of the relational model Attributes and domains Relation schemas and database schemas

The data structures of the relational model Attributes and domains Relation schemas and database schemas databases First normal form (1NF) Running Example Pubs-Drinkers-DB: Pubs (name, location) Drinkers

### Exam 1. March 20th, CS525 - Midterm Exam Solutions

Name CWID Exam 1 March 20th, 2017 CS525 - Midterm Exam s Please leave this empty! 1 2 3 4 Sum Things that you are not allowed to use Personal notes Textbook Printed lecture notes Phone The exam is 75 minutes

### Chapter 18 Strategies for Query Processing. We focus this discussion w.r.t RDBMS, however, they are applicable to OODBS.

Chapter 18 Strategies for Query Processing We focus this discussion w.r.t RDBMS, however, they are applicable to OODBS. 1 1. Translating SQL Queries into Relational Algebra and Other Operators - SQL is

### CS348: INTRODUCTION TO DATABASE MANAGEMENT (Winter, 2011) FINAL EXAMINATION

CS348: INTRODUCTION TO DATABASE MANAGEMENT (Winter, 2011) FINAL EXAMINATION INSTRUCTOR: Grant Weddell TIME: 150 minutes WRITE YOUR NAME AND ID HERE: NOTE 1: This is a closed book examination. For example,

### Data Modeling with the Entity Relationship Model. CS157A Chris Pollett Sept. 7, 2005.

Data Modeling with the Entity Relationship Model CS157A Chris Pollett Sept. 7, 2005. Outline Conceptual Data Models and Database Design An Example Application Entity Types, Sets, Attributes and Keys Relationship

### MIT Database Management Systems Lesson 01: Introduction

MIT 22033 Database Management Systems Lesson 01: Introduction By S. Sabraz Nawaz Senior Lecturer in MIT, FMC, SEUSL Learning Outcomes At the end of the module the student will be able to: Describe the

### In-class activities: Sep 25, 2017

In-class activities: Sep 25, 2017 Activities and group work this week function the same way as our previous activity. We recommend that you continue working with the same 3-person group. We suggest that

### Lecture 16. The Relational Model

Lecture 16 The Relational Model Lecture 16 Today s Lecture 1. The Relational Model & Relational Algebra 2. Relational Algebra Pt. II [Optional: may skip] 2 Lecture 16 > Section 1 1. The Relational Model

### SQL: Data Manipulation Language. csc343, Introduction to Databases Diane Horton Winter 2017

SQL: Data Manipulation Language csc343, Introduction to Databases Diane Horton Winter 2017 Introduction So far, we have defined database schemas and queries mathematically. SQL is a formal language for

### Relational Query Optimization. Highlights of System R Optimizer

Relational Query Optimization Chapter 15 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Highlights of System R Optimizer v Impact: Most widely used currently; works well for < 10 joins.

### NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E)

1 NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E) 2 LECTURE OUTLINE More Complex SQL Retrieval Queries Self-Joins Renaming Attributes and Results Grouping, Aggregation, and Group Filtering

### Database Design and Tuning

Database Design and Tuning Chapter 20 Comp 521 Files and Databases Spring 2010 1 Overview After ER design, schema refinement, and the definition of views, we have the conceptual and external schemas for

### Hash-Based Indexing 165

Hash-Based Indexing 165 h 1 h 0 h 1 h 0 Next = 0 000 00 64 32 8 16 000 00 64 32 8 16 A 001 01 9 25 41 73 001 01 9 25 41 73 B 010 10 10 18 34 66 010 10 10 18 34 66 C Next = 3 011 11 11 19 D 011 11 11 19

### Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Lecture 2 Lecture Overview 1. SQL introduction & schema definitions 2. Basic single-table queries

### Unit 4 Relational Algebra (Using SQL DML Syntax): Data Manipulation Language For Relations Zvi M. Kedem 1

Unit 4 Relational Algebra (Using SQL DML Syntax): Data Manipulation Language For Relations 2014 Zvi M. Kedem 1 Relational Algebra And SQL SQL is based on relational algebra with many extensions Some necessary

### Chapter 6 Part I The Relational Algebra and Calculus

Chapter 6 Part I The Relational Algebra and Calculus Copyright 2004 Ramez Elmasri and Shamkant Navathe Database State for COMPANY All examples discussed below refer to the COMPANY database shown here.

### Midterm 1: CS186, Spring 2015

Midterm 1: CS186, Spring 2015 Prof. J. Hellerstein You should receive a double-sided answer sheet and a 7-page exam. Mark your name and login on both sides of the answer sheet, and in the blanks above.

### Lecture Query evaluation. Combining operators. Logical query optimization. By Marina Barsky Winter 2016, University of Toronto

Lecture 02.03. Query evaluation Combining operators. Logical query optimization By Marina Barsky Winter 2016, University of Toronto Quick recap: Relational Algebra Operators Core operators: Selection σ

### Database Systems External Sorting and Query Optimization. A.R. Hurson 323 CS Building

External Sorting and Query Optimization A.R. Hurson 323 CS Building External sorting When data to be sorted cannot fit into available main memory, external sorting algorithm must be applied. Naturally,

### The Relational Model Constraints and SQL DDL

The Relational Model Constraints and SQL DDL Week 2-3 Weeks 2-3 MIE253-Consens 1 Schedule Week Date Lecture Topic 1 Jan 9 Introduction to Data Management 2 Jan 16 The Relational Model 3 Jan. 23 Constraints

### NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E)

1 NESTED QUERIES AND AGGREGATION CHAPTER 5 (6/E) CHAPTER 8 (5/E) 2 LECTURE OUTLINE More Complex SQL Retrieval Queries Self-Joins Renaming Attributes and Results Grouping, Aggregation, and Group Filtering

### Midterm Exam. Name: CSE232A, Winter February 21, Brief Directions:

Midterm Exam CSE232A, Winter 2002 February 21, 2002 Name: Brief Directions: ² Write clearly: First, you don't want me to spend the whole week grading, do you? Second, it's good for you to write clearly!

### Introduction to Data Management. Lecture #4 (E-R Relational Translation)

Introduction to Data Management Lecture #4 (E-R Relational Translation) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v Today

### SQL: csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Sina Meraji. Winter 2018

SQL: csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Sina Meraji Winter 2018 Introduction So far, we have defined database schemas and queries mathematically. SQL is a

### Administrivia. Physical Database Design. Review: Optimization Strategies. Review: Query Optimization. Review: Database Design

Administrivia Physical Database Design R&G Chapter 16 Lecture 26 Homework 5 available Due Monday, December 8 Assignment has more details since first release Large data files now available No class Thursday,

### CS 4320/5320 Homework 2

CS 4320/5320 Homework 2 Fall 2017 Due on Friday, 20th of October 2017 at 11:59 pm This assignment is out of 75 points and accounts for 10% of your overall grade. All answers for this homework should be

### What s a database system? Review of Basic Database Concepts. Entity-relationship (E/R) diagram. Two important questions. Physical data independence

What s a database system? Review of Basic Database Concepts CPS 296.1 Topics in Database Systems According to Oxford Dictionary Database: an organized body of related information Database system, DataBase

### UNIT- II (Relational Data Model & Introduction to SQL)

Database Management System 1 (NCS-502) UNIT- II (Relational Data Model & Introduction to SQL) 2.1 INTRODUCTION: 2.1.1 Database Concept: 2.1.2 Database Schema 2.2 INTEGRITY CONSTRAINTS: 2.2.1 Domain Integrity:

### The Relational Model

The Relational Model What is the Relational Model Relations Domain Constraints SQL Integrity Constraints Translating an ER diagram to the Relational Model and SQL Views A relational database consists

### Chapter 19 Query Optimization

Chapter 19 Query Optimization It is an activity conducted by the query optimizer to select the best available strategy for executing the query. 1. Query Trees and Heuristics for Query Optimization - Apply

### Query Processing & Optimization. CS 377: Database Systems

Query Processing & Optimization CS 377: Database Systems Recap: File Organization & Indexing Physical level support for data retrieval File organization: ordered or sequential file to find items using

### Midterm Exam (Version B) CS 122A Spring 2017

NAME: SOLUTION SEAT NO.: STUDENT ID: Midterm Exam (Version B) CS 122A Spring 2017 Max. Points: 100 (Please read the instructions carefully) Instructions: - The total time for the exam is 80 minutes; be

### The Relational Model. Chapter 3. Comp 521 Files and Databases Fall

The Relational Model Chapter 3 Comp 521 Files and Databases Fall 2012 1 Why Study the Relational Model? Most widely used model by industry. IBM, Informix, Microsoft, Oracle, Sybase, etc. It is simple,

### What happens. 376a. Database Design. Execution strategy. Query conversion. Next. Two types of techniques

376a. Database Design Dept. of Computer Science Vassar College http://www.cs.vassar.edu/~cs376 Class 16 Query optimization What happens Database is given a query Query is scanned - scanner creates a list

### Database Management Systems

Sample Questions 1 Write SQL query to create a table for describing a book. The table should have Book Title, Author, Publisher, Year published, and ISBN fields. Your table should have a primary key. For

### Introduction to SQL Part 2 by Michael Hahsler Based on slides for CS145 Introduction to Databases (Stanford)

Introduction to SQL Part 2 by Michael Hahsler Based on slides for CS145 Introduction to Databases (Stanford) Lecture 3 Lecture Overview 1. Aggregation & GROUP BY 2. Set operators & nested queries 3. Advanced

### Informatics 1: Data & Analysis

Informatics 1: Data & Analysis Lecture 7: SQL Ian Stark School of Informatics The University of Edinburgh Tuesday 7 February 2017 Semester 2 Week 4 https://blog.inf.ed.ac.uk/da17 Homework from Friday 1.

### Introduction to Database Systems CSE 444

Introduction to Database Systems CSE 444 Lecture 2: SQL Announcements Project 1 & Hw 1 are posted on class website Project 1 (SQL) due in two weeks Homework 1 (E/R models etc) due in three weeks Remember:

### Midterm 2: CS186, Spring 2015

Midterm 2: CS186, Spring 2015 Prof. J. Hellerstein You should receive a double-sided answer sheet and an 8-page exam. Mark your name and login on both sides of the answer sheet, and in the blanks above.

### CSC 742 Database Management Systems

CSC 742 Database Management Systems Topic #16: Query Optimization Spring 2002 CSC 742: DBMS by Dr. Peng Ning 1 Agenda Typical steps of query processing Two main techniques for query optimization Heuristics

### PES Institute of Technology Bangalore South Campus (1 K.M before Electronic City,Bangalore ) Department of MCA. Solution Set - Test-II

PES Institute of Technology Bangalore South Campus (1 K.M before Electronic City,Bangalore 560100 ) Solution Set - Test-II Sub: Database Management Systems 16MCA23 Date: 04/04/2017 Sem & Section:II Duration:

### COMP Instructor: Dimitris Papadias WWW page:

COMP 5311 Instructor: Dimitris Papadias WWW page: http://www.cse.ust.hk/~dimitris/5311/5311.html Textbook Database System Concepts, A. Silberschatz, H. Korth, and S. Sudarshan. Reference Database Management

### Databases - 4. Other relational operations and DDL. How to write RA expressions for dummies

Databases - 4 Other relational operations and DDL How to write RA expressions for dummies Step 1: Identify the relations required and CP them together Step 2: Add required selections to make the CP Step

### Chapter 6 The database Language SQL as a tutorial

Chapter 6 The database Language SQL as a tutorial About SQL SQL is a standard database language, adopted by many commercial systems. ANSI SQL, SQL-92 or SQL2, SQL99 or SQL3 extends SQL2 with objectrelational

### Data Structure: Relational Model

Applications View of a Relational Database Management (RDBMS) System Why applications use DBs? Persistent data structure Independent from processes using the data Also, large volume of data High-level

### Relational Model. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

Relational Model DCS COMSATS Institute of Information Technology Rab Nawaz Jadoon Assistant Professor COMSATS IIT, Abbottabad Pakistan Management Information Systems (MIS) Relational Model Relational Data

### Review. The Relational Model. Glossary. Review. Data Models. Why Study the Relational Model? Why use a DBMS? OS provides RAM and disk

Review The Relational Model CS 186, Fall 2006, Lecture 2 R & G, Chap. 3 Why use a DBMS? OS provides RAM and disk Review Why use a DBMS? OS provides RAM and disk Concurrency Recovery Abstraction, Data Independence

### Keys, SQL, and Views CMPSCI 645

Keys, SQL, and Views CMPSCI 645 SQL Overview SQL Preliminaries Integrity constraints Query capabilities SELECT-FROM- WHERE blocks, Basic features, ordering, duplicates Set ops (union, intersect, except)

### Relational Algebra 1

Relational Algebra 1 Motivation The relational data model provides a means of defining the database structure and constraints NAME SALARY ADDRESS DEPT Smith 50k St. Lucia Printing Dilbert 40k Taringa Printing

### SQL. A Short Note. November 14, where the part appears between [ and ] are optional. A (simple) description of components are given below:

SQL A Short Note November 14, 2002 1 Syntax SQL Queries have the generic form as follows: SELECT [DISTINCT] List_of_attributes FROM List_of_tables [ WHERE Condition] [ ORDER BY List_Of_Ordering_Attributes

### Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

Entity-Relationship Modelling Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables 1 Entity Sets A enterprise can be modeled as a collection of: entities, and

### Agenda. Database Systems. Session 5 Main Theme. Relational Algebra, Relational Calculus, and SQL. Dr. Jean-Claude Franchitti

Database Systems Session 5 Main Theme Relational Algebra, Relational Calculus, and SQL Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical Sciences

### Lecture 3 SQL - 2. Today s topic. Recap: Lecture 2. Basic SQL Query. Conceptual Evaluation Strategy 9/3/17. Instructor: Sudeepa Roy

CompSci 516 Data Intensive Computing Systems Lecture 3 SQL - 2 Instructor: Sudeepa Roy Announcements HW1 reminder: Due on 09/21 (Thurs), 11:55 pm, no late days Project proposal reminder: Due on 09/20 (Wed),

### Problem Set 2 Solutions

Design and Analysis of Algorithms February, 01 Massachusetts Institute of Technology 6.046J/18.410J Profs. Dana Moshkovitz and Bruce Tidor Handout 8 Problem Set Solutions This problem set is due at 9:00pm

### Chapter 5 Relational Algebra. Nguyen Thi Ai Thao

Chapter 5 Nguyen Thi Ai Thao thaonguyen@cse.hcmut.edu.vn Spring- 2016 Contents 1 Unary Relational Operations 2 Operations from Set Theory 3 Binary Relational Operations 4 Additional Relational Operations

### Chapter 2: Entity-Relationship Model

Chapter 2: Entity-Relationship Model! Entity Sets! Relationship Sets! Design Issues! Mapping Constraints! Keys! E-R Diagram! Extended E-R Features! Design of an E-R Database Schema! Reduction of an E-R

### IMPORTANT: Circle the last two letters of your class account:

Spring 2011 University of California, Berkeley College of Engineering Computer Science Division EECS MIDTERM I CS 186 Introduction to Database Systems Prof. Michael J. Franklin NAME: STUDENT ID: IMPORTANT:

### UML & OO Fundamentals. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 3 09/04/2012

UML & OO Fundamentals CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 3 09/04/2012 1 Goals of the Lecture Review the material in Chapter 2 of the Textbook Cover key parts of the UML notation

### ON MAKING RELATIONAL DIVISION COMPREHENSIBLE

ON MAKING RELATIONAL DIVISION COMPREHENSIBLE Lester I. McCann 1 Session F2C Abstract - Division is the most intellectually challenging of the basic operators of relational algebra. Although its utility

### Database Applications (15-415)

Database Applications (15-415) ER to Relational & Relational Algebra Lecture 4, January 20, 2015 Mohammad Hammoud Today Last Session: The relational model Today s Session: ER to relational Relational algebra

### CS/INFO 330 Entity-Relationship Modeling. Announcements. Goals of This Lecture. Mirek Riedewald

CS/INFO 330 Entity-Relationship Modeling Mirek Riedewald mirek@cs.cornell.edu Announcements Office hour update (see class homepage) First homework assignment will be available from CMS later today Some

### Class Information. Textbooks. Grading. Final Project. Grading. CS 440: Database Management Systems. Instructor:

CS 440: Database Management Systems Class Information Instructor: Eugene Zhang (zhange@eecs.oregonstate.edu) 2 KEC Office hour: MWF 4:00 5:00 Class web site: http://classes.engr.oregonstate.edu/eecs/winter200/cs440/

### Schema for Examples. Query Optimization. Alternative Plans 1 (No Indexes) Motivating Example. Alternative Plans 2 With Indexes

Schema for Examples Query Optimization (sid: integer, : string, rating: integer, age: real) (sid: integer, bid: integer, day: dates, rname: string) Similar to old schema; rname added for variations. :

### Relational Model: History

Relational Model: History Objectives of Relational Model: 1. Promote high degree of data independence 2. Eliminate redundancy, consistency, etc. problems 3. Enable proliferation of non-procedural DML s

### COSC6340: Database Systems Mini-DBMS Project evaluating SQL queries

COSC6340: Database Systems Mini-DBMS Project evaluating SQL queries Instructor: Carlos Ordonez 1 Introduction You will develop a small DBMS in C++ supporting SQL with nested SPJ queries. The small DBMS

### Chapter 12: Query Processing

Chapter 12: Query Processing Overview Catalog Information for Cost Estimation \$ Measures of Query Cost Selection Operation Sorting Join Operation Other Operations Evaluation of Expressions Transformation

### CS317 File and Database Systems

CS317 File and Database Systems Lecture 3 Relational Calculus and Algebra Part-2 September 10, 2017 Sam Siewert RDBMS Fundamental Theory http://dilbert.com/strips/comic/2008-05-07/ Relational Algebra and

### Databases - Relational Algebra. (GF Royle, N Spadaccini ) Databases - Relational Algebra 1 / 24

Databases - Relational Algebra (GF Royle, N Spadaccini 2006-2010) Databases - Relational Algebra 1 / 24 This lecture This lecture covers relational algebra which is the formal language underlying the manipulation

### Midterm I - Solution CS164, Spring 2014

164sp14 Midterm 1 - Solution Midterm I - Solution CS164, Spring 2014 March 3, 2014 Please read all instructions (including these) carefully. This is a closed-book exam. You are allowed a one-page handwritten

### Exam code: Exam name: Database Fundamentals. Version 16.0

98-364 Number: 98-364 Passing Score: 800 Time Limit: 120 min File Version: 16.0 Exam code: 98-364 Exam name: Database Fundamentals Version 16.0 98-364 QUESTION 1 You have a table that contains the following

### Final Examination Computer Science 420 Dr. St. John Lehman College City University of New York 21 May 2002

Final Examination Computer Science 420 Dr. St. John Lehman College City University of New York 21 May 2002 NAME (Printed) NAME (Signed) E-mail Exam Rules Show all your work. Your grade will be based on

### SQL - Data Query language

SQL - Data Query language Eduardo J Ruiz October 20, 2009 1 Basic Structure The simple structure for a SQL query is the following: select a1...an from t1... tr where C Where t 1... t r is a list of relations

### CSE 444, Winter 2011, Final Examination. 17 March 2011

Name: CSE 444, Winter 2011, Final Examination 17 March 2011 Rules: Open books and open notes. No laptops or other mobile devices. Please write clearly and explain your reasoning You have 1 hour 50 minutes;

### CS W Introduction to Databases Spring Computer Science Department Columbia University

CS W4111.001 Introduction to Databases Spring 2018 Computer Science Department Columbia University 1 in SQL 1. Key constraints (PRIMARY KEY and UNIQUE) 2. Referential integrity constraints (FOREIGN KEY

### Name: 1. (a) SQL is an example of a non-procedural query language.

Name: 1 1. (20 marks) erminology: or each of the following statements, state whether it is true or false. If it is false, correct the statement without changing the underlined text. (Note: there might

### CS448 Designing and Implementing a Mini Relational DBMS

CS448 Designing and Implementing a Mini Relational DBMS Credit: 20 points Due Date: Midnight of April 2, 2014 without any penalties. The last day to submit the program is April 9, 2014 with 1 point penalty

### CPSC 421 Database Management Systems. Lecture 19: Physical Database Design Concurrency Control and Recovery

CPSC 421 Database Management Systems Lecture 19: Physical Database Design Concurrency Control and Recovery * Some material adapted from R. Ramakrishnan, L. Delcambre, and B. Ludaescher Agenda Physical

### A Sample Solution to the Midterm Test

CS3600.1 Introduction to Database System Fall 2016 Dr. Zhizhang Shen A Sample Solution to the Midterm Test 1. A couple of W s(10) (a) Why is it the case that, by default, there are no duplicated tuples

### Column Stores vs. Row Stores How Different Are They Really?

Column Stores vs. Row Stores How Different Are They Really? Daniel J. Abadi (Yale) Samuel R. Madden (MIT) Nabil Hachem (AvantGarde) Presented By : Kanika Nagpal OUTLINE Introduction Motivation Background

### Illustrative Example of Logical Database Creation

Illustrative Example of Logical Database Creation A small RAQUEL DB is created to illustrate what is involved as regards the logical schemas of a RAQUEL DB. Create a Database or ExampleDB

### CS425 Fall 2017 Boris Glavic Chapter 4: Introduction to SQL

CS425 Fall 2017 Boris Glavic Chapter 4: Introduction to SQL Modified from: Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Chapter 4: Introduction to SQL Overview of the

### DATA, DATABASES, AND QUERIES

Managing Data in Relational Databases DATA, DATABASES, AND QUERIES CS1100 Microsoft Access - Introduction 1 What is this About Storing, accessing, searching, and viewing data are important in any business.