LAB 4 FIGURES.

Slides:



Advertisements
Similar presentations
พีชคณิตแบบสัมพันธ์ (Relational Algebra) บทที่ 3 อ. ดร. ชุรี เตชะวุฒิ CS (204)321 ระบบฐานข้อมูล 1 (Database System I)
Advertisements

COMPANY schema EMPLOYEE
Lecture 1 Relational Algebra and Relational Calculus.
The Relational Algebra
Basic Queries. 2 Retrieval Queries in SQL SQL has one basic statement for retrieving information from a database; the SELECT statement This is not the.
SQL Query Slides Sharif University Of Technology Database Systems CE 384 Prepared By: Babak Bagheri Hariri
Displaying Data from Multiple Tables. EMPNO DEPTNO LOC NEW YORK CHICAGO NEW YORK DALLAS
Database technology Lecture 2: Relational databases and SQL
FEN More about SELECT, Nested selects GROUP BY, HAVING, ORDER BY Other joins Aggregate functions Views More about SQL.
Database Systems Chapter 6 ITM Relational Algebra The basic set of operations for the relational model is the relational algebra. –enable the specification.
- relation schema, relations - database schema, database state
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
Copyright © 2004 Pearson Education, Inc.. Chapter 6 The Relational Algebra and Relational Calculus.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
More SQL: Complex Queries, Triggers, Views, and Schema Modification 1.
Relational Data Model Sept. 2014Yangjun Chen ACS Outline: Relational Data Model Relational Data Model -relation schema, relations -database schema,
관계 연산자 & SQL. Selection SELECT * FROM r WHERE A=B AND D>5.
SQL The relational DB Standard CS-450 Dr. Ali Obaidi.
The Relational Algebra and Calculus. Relational Algebra Overview Relational algebra is the basic set of operations for the relational model These operations.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 6 The Relational Algebra and Calculus.
Relational Algebra Example Database Application (COMPANY) Relational Algebra –Unary Relational Operations –Relational Algebra Operations From Set Theory.
FEN  Queries: SELECT  Data Manipulation: INSERT, UPDATE, DELETE SQL: Structured Query Language – Part 2.
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 )
CS 380 Introduction to Database Systems Chapter 7: The Relational Algebra and Relational Calculus.
METU Department of Computer Eng Ceng 302 Introduction to DBMS The Relational Algebra by Pinar Senkul resources: mostly froom Elmasri, Navathe and other.
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.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 6- 1.
Oracle DML Dr. Bernard Chen Ph.D. University of Central Arkansas.
 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.
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)
Slide 6- 1 CARTESIAN (or cross) Product Operation Defines a relation Q that is the concatenation of every tuple of relation R with every tuple of relation.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 6 The Relational Algebra.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 6 The Relational Algebra.
The Relational Algebra. Slide 6- 2 Outline Relational Algebra Unary Relational Operations Relational Algebra Operations From Set Theory Binary Relational.
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.
603 Database Systems Senior Lecturer: Laurie Webster II, M.S.S.E.,M.S.E.E., M.S.BME, Ph.D., P.E. Lecture 11 A First Course in Database Systems.
7-1 Chapter 7 The Relational Data Model, Relational Constraints, and the Relational Algebra.
Query Processing – Implementing Set Operations and Joins Chap. 19.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus تنبيه : شرائح العرض.
Relational Algebra National University of Computer and Emerging Sciences Lecture # 6 June 30,2012.
Database Systems 主講人 : 陳建源 日期 :99/11/30 研究室 : 法 Chapter 6 The Relational Algebra.
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.
10/3/2017.
The Relational Algebra and Calculus
The Relational Algebra and Relational Calculus
The SQL Database Grammar
COMP3017 Advanced Databases
CS580 Advanced Database Topics
6/22/2018.
Chapter 6: Relational Algebra Fall 2015 Dr. Abdullah Almutairi
Chapter 4 The Relational Algebra and Calculus
Mapping ER Diagrams to Tables
CS4222 Principles of Database System
Outline: Relational Data Model
Company Requirements.
The Relational Algebra and Calculus
Introduction to Database Systems
The Relational Algebra and The Relational Calculus
SQL Grouping, Ordering & Arithmetics Presented by: Dr. Samir Tartir
SQL: Set Operations & Nested Queries. Presented by: Dr. Samir Tartir
Presentation transcript:

LAB 4 FIGURES

EMPLOYEE TABLE

PROJECT TABLE

DEPARTMENT TABLE

DEPENDENT TABLE

WORKS_ON TABLE

DEPT_LOCATIONS TABLE

RENAMING OPERATION Note : Ssn shouldn’t be underlined.

UNION OPERATION

UNION OPERATION

INTERSECTION OPERATION

SET DIFFERENCE (OR MINUS)

CARTESIAN PRODUCT

CARTESIAN PRODUCT

CARTESIAN PRODUCT

JOIN OPERATION

NATURAL JOIN OPERATION

NATURAL JOIN

LEFT OUTER JOIN

LEFT OUTER JOIN

RIGHT OUTER JOIN

DIVISION OPERATION

AGGREGATE FUNCTIONS ᵨ R(Dno,No_of_employees,Average_sal)(Dno COUNT Ssn, AVERAGE Salary(EMPLOYEE)) No renaming :

AGGREGATE FUNCTIONS ᵨ R(Dno,No_of_employees,Average_sal)(Dno COUNT Ssn, AVERAGE Salary(EMPLOYEE)) No grouping :

QUERY 1 Retrieve the name and address of all employees who work for the ‘Research’ department.

QUERY 1 RESEARCH_DEPT <- σ Dname=’Research’ (DEPARTMENT) RESEARCH_EMPS <- (RESEARCH_DEPT Dnumber=Dno EMPLOYEE) RESULT <- ∏ Fname, Lname, Address (RESEARCH_EMPS) OR ∏ Fname, Lname, Address (σ Dname=’Research’(DEPARTMENT Dnumber=Dno (EMPLOYEE)))

QUERY 2 List the names of employees with two or more dependents.

QUERY 2 T1(Ssn, No_of_dependents) <- Essn COUNT Dependent_name (DEPENDENT) T2 <- σ No_of_dependents>2 (T1) RESULT <- ∏ Lname, Fname (T2 * EMPLOYEE)

QUERY 3 Find the names of employees who work on all the projects controlled by department number 5.

QUERY 3 DEPT5_PROJS <- ᵨ(Pno)(∏ Pnumber (σ Dnum=5(PROJECT))) EMP_PROJ <- ᵨ(Ssn,Pno)(∏ Essn,Pno(WORKS_ON))

QUERY 3 RESULT_EMP_SSNS <- EMP_PROJ  DEPT5_PROJS RESULT <- ∏ Lname, Fname (RESULT_EMP_SSNS * EMPLOYEE)

QUERY 4 List the names of managers who have at least one dependent.

QUERY 4 MGRS(Ssn) <- ∏ Mgr_ssn (DEPARTMENT) EMPS_WITH_DEPS(Ssn) ∏ Essn (DEPENDENT) MGRS_WITH_DEPS <- (MGRS ∩ EMPS_WITH_DEPS) RESULT <- ∏ Lname, Fname (MGRS_WITH_DEPS * EMPLOYEE)