Dept. of Computer & Information Sciences

Slides:



Advertisements
Similar presentations
Exercise 2 Relational Calculus
Advertisements

The Relational Algebra
The Relational Calculus
Database System - Assignment #3 Sept. 2012Yangjun Chen ACS Assignment #3 due Wed., Nov. 14, (30) Exercise 7.17 on Page 235 Show the result.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 102 Computer Programming II (Lab:
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 6 (Continued) The Relational Algebra and Calculus.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
1 CSE 480: Database Systems Lecture 22: Query Optimization Reference: Read Chapter 15.6 – 15.8 of the textbook.
Chapter 6 Additional Relational Operations Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
SQL Query Slides Sharif University Of Technology Database Systems CE 384 Prepared By: Babak Bagheri Hariri
Your Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Instructor: Mr. Ahmed Al Astal Chapter 8 (Cont.) SQL-99: Schema Definition,
Displaying Data from Multiple Tables. EMPNO DEPTNO LOC NEW YORK CHICAGO NEW YORK DALLAS
Company Database. CREATE TABLE DEPARMENT ( DNAME VARCHAR(10) NOT NULL, DNUMBER INTEGER NOT NULL, MGRSSN CHAR(9), MGRSTARTDATE CHAR(9), PRIMARY KEY (DNUMBER),
Exercise 1 Relational Algebra Database System-dww.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Employee database: Conceptual Schema in ERD Chapter 3, page 62.
Copyright © 2004 Pearson Education, Inc.. Chapter 6 The Relational Algebra and Relational Calculus.
CS 104 Introduction to Computer Science and Graphics Problems Introduction to Database (2) Basic SQL 12/05/2008 Yang Song.
More SQL: Complex Queries, Triggers, Views, and Schema Modification 1.
관계 연산자 & SQL. Selection SELECT * FROM r WHERE A=B AND D>5.
SQL The relational DB Standard CS-450 Dr. Ali Obaidi.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 8- 1 CREATE/DROP/ALTER TABLE Data types : char, varchar, decimal, date CREATE TABLE DEPARTMENT.
Al-Imam University Girls Education Center Collage of Computer Science 1 ST Semester, 1432/1433H Chapter 8 Part 4 SQL-99 Schema Definition, Constraints,
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Banking Example  branch (branch-name, branch-city, assets)  customer (customer-name, customer-street,
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
1 CS 430 Database Theory Winter 2005 Lecture 12: SQL DML - SELECT.
1 CSE 480: Database Systems Lecture 11: SQL. 2 SQL Query SELECT FROM WHERE –In MySQL, FROM and WHERE clauses are optional –Example:
Relational Algebra - Chapter (7th ed )
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 6 The Relational Algebra and Calculus.
CS 380 Introduction to Database Systems Chapter 7: The Relational Algebra and Relational Calculus.
Retrieve the names of all employees in department 5 who work more than 10 hours per week on the ‘ProductX’ project. p10ssn ← (Π essn (σ hours > 10 (works-on.
Dept. of Computer & Information Sciences
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 14 A First Course in Database Systems.
 Employee (fname, minit, lname, ssn, bdate, address, sex, salary, superssn, dno)  Department (dname, dnumber, mgrssn, mgrstartdate) 
Database Management Systems. NESTING OF QUERIES  Some queries require that existing values in the database be retrieved and then used in a comparison.
Relational Model COP 4720 Lecture 9 Lecture Notes.
SQL-5 (Group By.. Having). Group By  Need: To apply the aggregate functions to subgroups of tuples in a relation, where the subgroups are based on some.
The Relational Algebra and Calculus
Relational Algebra. 2 Outline  Relational Algebra Unary Relational Operations Relational Algebra Operations from Set Theory Binary Relational Operations.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Chapter 3 MORE SQL Copyright © 2004 Pearson Education, Inc.
莊裕澤資料庫基本概念 1 Yuh-Jzer Joung 莊 裕 澤 Dept. of Information Management National Taiwan University February, 2002 資料庫管理與資訊科技.
1 CSE 480: Database Systems Lecture 12: SQL (Nested queries and Aggregate functions)
Structured Query Language (2) The main reference of this presentation is the textbook and PPT from : Elmasri & Navathe, Fundamental of Database Systems,
The Relational Calculus (Based on Chapter 9 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3)
Copyright © 2004 Ramez Elmasri and Shamkant Navathe The Relational Calculus The main reference of this presentation is the textbook and PPT from : Elmasri.
Slide 6- 1 Additional Relational Operations Aggregate Functions and Grouping A type of request that cannot be expressed in the basic relational algebra.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Introduction to Database Systems
COMP163 Database Management Systems September 18, 2008 Lecture 8 – Sections SQL Queries.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 16 A First Course in Database Systems.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Basic SQL تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Basic SQL تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة.
CS580 Advanced Database Topics Chapter 8 SQL Irena Pevac.
CS580 Advanced Database Topics
6/22/2018.
Dept. of Computer & Information Sciences
Subject Name: DATA BASE MANAGEMENT SYSTEM Subject Code: 10cs54
More SQL: Complex Queries, Triggers, Views, and Schema Modification
11/9/2018.
Session - 6 Sequence - 2 SQL: The Structured Query Language:
Introduction to Database Systems
SQL (more).
e. Retrieve the names of all employees who work on every project.
SQL-99: Schema Definition, Constraints, and Queries and Views
SQL Grouping, Ordering & Arithmetics Presented by: Dr. Samir Tartir
SQL: Set Operations & Nested Queries. Presented by: Dr. Samir Tartir
Presentation transcript:

Dept. of Computer & Information Sciences Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems (Chapter 6 Tutorial)

Exercise 1 Given the Following database schema: Specify the following queries in: Relation algebra Tuple relational calculus Domain relational calculus Only for a, b, c, f, i, j Chapter 6 Tutorial 1

Exercise 1 - a Retrieve the names of all employees in department 5 who work more than 10 hours per week on the ‘Product x’ project. Relational Algebra: PROJ_X  PNAME = ‘Product x’ (PROJECT) EMP_WORK_10  HOURS>10 (PROJ_X PNUMBER=PNO WORKS_ON) EMP_DEPT_5  DNO=5 (EMPLOYEE SSN=ESSN EMP_WORK_10) RESULT p FNAME, LNAME (EMP_DEPT_5) Chapter 6 Tutorial 2

Exercise 1 - a Tuple relational calculus: {e.FNAME, e.LNAME | EMPLOYEE(e) AND e.DNO=5 AND (p) (w) (PROJECT(p) AND WORKS_ON(w) AND p.PNAME=‘Product x’ AND w.HOURS>10 AND e.SSN=w.ESSN AND p.PNUMBER= w.PNO)} Domain relational calculus: {qs | (z) (a) (b) (e) (f) (g) (EMPLOYEE(qrstuvwxyz) AND PROJECT(abcd) AND WORKS_ON(efg) AND z=5 AND a=‘Product x’ AND g>10 AND t=e AND b=f)} Chapter 6 Tutorial 3

Exercise 1 - b List the names of all employees who have a dependent with the same first name as themselves. Relational Algebra: EMP (EMPLOYEE SSN=ESSN AND FNAME=DEPENDENT_NAME DEPENDENT) RESULT p FNAME, LNAME (EMP) Chapter 6 Tutorial 4

Exercise 1 - b Tuple relational calculus: {e.FNAME, e.LNAME | EMPLOYEE(e) AND (d) (DEPENDENT(d) AND e.SSN=d.ESSN AND e.FNAME=d.DEPENDENT_NAME)} Domain relational calculus: {qs | (t) (a) (b) (EMPLOYEE(qrstuvwxyz) AND DEPENDENT(abcde) AND t=a AND q=b)} Chapter 6 Tutorial 5

Exercise 1 - c Find the names of all employees who are directly supervised by ‘Franklin Wong’. Relational Algebra: Domain relational calculus: Tuple relational calculus: Chapter 6 Tutorial 6

Exercise 1 - d For each project, list the project name and the total hours per week (by all employees) spent on that project. Relational Algebra: Chapter 6 Tutorial 8

Exercise 1 - e Retrieve the names of all employees who work on every project. Relational Algebra: Chapter 6 Tutorial 9

Exercise 1 - f Retrieve the names of all employees who do not work on any project. Relational Algebra: Domain relational calculus: Tuple relational calculus: Chapter 6 Tutorial 10

Exercise 1 - g For each department, retrieve the department name and the average salary of all employees working in that department. Relational Algebra: Chapter 6 Tutorial 12

Exercise 1 - h Retrieve the average salary of all female employees. Relational Algebra: Chapter 6 Tutorial 13

Exercise 1 - i Find the names and addresses of all employees who work on at least one project located in Houston but whose department has no location in Houston. Relational Algebra: Domain relational calculus: Tuple relational calculus: Chapter 6 Tutorial 14

Exercise 1 - j List the last names of all department managers who have no dependents. Relational Algebra: Domain relational calculus: Tuple relational calculus: Chapter 6 Tutorial 16