Relational Model COP 4720 Lecture 9 Lecture Notes.

Slides:



Advertisements
Similar presentations
Exercise 2 Relational Calculus
Advertisements

Week 5 Relational Database Design by ER- -to-Relational Mapping.
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.
COMPANY schema EMPLOYEE
OUTLINE OF THE LECTURE PART I GOAL: Understand the Data Definition Statements in Fig 4.1 Step1: Columns of the Tables and Data types. Step2: Single column.
Lecture 1 Relational Algebra and Relational Calculus.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
The Relational Algebra
SQL Query Slides Sharif University Of Technology Database Systems CE 384 Prepared By: Babak Bagheri Hariri
Dept. of Computer & Information Sciences
LAB 4 FIGURES.
1 Lecture No 16 Asma Ahmad Relational Algebra I March 10, 2011 Database Systems.
Exploring Microsoft Access 2003 Chapter 4 Proficiency: Relational Databases, External Data, Charts, Pivot, and the Switchboard.
- relation schema, relations - database schema, database state
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
Jyh-haw Yeh Dept. of Computer Science Boise State University
More SQL: Complex Queries, Triggers, Views, and Schema Modification 1.
관계 연산자 & SQL. Selection SELECT * FROM r WHERE A=B AND D>5.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 8- 1 CREATE/DROP/ALTER TABLE Data types : char, varchar, decimal, date CREATE TABLE DEPARTMENT.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- to-Relational Mapping.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- Mapping.
1 CS 430 Database Theory Winter 2005 Lecture 12: SQL DML - SELECT.
Relational Algebra - Chapter (7th ed )
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.
 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 Algebra – Constraints CIS 4301 Lecture Notes Lecture /02/2006.
Slide Chapter 7 Relational Database Design by ER- to-Relational Mapping.
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.
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
莊裕澤資料庫基本概念 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.
Operations in the Relational Model COP 4720 Lecture 8 Lecture Notes.
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.
Security and User Authorization in SQL CIS 4301 Lecture Notes Lecture /18/2006.
Lecture (8) 1. Relational Database Design by ER- and EERR- to-Relational Mapping 2.
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.
Relational Database Design by ER- and EER-to-Relational Mapping
CS580 Advanced Database Topics Chapter 8 SQL Irena Pevac.
The SQL Database Grammar
CS580 Advanced Database Topics
6/22/2018.
Relational Database Design by ER- and EER-to-Relational Mapping
Relational Database Design by ER- and EERR-to-Relational Mapping
Relational Database Design by ER-to-Relational Mapping
Retrieval Queries in SQL(DML)
11/9/2018.
Company Requirements.
Relational Databases Relational Algebra (2)
Session - 6 Sequence - 2 SQL: The Structured Query Language:
LECTURE 3: Relational Algebra
Relational Algebra Sample Questions.
Relational Database Design by ER- and EER-to-Relational Mapping
SQL-99: Schema Definition, Constraints, and Queries and Views
Relational Database Design by ER- and EER-to- Relational Mapping
1. Explain the following concepts: (a) superkey (b) key
SQLPLUS: Oracle SQL Interface
SQL Grouping, Ordering & Arithmetics Presented by: Dr. Samir Tartir
SQL: Set Operations & Nested Queries. Presented by: Dr. Samir Tartir
Relational Database Design by ER-to-Relational Mapping
Answers to Midterm - Exam. Feb. 28, 2018
Answers to Midterm - Exam. Feb. 27, 2006
Presentation transcript:

Relational Model COP 4720 Lecture 9 Lecture Notes

Lecture 9COP Outline of Lecture Relational Algebra Queries Sec. 3.2

Lecture 9COP Summary of Relational Algebra (1) E ::= R | SELECT C (R) or  c (R) | PROJECT A 1,A 2,...,A n (R) or  A 1,A 2,...,A n (R) | E1 X E2 | E1 U E2 | E1 - E2 | RENAME R(A 1,A 2,...,A m ) (E) or  R(A 1,A 2,...,A m ) (E)

Lecture 9COP Summary of Relational Algebra (2) E ::= R | E1 JOIN E2 or E1 E2 | E1 JOIN C E2 or E1 C E2 | E1 INTERSECT E2 or E1  E2

Lecture 9COP Sample Schema for Exercises Student(ID, name, address, GPA, SAT) Campus(location, enrollment, rank) Apply(ID, location, date, major, decision)

Lecture 9COP Sample Queries PROJECT date,decision (Apply) Campus X Apply

Lecture 9COP Sample Queries Find Names and addresses of all students with GPA > 3.7 who applied to CS major and were rejected. List name and address of all students who didn’t apply anywhere.  name, address ((Students) Students.ID= Not_Apply.ID (  Not_Apply (  ID (Students) -  ID (Apply))))  name, address (  GPA>3.7  decision=‘No’  major=‘CS’ (Student Student.ID=Apply.ID Apply))

Lecture 9COP Schema for examples Employee(fname,lname,ssn,bdate,address,sex,salary,superssn,dno) Department(dname, dnumber,mgrssn,mgrstartdate) Dept_Locations(dnumber, dlocation) Project(pname,pnumber,plocation,dnum) Works_on(essn,pno,hours) Dependent(essn,dependent_name,sex,bdate,relationship)

Lecture 9COP Examples a)Retrieve the name and address of all employees who work for the ‘Research’ department. research   dname = ‘Research’ (Department) research_emps  research dnumber = dno (Employee) Result   fname,lname,address (research_emps) or research  Select dname = ‘Research’ (Department) research_emps  research join dnumber=dno Employee result  project fname,lname,address (research_emps)

Lecture 9COP Examples (refer to schema on previous slide) b) Retrieve the names of all employees in dept. 5 who work more than 10 hrs./week on project X. Option 1:  Fname,Lname (Employee SSN=ESSN (  Pname=‘Project X’  hours>10  Dnum=5 (Project Pnumber=Pno Works_On) ) ) Option 2: Emp_Work_X   Pname=‘Project X’ (Project Pnumber=Pno Works_On) Emp-Work_10  Employee SSN=ESSN (  hours>10 (Emp_Work_X) ) Result   Fname,Lname (  Dnum=5 (Emp_Work_10) )

Lecture 9COP c) List names of employees who have a dependent with the same first name. Same  (Employee) Fname=Dependent_Name (Dependent) Result   Fname,Lname (Same) ???????

Lecture 9COP c) List names of employees who have a dependent with the same first name. Same  (Employee) Fname=Dependent_Name  ssn=essn (Dependent) Result   Fname,Lname (Same)

Lecture 9COP d) Retrieve the names of employees who work on every project. Emp_proj  Project essn,pno ( Works_on ) T1  Project essn (Emp_proj) T2  Project pno (Works_on) T3  T2 x T1 T4  T3 – Emp_proj T5  Project essn T4 Ans  T1 – T5