SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Division
 Division is not essential operation ; just a useful shorthand.
 Also true of joins, but joins are so common that systems implement
joins specially. Division is NOT implemented in SQL.
 Not supported as a primitive operator, but useful for many
expressing queries
 Precondition: in A/B, the attributes in B must be included in the
schema for A. Also, the result has attributes A-B.
 SALES(supId, prodId);
 PRODUCTS(prodId);
 Relations SALES and PRODUCTS must be built using projections.
 SALES/PRODUCTS: the ids of the suppliers supplying ALL
products
 The division is a binary operation that is written
as R Ă· S
 The result consists of the restrictions of tuples in R to
the attribute names unique to R
 The header of R but not in the header of S, for which it
holds that all their combinations with tuples in S are
present in R
Student Task
Fred Database1
Fred Database2
Fred Compiler1
Eugene Database1
Eugene Compiler1
Sarah Database1
Sarah Database2
Completed DBProject
Task
Database1
Database2
Completed
Ă·
DBProject
Student
Fred
Sarah
sNo pNo
s1 p1
s1 p2
s1 p3
s1 p4
s2 p1
s2 p2
s3 p2
s4 p2
s4 p4
pNo
p2
A B1 A/B1
sNo
s1
s2
s3
s4
sNo pNo
s1 p1
s1 p2
s1 p3
s1 p4
s2 p1
s2 p2
s3 p2
s4 p2
s4 p4
pNo
p2
p4
A B2 A/B2
sNo
s1
s4
sNo pNo
s1 p1
s1 p2
s1 p3
s1 p4
s2 p1
s2 p2
s3 p2
s4 p2
s4 p4
pNo
p1
p2
p4
A B3 A/B3
sNo
s1
 Suppose that employees of the company are assigned
to some professional courses; each employee follows
several courses and each course is taken by several
employees
 Information about courses and which employee takes
which course can be represented by the following
relations
 Takes (Emp#, Course#)
 Courses (Course#, Topic, Weeks)
 Assume that these two relations have the following
content
Emp# Course#
7369 10
7369 20
7369 30
7782 10
7782 40
Course# Topics Weeks
20 CAD 5
10 DB 3
30 DB 2
40 OS 4
Takes Courses
 Consider the following query: “determine the emp# of
the employees taking all the courses with topic DB”
(Q1)
 The course# of the courses relevant to the query is
obtained through the following expression:
R1 = ∏ Course# (σ Topic=“DB”) (Courses))
The result of such query is {10, 30}
 The result of query Q1 is represented by all the
employees that appear in the Takes relation with each
of the course numbers retrieved by query R1
 The correct result of Q1 is thus {7369}
 The operation that allows one to execute such query is
the division
 Let R and S be relations; let UR and US be the attribute
 sets of R and S, respectively, and such that UR US
 The division operation is denoted as
R Ă· S
and is expressed as follows
 ∏(UR -US) (R) - ∏ (UR -US) ((∏ (UR –US) (R) X S) – R)
 The expression on the right side of the – sign
determines all tuples of R that are not associated with
at least a tuple of S
 Query Q1 is thus expressed as follows:
Takes Ă· ∏ Course# (σ Topic=“DB”) (Courses))
R = Takes
S = ∏ Course# (σ Topic=“DB”) (Courses))
S = {10, 30}
UR = {Emp#, Course#}
Us = {Course#}

Weitere Àhnliche Inhalte

Was ist angesagt?

Alg2 lesson 2-6 day 1
Alg2 lesson 2-6 day 1Alg2 lesson 2-6 day 1
Alg2 lesson 2-6 day 1
Carol Defreese
 
Relational Algebra-Database Systems
Relational Algebra-Database SystemsRelational Algebra-Database Systems
Relational Algebra-Database Systems
jakodongo
 

Was ist angesagt? (14)

Relational algebra dbms (2130703) - 160920107003
Relational algebra  dbms (2130703) - 160920107003Relational algebra  dbms (2130703) - 160920107003
Relational algebra dbms (2130703) - 160920107003
 
Tableau functions
Tableau   functionsTableau   functions
Tableau functions
 
Compiler lec 3
Compiler lec 3Compiler lec 3
Compiler lec 3
 
Relational algebra in dbms
Relational algebra in dbmsRelational algebra in dbms
Relational algebra in dbms
 
Regression diagnostics - Checking if linear regression assumptions are violat...
Regression diagnostics - Checking if linear regression assumptions are violat...Regression diagnostics - Checking if linear regression assumptions are violat...
Regression diagnostics - Checking if linear regression assumptions are violat...
 
Ch6 formal relational query languages
Ch6 formal relational query languages Ch6 formal relational query languages
Ch6 formal relational query languages
 
Data Structure Radix Sort
Data Structure Radix SortData Structure Radix Sort
Data Structure Radix Sort
 
Alg2 lesson 2-6 day 1
Alg2 lesson 2-6 day 1Alg2 lesson 2-6 day 1
Alg2 lesson 2-6 day 1
 
Alg2 lesson 2-6
Alg2 lesson 2-6Alg2 lesson 2-6
Alg2 lesson 2-6
 
Relational Algebra
Relational AlgebraRelational Algebra
Relational Algebra
 
Radix Sort
Radix SortRadix Sort
Radix Sort
 
Relational Algebra-Database Systems
Relational Algebra-Database SystemsRelational Algebra-Database Systems
Relational Algebra-Database Systems
 
Relational Algebra
Relational AlgebraRelational Algebra
Relational Algebra
 
DBMS - Relational Algebra
DBMS - Relational AlgebraDBMS - Relational Algebra
DBMS - Relational Algebra
 

Andere mochten auch (7)

09.02 normalization example
09.02 normalization example09.02 normalization example
09.02 normalization example
 
Earthquake in Nepal 2015
Earthquake in Nepal 2015Earthquake in Nepal 2015
Earthquake in Nepal 2015
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 
06.01 sql select distinct
06.01 sql select distinct06.01 sql select distinct
06.01 sql select distinct
 
Theoretische Informatik
Theoretische InformatikTheoretische Informatik
Theoretische Informatik
 
SQL
SQLSQL
SQL
 
OSI-Schichtenmodell
OSI-SchichtenmodellOSI-Schichtenmodell
OSI-Schichtenmodell
 

Ähnlich wie 07.05 division

Lecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculusLecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculus
emailharmeet
 
Unit04 dbms
Unit04 dbmsUnit04 dbms
Unit04 dbms
arnold 7490
 
Module 2-2.ppt
Module 2-2.pptModule 2-2.ppt
Module 2-2.ppt
Shylaja40
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questions
Dr P Deepak
 

Ähnlich wie 07.05 division (20)

Lecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculusLecture 06 relational algebra and calculus
Lecture 06 relational algebra and calculus
 
DBMS CS3
DBMS CS3DBMS CS3
DBMS CS3
 
Relational Algebra and it's Operations pptx
Relational Algebra and it's Operations pptxRelational Algebra and it's Operations pptx
Relational Algebra and it's Operations pptx
 
uniT 4 (1).pptx
uniT 4 (1).pptxuniT 4 (1).pptx
uniT 4 (1).pptx
 
Module 2 - part i
Module   2 - part iModule   2 - part i
Module 2 - part i
 
Lec02
Lec02Lec02
Lec02
 
Unit04 dbms
Unit04 dbmsUnit04 dbms
Unit04 dbms
 
Relational algebr
Relational algebrRelational algebr
Relational algebr
 
Relational algebra-and-relational-calculus
Relational algebra-and-relational-calculusRelational algebra-and-relational-calculus
Relational algebra-and-relational-calculus
 
Dbms ii mca-ch5-ch6-relational algebra-2013
Dbms ii mca-ch5-ch6-relational algebra-2013Dbms ii mca-ch5-ch6-relational algebra-2013
Dbms ii mca-ch5-ch6-relational algebra-2013
 
Module 2-2.ppt
Module 2-2.pptModule 2-2.ppt
Module 2-2.ppt
 
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questions
 
Relational algebra operations
Relational algebra operationsRelational algebra operations
Relational algebra operations
 
Base sas interview questions
Base sas interview questionsBase sas interview questions
Base sas interview questions
 
Relational Model
Relational ModelRelational Model
Relational Model
 
relational model in Database Management.ppt.ppt
relational model in Database Management.ppt.pptrelational model in Database Management.ppt.ppt
relational model in Database Management.ppt.ppt
 
SAS_and_R.pdf
SAS_and_R.pdfSAS_and_R.pdf
SAS_and_R.pdf
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R lang
 
Introduction to Relational Database Management Systems
Introduction to Relational Database Management SystemsIntroduction to Relational Database Management Systems
Introduction to Relational Database Management Systems
 

Mehr von Bishal Ghimire

07.03 cartesian product
07.03 cartesian product07.03 cartesian product
07.03 cartesian product
Bishal Ghimire
 
07.02 relational union intersection
07.02 relational union intersection07.02 relational union intersection
07.02 relational union intersection
Bishal Ghimire
 
07.01 relational algebra
07.01 relational algebra07.01 relational algebra
07.01 relational algebra
Bishal Ghimire
 
07.01 relational algebra
07.01 relational algebra07.01 relational algebra
07.01 relational algebra
Bishal Ghimire
 
09.01 normalization
09.01 normalization09.01 normalization
09.01 normalization
Bishal Ghimire
 
02.02 querying relational database
02.02 querying relational database02.02 querying relational database
02.02 querying relational database
Bishal Ghimire
 
02.01 relational databases
02.01 relational databases02.01 relational databases
02.01 relational databases
Bishal Ghimire
 
00.00 fundamentals of database management syllabus
00.00 fundamentals of database management syllabus00.00 fundamentals of database management syllabus
00.00 fundamentals of database management syllabus
Bishal Ghimire
 

Mehr von Bishal Ghimire (14)

Counseling Ethics in Astrology for better Mental Health
Counseling Ethics in Astrology for better Mental HealthCounseling Ethics in Astrology for better Mental Health
Counseling Ethics in Astrology for better Mental Health
 
Agile Intro to Manifesto - Values 1 - Interaction over Process
Agile Intro to Manifesto - Values 1 - Interaction over ProcessAgile Intro to Manifesto - Values 1 - Interaction over Process
Agile Intro to Manifesto - Values 1 - Interaction over Process
 
07.04 joins
07.04 joins07.04 joins
07.04 joins
 
07.03 cartesian product
07.03 cartesian product07.03 cartesian product
07.03 cartesian product
 
07.02 relational union intersection
07.02 relational union intersection07.02 relational union intersection
07.02 relational union intersection
 
07.01 relational algebra
07.01 relational algebra07.01 relational algebra
07.01 relational algebra
 
07.01 relational algebra
07.01 relational algebra07.01 relational algebra
07.01 relational algebra
 
09.01 normalization
09.01 normalization09.01 normalization
09.01 normalization
 
06.02 sql alias
06.02 sql alias06.02 sql alias
06.02 sql alias
 
04.01 file organization
04.01 file organization04.01 file organization
04.01 file organization
 
02.02 querying relational database
02.02 querying relational database02.02 querying relational database
02.02 querying relational database
 
02.01 relational databases
02.01 relational databases02.01 relational databases
02.01 relational databases
 
01.01 introduction to database
01.01 introduction to database01.01 introduction to database
01.01 introduction to database
 
00.00 fundamentals of database management syllabus
00.00 fundamentals of database management syllabus00.00 fundamentals of database management syllabus
00.00 fundamentals of database management syllabus
 

KĂŒrzlich hochgeladen

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 

KĂŒrzlich hochgeladen (20)

Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 

07.05 division

  • 1.
  • 2. Division  Division is not essential operation ; just a useful shorthand.  Also true of joins, but joins are so common that systems implement joins specially. Division is NOT implemented in SQL.  Not supported as a primitive operator, but useful for many expressing queries  Precondition: in A/B, the attributes in B must be included in the schema for A. Also, the result has attributes A-B.  SALES(supId, prodId);  PRODUCTS(prodId);  Relations SALES and PRODUCTS must be built using projections.  SALES/PRODUCTS: the ids of the suppliers supplying ALL products
  • 3.  The division is a binary operation that is written as R Ă· S  The result consists of the restrictions of tuples in R to the attribute names unique to R  The header of R but not in the header of S, for which it holds that all their combinations with tuples in S are present in R
  • 4. Student Task Fred Database1 Fred Database2 Fred Compiler1 Eugene Database1 Eugene Compiler1 Sarah Database1 Sarah Database2 Completed DBProject Task Database1 Database2 Completed Ă· DBProject Student Fred Sarah
  • 5. sNo pNo s1 p1 s1 p2 s1 p3 s1 p4 s2 p1 s2 p2 s3 p2 s4 p2 s4 p4 pNo p2 A B1 A/B1 sNo s1 s2 s3 s4
  • 6. sNo pNo s1 p1 s1 p2 s1 p3 s1 p4 s2 p1 s2 p2 s3 p2 s4 p2 s4 p4 pNo p2 p4 A B2 A/B2 sNo s1 s4
  • 7. sNo pNo s1 p1 s1 p2 s1 p3 s1 p4 s2 p1 s2 p2 s3 p2 s4 p2 s4 p4 pNo p1 p2 p4 A B3 A/B3 sNo s1
  • 8.  Suppose that employees of the company are assigned to some professional courses; each employee follows several courses and each course is taken by several employees  Information about courses and which employee takes which course can be represented by the following relations  Takes (Emp#, Course#)  Courses (Course#, Topic, Weeks)
  • 9.  Assume that these two relations have the following content Emp# Course# 7369 10 7369 20 7369 30 7782 10 7782 40 Course# Topics Weeks 20 CAD 5 10 DB 3 30 DB 2 40 OS 4 Takes Courses
  • 10.  Consider the following query: “determine the emp# of the employees taking all the courses with topic DB” (Q1)  The course# of the courses relevant to the query is obtained through the following expression: R1 = ∏ Course# (σ Topic=“DB”) (Courses)) The result of such query is {10, 30}
  • 11.  The result of query Q1 is represented by all the employees that appear in the Takes relation with each of the course numbers retrieved by query R1  The correct result of Q1 is thus {7369}  The operation that allows one to execute such query is the division
  • 12.  Let R and S be relations; let UR and US be the attribute  sets of R and S, respectively, and such that UR US  The division operation is denoted as R Ă· S and is expressed as follows  ∏(UR -US) (R) - ∏ (UR -US) ((∏ (UR –US) (R) X S) – R)  The expression on the right side of the – sign determines all tuples of R that are not associated with at least a tuple of S
  • 13.  Query Q1 is thus expressed as follows: Takes Ă· ∏ Course# (σ Topic=“DB”) (Courses)) R = Takes S = ∏ Course# (σ Topic=“DB”) (Courses)) S = {10, 30} UR = {Emp#, Course#} Us = {Course#}