Download presentation

Presentation is loading. Please wait.

Published bySamantha Willis Modified over 3 years ago

1
Relational operators 1 Lecture 7 Relational Operators

2
Relational operators 2 Relational data model relational data objects relational operators relational data integrity

3
Relational operators 3 preamble why do we need relational operators? what kind of operations do we need to perform? how many operators would we like to have? what do you think a powerful set of operators means? procedural / declarative relational algebra / relational calculus

4
Relational operators 4 Relational algebra operators basic primitive 4 set specific operations 4 relation specific operations relational closure

5
Relational operators 5 Set specific operators specialised for relations type compatibility attribute name inheritance candidate key inheritance they are union intersection difference Cartesian product exemplify them with a couple of relations of your choice

6
Relational operators 6 Relation specific operators restriction WHERE projection [,, …, ] join JOIN difference DIVBY

7
Relational operators 7 Restriction conditional expressions on atomic values primitive data types supported in SQL non-conditional scalar operators cannot be used in conditional expressions; however, they can be introduced via EXTEND domains no support provided in SQL PostgreSQL - extendable set of operators on atomic value atomic / non-atomic conditions nested conditions logical expressions

8
Relational operators 8 Join natural join theta-join can be expressed via a Cartesian product and a restriction; how? properties commutative associative

9
Relational operators 9 Join

10
Relational operators 10 Join

11
Relational operators 11 Division

12
Relational operators 12 Division

13
Relational operators 13 Relational algebra operators closure nested expressions primitive set restriction, projection, Cartesian product, union, difference

14
Relational operators 14 Examples

15
Relational operators 15 Examples get the name of the tutors who teach at least one module get the name position and salary of all the tutors who teach at least one module get the name of the tutors who do not teach any module get the name and address of all the students who take level one courses get the name of students who take all optional modules... think of other queries and devise relational algebra expressions for them

16
Relational operators 16 Extensions EXTEND you can think as allowing scalar computations in WHERE clauses SUMMARISE projections combined with the performance of summary calculations

17
Relational operators 17 Implementation DML in SQL relational operators can be implemented via SELECT statements SQL provides a richer set of operations than just the set of basic relational algebra operations e.g. sub-queries

18
Relational operators 18 The optimiser optimiser for a specific implementation, the module that decides what is the best strategy of evaluating an expression (a query) (note that evaluation record level operations) example get the addresses of all students who take the AI module 3000 students; 4 modules per student, on average; some 100 students for the AI module; ((Students JOIN Registration) WHERE Mname = AI) [Sname, Address] (Students JOIN (Registration WHERE Mname = AI)) [Sname, Address]

19
Relational operators 19 Summary relational algebra operators (set and relation specific) relational closure extensions implementation - SQL the optimiser relational calculus

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google