1 Session 3 Welcome: To session 3-the 8 th. learning sequence “Relational algebra “ Recap : In the previous learning sequence, we discussed some example.

Slides:



Advertisements
Similar presentations
Database Languages Chapter 7. The Relational Algebra.
Advertisements

1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations.
1 Session 3 Welcome: To session 3 - the 7 th. learning sequence “Relational algebra “ Recap : In the previous learning sequences, we discussed some operators.
Murali Mani The Relational Model. Murali Mani Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still.
Nov 24, 2003Murali Mani SQL B term 2004: lecture 12.
Cs3431 Transactions, Logging and Security. cs3431 Transactions: What and Why? A set of operations on a database must appear as one “unit”. Example: Consider.
CS34311 The Entity- Relationship Model. CS34312 Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design Conceptual.
CS34311 The Entity- Relationship Model Part II.. CS34312 Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design.
Domains, Relations & Base RelVars (Ch
Murali Mani The Entity- Relationship Model. Murali Mani Database Design Stages Application Requirements Conceptual Design Logical Design Physical Design.
VARIABLES AND EXPRESSIONS NUMERICAL EXPRESSION A NAME FOR A NUMBER VARIABLE OR ALGEBRAIC EXPRESSION AN EXPRESSION THAT CONTAINS AT LEAST ONE VARIABLE.
1 SELECT statement. 2 Sample database Supplier Part supplies (0,n) colour s# snamep# pname amount citydob price qualitydate.
Arithmetic Sequences and Series. A sequence is arithmetic if each term – the previous term = d where d is a constant e.g. For the sequence d = 2 nd term.
Relational Algebra II. Semantics - where A WHERE X  Y –  : an operator like =, >, … Result of restriction A by the condition X  Y is A relation –with.
1.2 – Evaluate and Simplify Algebraic Expressions A numerical expression consists of numbers, operations, and grouping symbols. An expression formed by.
1 Session 3 Welcome: To session 3- the first learning sequence “ Introduction to Relational Model“ Recap : In the previous learning sequences, we discussed.
Algebraic Expressions. Definitions Variable – A variable is a letter or symbol that represents a number (unknown quantity). 8 + n = 12.
SQL (Chapter 2: Simple queries; Chapter 7 and 8: Nested and DML queries) Many of the examples in this document are based on the tables in the next slide.
Chapter 7 Relational Algebra. Topics in this Chapter Closure Revisited The Original Algebra: Syntax and Semantics What is the Algebra For? Further Points.
1 Session 2 Welcome: The seventh learning sequence “ Reduction of an EER schema to tables“ Recap : In the previous learning sequence, we discussed the.
1 Session 3 Welcome: To session 3-the fifth learning sequence “ Relational algebra “ Recap : In the previous learning sequences, we discussed the eight.
Algebra1 After this lecture, you should be able to:  Understand the differences between SQL (Structured Query Language) and Relational Algebra expressions.
SQL - miscellaneous D. Christozov / G.Tuparov INF 280 Database Systems: SQL – miscellaneous 1.
Perform DFS from A A B C D E F G. Perform BFS from A A B C D E F G.
An Introduction to SQL For CS Overview of SQL  It is the standard language for relational systems, although imperfect  Supports data definition.
1 The Entity- Relationship Model Instructor: Mohamed Eltabakh Part-2.
Relational Algebra Prof. Yin-Fu Huang CSIE, NYUST Chapter 7.
Properties of Logarithms. Basic Properties All logarithmic functions have certain properties. The basic properties are:
CS34311 The Entity- Relationship Model Part III..
1 Session 3 Welcome: To session 3-the fourth learning sequence “Relational algebra “ Recap : In the previous learning sequences, we discussed the four.
ALGEBRA VOCABULARY. Vocabulary: Expression Definition: A math phrase built from constants, variables and operations EXAMPLE: 3X - 2Y.
Patterns and Sequences Sequence: Numbers in a specific order that form a pattern are called a sequence. An example is 2, 4, 6, 8, 10 and 12. Polygon:
1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous learning sequence, we discussed the basic definitions.
CS34311 Translating ER Schema to Relational Model.
Algebra Arithmetic Sequences and Series. Vocabulary Sequence – A list of numbers in a particular order Arithmetic Sequence – A sequence of numbers.
1 Session 3 Welcome: To session 3-the third learning sequence “ Relational algebra “ Recap : In the previous learning sequences, we discussed the four.
STRUCTURE OF PRESENTATION :
“ Possible representation (3) “
Session 3 Welcome: To session 3-the fourth learning sequence
1-2 Algebraic Expressions Key Concept
Fundamentals of Databases
UNIT 11 Query Optimization
Unit 2 DB2 and SQL.
The number of times a number or expression (called a base) is used as a factor of repeated multiplication. Also called the power. 5⁴= 5 X 5 X 5 X 5 = 625.
Session 3 Welcome: To session 3-the fifth learning sequence
Translating ER Schema to Relational Model
Arithmetic Sequences and Series
Chapter 8 Relational Calculus.
SQL : Query Language Part II CS3431.
The Entity-Relationship Model
Session 3 Welcome: To session 3 - the 7th. learning sequence
The Entity-Relationship Model
پايگاه داده ها.
Advanced SQL: Views & Triggers
Session 3 Welcome: To session 3-the second learning sequence
Session 3 Welcome: To session 3-the sixth learning sequence
Φροντιστήριο SQL (από το βιβλίο του Date)
Session 2 Welcome: The seventh learning sequence
Advanced Database System
Instructor: Mohamed Eltabakh
Relational Algebra.
Session 3 Welcome: To session 3-the 8th. learning sequence
Evaluating Algebraic Expressions
SQL: Structured Query Language
“ Possible representation (2) “
“ Possible representation (1) “
Building Queries using the Principle of Simplest Query (POSQ)
STRUCTURE OF PRESENTATION :
Learn to identify and evaluate expressions.
Evaluating Algebraic Expressions
Presentation transcript:

1 Session 3 Welcome: To session 3-the 8 th. learning sequence “Relational algebra “ Recap : In the previous learning sequence, we discussed some example queries. Present learning: We shall explore the following topic: xample Queries. - Another example Queries.

2 Relational Algebra

uA basic expression in the relational algebra consists of either one of the following: wA relation in the database wA constant relation

Relational Instances for the Purchasing System The Supplier relation: S-numberS-nameS-city S100AhmedAmman S200AliJarash S300KasimIrbid S400JasimAquaba S500RanaAmman

5 The Part relation: P-numberP-nameColorPriceP-city P1TVSilver300Amman P2CameraBlack100Jarash P3VideoBlack200Amman P4PCSilver400Irbid P5PrinterRed100Irbid P6Scannersilver150Jarash

6 The shipment relation: S-numberP-numberQuantity S100P1100 S100P2150 S100P3200 S100P4160 S100P550 S100P670 S200P1200 S200P2150 S300P2400 S400P2150 S400P480 S500P4100

Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part.

Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part)

Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part) P-numberP-nameColorPriceP-city P1TVSilver300Amman P4PCSilver400Irbid P6Scannersilver150Jarash Temp1

Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part) Temp2  Shipment Temp1

Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part) Temp2  Shipment Temp1 S-numberP-numberQuantityP-nameColorPriceP-city S100P1100TVSilver300Amman S100P4160PCSilver400Irbid S100P670Scannersilver150Jarash S200P1200TVSilver300Amman S400P480PCSilver400Irbid S500P4100PCSilver400Irbid Temp2

Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) S-number S100 S200 S400 S500 Temp3

Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) Temp4  Supplier Temp3 S-numberS-nameS-city S100AhmedAmman S200AliJarash S400JasimAquaba S500RanaAmman Temp4

Example Queries uQ1- Get supplier names for suppliers who supplying at least one silver part. Temp1   P-color = ‘silver’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) Temp4  Supplier Temp3 Result   S-name (Temp4) S-name Ahmed Ali Jasim Rana Result

Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid.

Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part)

Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) P-numberP-nameColorPriceP-city P4PCSilver400Irbid P5PrinterRed100Irbid Temp1

Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) Temp2  Shipment Temp1 S-numberP-numberQuantityP-nameColorPriceP-city S100P4160PCSilver400Irbid S100P550PrinterRed100Irbid S400P480PCSilver400Irbid S500P4100PCSilver400Irbid Temp2

Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) S-number S100 S400 S500 Temp3

Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) Temp4  Supplier Temp3

Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) Temp4  Supplier Temp3 S-numberS-nameS-city S100AhmedAmman S400JasimAquaba S500RanaAmman Temp4

Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) Temp4  Supplier Temp3 Result   S-name, S-city (Temp4)

Example Queries uQ2- Get supplier names and cities who supplying parts stored in Irbid. Temp1   P-city = ‘Irbid’ (Part) Temp2  Shipment Temp1 Temp3   S-number (Temp2) Temp4  Supplier Temp3 Result   S-name, S-city (Temp4) S-nameS-city AhmedAmman JasimAquaba RanaAmman Result

Example Queries uQ3- Find supplier names for suppliers who supply all parts.

Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part)

Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) P-number P1 P2 P3 P4 P5 P6 Temp1

Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment)

Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) S-numberP-number S100P1 S100P2 S100P3 S100P4 S100P5 S100P6 S200P1 S200P2 S300P2 S400P2 S400P4 S500P4 Temp2

Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) Temp3  Temp2  Temp1

Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) Temp3  Temp2  Temp1 S-number S100 Temp3

Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) Temp3  Temp2  Temp1 Temp4  Supplier Temp3

Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) Temp3  Temp2  Temp1 Temp4  Supplier Temp3 S-numberS-nameS-city S100AhmedAmman Temp4

Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) Temp3  Temp2  Temp1 Temp4  Supplier Temp3 Result   S-name (Temp4)

Example Queries uQ3- Find supplier names for suppliers who supply all parts. Temp1   P-number (Part) Temp2   S-number, P-number (Shipment) Temp3  Temp2  Temp1 Temp4  Supplier Temp3 Result   S-name (Temp4) S-name Ahmed Result

Example Queries uQ4- How many parts they have?

Example Queries uQ4- How many parts they have? g count (P-number) (Part) P-number 6

Example Queries uQ5- Find the total quantities supplied by each supplier.

Example Queries uQ6- Find the total quantities supplied by each supplier. S-number g sum (Quantity) (Shipment)

Example Queries uQ6- Find the total quantities supplied by each supplier. S-number g sum (Quantity) (Shipment) S-numberQuantity S S S S S500100

Example Queries uQ6- Find the total quantities supplied by each supplier. S-number g sum (Quantity) as ( sum-quantity) (Shipment) S-numberSum-Quantity S S S S S500100

41 Relational Algebra Summary: In this learning sequence, we discussed another example queries about purchasing system.

42 END