SlideShare a Scribd company logo
RELATIONAL SET OPERATORS


          Prepared by:

         Michelle A. Ogana

        Ronnjemmele Rivera

        Jane Allyza Catalla

          Harry Ochinang




                              1
Relational Set Operators
 This section describes the basic data manipulation



Relational Algebra
 Defines the theoretical way of manipulating table
  contents using the eight relational operators.



                                                   2
Eight Relational Operators
 SELECT
 PROJECT
 JOIN
 INTERSECT
 UNION
 DIFFERENCE
 PRODUCT
 DIVIDE

                             3
 The relational operators have the property of
  closure; that is, the use of relational algebra
  operators on existing relations (tables) produces
  new relations.

 There is no need to examine the mathematical
  definitions, properties and characteristics of
  those relational algebra operators.




                                                      4
SELECT

 Also known as RESTRICT
 Yields values for all rows found in a table.
 Used to list all of the row values, or can yield
  only those row values that match a specified
  criterion.
 SELECT yields a horizontal subset of a table.




                                                     5
ORIGINAL TABLE

      P_CODE   P_DESCRIPT   PRICE                              P_CODE      P_DESCRIPT      PRICE
      123456   Flashlight   $5.26                              123456      Flashlight      $5.26

      123457   Lamp         $25.15                             123457      Lamp            $25.15
                                     SELECT ALL yields
      123458   Box Fan      $10.99
                                                               123458      Box Fan         $10.99
      123459   9V Battery   $1.29
                                                               123459      9V Battery      $1.29
      254688   100W Bulb    $1.47
                                                               254688      100W Bulb       $1.47
      311452   Powerdrill   $34.99
                                                               311452      Powerdrill      $34.99




SELECT only PRICE less than $2.00 yields                 P_CODE P_DESCRIPT              PRICE
                                                         123459     9V Battery          $1.29
                                                         254688     100W Bulb           $1.47




SELECT only P_CODE = 311452 yields                         P_CODE       P_DESCRIPT       PRICE

                                                           311452 Powerdrill $34.99


                                                                                                 6
PROJECT

 Yields all values for selected attributes.


 It yields a vertical subset of a table.




                                               7
ORIGINAL TABLE                                                   NEW TABLE

     P_CODE   P_DESCRIPT   PRICE                                        PRICE
     123456   Flashlight   $5.26
                                    PROJECT PRICE yields                $5.26
     123457   Lamp         $25.15                                       $25.15

     123458   Box Fan      $10.99                                       $10.99
                                                                        $1.92
     123459   9V Battery   $1.29
                                                                        $1.47
     254688   100W Bulb    $1.47
                                                                        $34.99
     311452   Powerdrill   $34.99
                                                              P_DESCRIPT           PRICE
                                                           Flashlight            $5.26
                                                           Lamp                  $25.15
PROJECT P_DESCRIPT and PRICE yields                        Box Fan               $10.99
                                                           9v battery            $1.92
                                                           100w bulb             $1.47
                                                           Powerdrill            $34.99


                                                                  P_CODE          PRICE
                                                             123456              $5.26
PROJECT P_CODE and PRICE yields                              123457              $25.15
                                                             123458              $10.99
                                                             213345              $1.92
                                                             254467              $1.47
                                                             311452              $34.99
                                                                                           8
UNION

 Combines all rows from two tables, excluding
  duplicate rows.
 To be used in UNION, tables must have the same
  attribute characteristics
 Columns, and domains must be compatible
 When two or more tables share the same number
  of columns, and when their corresponding
  columns share the same domains, they are said
  to be UNION-COMPATIBLE.

                                               9
P_CODE   P_DESCRIPT   PRICE             P_CODE       P_DESCIPT         PRICE
                               UNION
123456   Flashlight   $5.26            345678       Microwave       160.00

123457   Lamp         $25.15           345679       Dishwasher      500.00

123458   Box Fan      $10.99

123459   9V Battery   $1.29

254688   100W Bulb    $1.47
                                        yields
311452   Powerdrill   $34.99


                                                 P_CODE   P_DESCRIPT         PRICE


                                                 123456   Flashlight     $5.26


                                                 123457   Lamp           $25.15


                                                 123458   Box Fan        $10.99


                                                 254688   9V Battery     $1.29


                                                 524789   100W Bulb      $1.47


                                                 311452   Powerdrill     $34.99


                                                 345678   Microwave      $ 160

                                                 345679   Dishwasher     $ 500
                                                                                     10
INTERSECT
 Yields only the rows that appear in both
  tables.
 As was true in the case of UNION, the tables
  must be union-compatible to yield valid
  results.
 For example, you cannot use INTERSECT if
  one of the attributes is numeric and one is
  character-based.


                                                 11
STU_FNAME           STU_LNAME                          EMP_FNAME         EMP_LNAME
                                       INTERSECT
George             Jones                                  Franklin          Lopez

Jane               Smith                                  William           Turner

Peter              Robinson                               Franklin          Johnson

Franklin           Johnson                                Susan             Rogers

Martin             Lopez




                                                          yields




                                                          STU_FNAME             STU_LNAME

                                                   Franklin               Johnson




                                                                                            12
DIFFERENCE

 Yields all rows in one table that are not found
  in the other table;
 It subtracts one table form the other.
 Tables must be union-compatible to yield
  valid results.
 Note that subtracting the first table from the
  second table is not the same as subtracting
  the second table from the first table.

                                                    13
STU_FNAME           STU_LNAME                        EMP_FNAME           EMP_LNAME
                                       DIFFERENCE
George             Jones                             Franklin            Lopez

Jane               Smith                             William             Turner

Peter              Robinson                          Franklin            Johnson

Franklin           Johnson                           Susan               Rogers

Martin             Lopez




                                                     yields



                                                           STU_FNAME            STU_LNAME

                                                    George              Jones

                                                    Jane                Smith

                                                    Peter               Robinson

                                                    Martin              Lopez




                                                                                            14
PRODUCT
 Yields all possible pairs of rows from two
  tables
 Also known as Cartesian product
 Therefore, if one table has six rows and the
  other table has three rows,
 The PRODUCT yields a list composed of
6 x 3 = 18 rows



                                                 15
P_CODE   P_DESCRIPT   PRICE                STORE       AISLE       SHELF

123456   Flashlight   $5.26    PRODUCT    23       W           5

123457   Lamp         $25.15              24       K           9

123458   Box Fan      $10.99              25       Z           6

123459   9V Battery   $1.29

254688   100W Bulb    $1.47

311452   Powerdrill   $34.99             yields




                                                                           16
JOIN

 Allows information to be combined from two
  or more tables.
 It is the real power behind the relational
  database, allowing the use of independent
  tables linked by common attributes
 The CUSTOMER and AGENT tables shown
  will be used to illustrate several types of joins.



                                                       17
TABLE name: CUSTOMER                             TABLE name: AGENT


 CUS_CODE   CUS_LNAME   CUS_ZIP     AGENT_CODE         AGENT_CODE     AGENT_PHONE

1132445     Walker      32145     321            125                6152439887

1217782     Adares      32145     125            167                6153426778

1312243     Rakowski    34129     167            231                6152431124

13212442    Rodriguez   37134     125            333                9041234445

1542311     Smithson    37134     421

1657399     Vanloo      32145     231




                                                                                    18
 A natural join links tables by selecting only
  the rows with common values in their
  common attribute(s).

 It is the result of a three-stage process:




                                                  19
a. First, a PRODUCT of the tables is created




                                               20
b. Second, a SELECT is performed on the output of Step A to
yield only the rows for which the AGENT_CODE values are equal.
Common columns are referred to as the join columns.




                                                              21
c. A PROJECT is performed on the results of Step B to yield a
single copy of each attribute, thereby eliminating duplicate
columns.




                                                           22
 The final outcome of a natural join yields a
  table that does not include unmatched pairs
  and provides only the copies of the matches.




                                                 23
Note a few crucial features of the natural join operation:


 If no match is made between the table rows, the new table
  does not include the unmatched row. In that case, neither
  AGENT_CODE 421 nor the customer whose last name is
  Smithson is included.



 Smithson’s AGENT_CODE 421 does not match any entry in
  the AGENT table.


                                                              24
 The column on which the join was made- that is,
  AGENT_CODE- occurs only once in the new table.



 If the same AGENT_CODE were to occur several times in the
  AGENT table, a customer would be listed for each match



 For example, if the AGENT_CODE 167 were to occur three
  times in the AGENT table, the customer name Rakowski, who
  is associated with AGENT_CODE 167, would occur three
  times in the resulting table
                                                           25
Forms of JOIN
 1. EQUIJOIN

 Links tables on the basis of an equality
  condition that compares specified columns of
  each table.

 It does not eliminate duplicate columns


 Condition or criterion used to join the tables
  must be explicitly defined.
                                                   26
 Takes its name from the equality comparison
  operator (=) used in the condition.


2. Theta Join



 This join is used if any other comparison
  operator is used.


                                                27
3. Inner Join



 Returns matched records from the tables that
   are being joined.




                                                 28
3. Outer Join


 Matched pairs would be retained, and any
   unmatched values in the other table would be
   left null.

 Returns all of the matched records that the
   inner join returns, plus it returns the
   unmatched records from one of the tables



                                                  29
3.a. Left Outer Join


 Yields all rows in the CUSTOMER table,
  including those that do not have a matching
  value in the AGENT table.




                                                30
3.b. Right Outer Join


 Yields all the rows in the AGENT table,
 including those that do not have matching
 values in the CUSTOMER table.




                                             31
 Outer joins operate like equijoins.


 It does not drop one copy of the common
  attribute, and it requires the specification of the
  join condition.


 Are especially useful when you are trying to
  determine what value(s) in related tables
  cause(s) referential integrity problems

                                                        32
 You may wonder why the outer joins are
  labeled left and right.



 The labels refer to the order in which the
  tables are listed in the SQL command.




                                               33
DIVIDE
 Uses one single-column table (e.g., column “a”) as
  the divisor and one 2-column table (i.e., columns “a”
  and “b”) as the dividend.


 The tables must have common column


 Single column with the values of column “a” from
  the dividend table rows where the value of the
  common column (i.e., column “a” ) in both tables.
                                                          34
CODE       LOC                  CODE                     LOC
                        DIVIDE
A          5                          A                      5
                                      B
A          9

A          4                                    yields
B          5

B          3

C          6

D          7         A. Table 1 is divided by Table 2 to produce Table 3.
D          8
                     Tables 1 & 2 both contain the column CODE but
E          8
                     do not share LOC.

    B. To be included in the resulting Table 3, a value in the
    unshared column (LOC( must be associated (in the dividing
    Table 2) with every value in Table 1.

    C. The only value associated with both A and B is 5.
                                                                       35
36

More Related Content

What's hot

SQL Overview
SQL OverviewSQL Overview
SQL Overview
Stewart Rogers
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
Ankit Rai
 
SQL commands
SQL commandsSQL commands
SQL commands
GirdharRatne
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
farwa waqar
 
Working with Databases and MySQL
Working with Databases and MySQLWorking with Databases and MySQL
Working with Databases and MySQL
Nicole Ryan
 
Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause
Deepam Aggarwal
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
Sachidananda M H
 
DML Commands
DML CommandsDML Commands
SQL Basics
SQL BasicsSQL Basics
SQL Basics
Hammad Rasheed
 
SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query Optimization
Brian Gallagher
 
Relational Algebra,Types of join
Relational Algebra,Types of joinRelational Algebra,Types of join
Relational Algebra,Types of join
raj upadhyay
 
SQL subquery
SQL subquerySQL subquery
SQL subquery
Vikas Gupta
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and Relationships
Abdul Rahman Sherzad
 
Database Triggers
Database TriggersDatabase Triggers
Database Triggers
Aliya Saldanha
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and Operators
Mohan Kumar.R
 
SQL
SQLSQL

What's hot (20)

SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
Mysql
MysqlMysql
Mysql
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
 
SQL commands
SQL commandsSQL commands
SQL commands
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Working with Databases and MySQL
Working with Databases and MySQLWorking with Databases and MySQL
Working with Databases and MySQL
 
Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Views
ViewsViews
Views
 
DML Commands
DML CommandsDML Commands
DML Commands
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query Optimization
 
Relational Algebra,Types of join
Relational Algebra,Types of joinRelational Algebra,Types of join
Relational Algebra,Types of join
 
SQL subquery
SQL subquerySQL subquery
SQL subquery
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and Relationships
 
Database Triggers
Database TriggersDatabase Triggers
Database Triggers
 
Sql operators & functions 3
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and Operators
 
SQL
SQLSQL
SQL
 

Viewers also liked

Sql Authorization
Sql AuthorizationSql Authorization
Sql AuthorizationFhuy
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
Kabindra Koirala
 
Relational keys
Relational keysRelational keys
Relational keys
Sana2020
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMSkoolkampus
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMSkoolkampus
 
Slide 5 keys
Slide 5 keysSlide 5 keys
Slide 5 keys
Visakh V
 
View of data DBMS
View of data DBMSView of data DBMS
View of data DBMS
Rahul Narang
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMSkoolkampus
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMSkoolkampus
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMSkoolkampus
 
RAID
RAIDRAID
DBMS - Normalization
DBMS - NormalizationDBMS - Normalization
DBMS - Normalization
Jitendra Tomar
 

Viewers also liked (13)

Sql Authorization
Sql AuthorizationSql Authorization
Sql Authorization
 
ER Model in DBMS
ER Model in DBMSER Model in DBMS
ER Model in DBMS
 
Relational keys
Relational keysRelational keys
Relational keys
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 
DBMS Keys
DBMS KeysDBMS Keys
DBMS Keys
 
Slide 5 keys
Slide 5 keysSlide 5 keys
Slide 5 keys
 
View of data DBMS
View of data DBMSView of data DBMS
View of data DBMS
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
 
15. Transactions in DBMS
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMS
 
RAID
RAIDRAID
RAID
 
DBMS - Normalization
DBMS - NormalizationDBMS - Normalization
DBMS - Normalization
 

More from Manuel S. Enverga University Foundation (6)

Information packaging
Information packagingInformation packaging
Information packaging
 
Formats & conventions
Formats & conventionsFormats & conventions
Formats & conventions
 
Readers advisory services_in_public_libraries
Readers advisory services_in_public_librariesReaders advisory services_in_public_libraries
Readers advisory services_in_public_libraries
 
Kwoc
KwocKwoc
Kwoc
 
Kwoc
KwocKwoc
Kwoc
 
Web design and the law
Web design and the lawWeb design and the law
Web design and the law
 

Recently uploaded

DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 

Recently uploaded (20)

DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 

Set operators

  • 1. RELATIONAL SET OPERATORS Prepared by: Michelle A. Ogana Ronnjemmele Rivera Jane Allyza Catalla Harry Ochinang 1
  • 2. Relational Set Operators  This section describes the basic data manipulation Relational Algebra  Defines the theoretical way of manipulating table contents using the eight relational operators. 2
  • 3. Eight Relational Operators  SELECT  PROJECT  JOIN  INTERSECT  UNION  DIFFERENCE  PRODUCT  DIVIDE 3
  • 4.  The relational operators have the property of closure; that is, the use of relational algebra operators on existing relations (tables) produces new relations.  There is no need to examine the mathematical definitions, properties and characteristics of those relational algebra operators. 4
  • 5. SELECT  Also known as RESTRICT  Yields values for all rows found in a table.  Used to list all of the row values, or can yield only those row values that match a specified criterion.  SELECT yields a horizontal subset of a table. 5
  • 6. ORIGINAL TABLE P_CODE P_DESCRIPT PRICE P_CODE P_DESCRIPT PRICE 123456 Flashlight $5.26 123456 Flashlight $5.26 123457 Lamp $25.15 123457 Lamp $25.15 SELECT ALL yields 123458 Box Fan $10.99 123458 Box Fan $10.99 123459 9V Battery $1.29 123459 9V Battery $1.29 254688 100W Bulb $1.47 254688 100W Bulb $1.47 311452 Powerdrill $34.99 311452 Powerdrill $34.99 SELECT only PRICE less than $2.00 yields P_CODE P_DESCRIPT PRICE 123459 9V Battery $1.29 254688 100W Bulb $1.47 SELECT only P_CODE = 311452 yields P_CODE P_DESCRIPT PRICE 311452 Powerdrill $34.99 6
  • 7. PROJECT  Yields all values for selected attributes.  It yields a vertical subset of a table. 7
  • 8. ORIGINAL TABLE NEW TABLE P_CODE P_DESCRIPT PRICE PRICE 123456 Flashlight $5.26 PROJECT PRICE yields $5.26 123457 Lamp $25.15 $25.15 123458 Box Fan $10.99 $10.99 $1.92 123459 9V Battery $1.29 $1.47 254688 100W Bulb $1.47 $34.99 311452 Powerdrill $34.99 P_DESCRIPT PRICE Flashlight $5.26 Lamp $25.15 PROJECT P_DESCRIPT and PRICE yields Box Fan $10.99 9v battery $1.92 100w bulb $1.47 Powerdrill $34.99 P_CODE PRICE 123456 $5.26 PROJECT P_CODE and PRICE yields 123457 $25.15 123458 $10.99 213345 $1.92 254467 $1.47 311452 $34.99 8
  • 9. UNION  Combines all rows from two tables, excluding duplicate rows.  To be used in UNION, tables must have the same attribute characteristics  Columns, and domains must be compatible  When two or more tables share the same number of columns, and when their corresponding columns share the same domains, they are said to be UNION-COMPATIBLE. 9
  • 10. P_CODE P_DESCRIPT PRICE P_CODE P_DESCIPT PRICE UNION 123456 Flashlight $5.26 345678 Microwave 160.00 123457 Lamp $25.15 345679 Dishwasher 500.00 123458 Box Fan $10.99 123459 9V Battery $1.29 254688 100W Bulb $1.47 yields 311452 Powerdrill $34.99 P_CODE P_DESCRIPT PRICE 123456 Flashlight $5.26 123457 Lamp $25.15 123458 Box Fan $10.99 254688 9V Battery $1.29 524789 100W Bulb $1.47 311452 Powerdrill $34.99 345678 Microwave $ 160 345679 Dishwasher $ 500 10
  • 11. INTERSECT  Yields only the rows that appear in both tables.  As was true in the case of UNION, the tables must be union-compatible to yield valid results.  For example, you cannot use INTERSECT if one of the attributes is numeric and one is character-based. 11
  • 12. STU_FNAME STU_LNAME EMP_FNAME EMP_LNAME INTERSECT George Jones Franklin Lopez Jane Smith William Turner Peter Robinson Franklin Johnson Franklin Johnson Susan Rogers Martin Lopez yields STU_FNAME STU_LNAME Franklin Johnson 12
  • 13. DIFFERENCE  Yields all rows in one table that are not found in the other table;  It subtracts one table form the other.  Tables must be union-compatible to yield valid results.  Note that subtracting the first table from the second table is not the same as subtracting the second table from the first table. 13
  • 14. STU_FNAME STU_LNAME EMP_FNAME EMP_LNAME DIFFERENCE George Jones Franklin Lopez Jane Smith William Turner Peter Robinson Franklin Johnson Franklin Johnson Susan Rogers Martin Lopez yields STU_FNAME STU_LNAME George Jones Jane Smith Peter Robinson Martin Lopez 14
  • 15. PRODUCT  Yields all possible pairs of rows from two tables  Also known as Cartesian product  Therefore, if one table has six rows and the other table has three rows,  The PRODUCT yields a list composed of 6 x 3 = 18 rows 15
  • 16. P_CODE P_DESCRIPT PRICE STORE AISLE SHELF 123456 Flashlight $5.26 PRODUCT 23 W 5 123457 Lamp $25.15 24 K 9 123458 Box Fan $10.99 25 Z 6 123459 9V Battery $1.29 254688 100W Bulb $1.47 311452 Powerdrill $34.99 yields 16
  • 17. JOIN  Allows information to be combined from two or more tables.  It is the real power behind the relational database, allowing the use of independent tables linked by common attributes  The CUSTOMER and AGENT tables shown will be used to illustrate several types of joins. 17
  • 18. TABLE name: CUSTOMER TABLE name: AGENT CUS_CODE CUS_LNAME CUS_ZIP AGENT_CODE AGENT_CODE AGENT_PHONE 1132445 Walker 32145 321 125 6152439887 1217782 Adares 32145 125 167 6153426778 1312243 Rakowski 34129 167 231 6152431124 13212442 Rodriguez 37134 125 333 9041234445 1542311 Smithson 37134 421 1657399 Vanloo 32145 231 18
  • 19.  A natural join links tables by selecting only the rows with common values in their common attribute(s).  It is the result of a three-stage process: 19
  • 20. a. First, a PRODUCT of the tables is created 20
  • 21. b. Second, a SELECT is performed on the output of Step A to yield only the rows for which the AGENT_CODE values are equal. Common columns are referred to as the join columns. 21
  • 22. c. A PROJECT is performed on the results of Step B to yield a single copy of each attribute, thereby eliminating duplicate columns. 22
  • 23.  The final outcome of a natural join yields a table that does not include unmatched pairs and provides only the copies of the matches. 23
  • 24. Note a few crucial features of the natural join operation:  If no match is made between the table rows, the new table does not include the unmatched row. In that case, neither AGENT_CODE 421 nor the customer whose last name is Smithson is included.  Smithson’s AGENT_CODE 421 does not match any entry in the AGENT table. 24
  • 25.  The column on which the join was made- that is, AGENT_CODE- occurs only once in the new table.  If the same AGENT_CODE were to occur several times in the AGENT table, a customer would be listed for each match  For example, if the AGENT_CODE 167 were to occur three times in the AGENT table, the customer name Rakowski, who is associated with AGENT_CODE 167, would occur three times in the resulting table 25
  • 26. Forms of JOIN 1. EQUIJOIN  Links tables on the basis of an equality condition that compares specified columns of each table.  It does not eliminate duplicate columns  Condition or criterion used to join the tables must be explicitly defined. 26
  • 27.  Takes its name from the equality comparison operator (=) used in the condition. 2. Theta Join  This join is used if any other comparison operator is used. 27
  • 28. 3. Inner Join  Returns matched records from the tables that are being joined. 28
  • 29. 3. Outer Join  Matched pairs would be retained, and any unmatched values in the other table would be left null.  Returns all of the matched records that the inner join returns, plus it returns the unmatched records from one of the tables 29
  • 30. 3.a. Left Outer Join  Yields all rows in the CUSTOMER table, including those that do not have a matching value in the AGENT table. 30
  • 31. 3.b. Right Outer Join  Yields all the rows in the AGENT table, including those that do not have matching values in the CUSTOMER table. 31
  • 32.  Outer joins operate like equijoins.  It does not drop one copy of the common attribute, and it requires the specification of the join condition.  Are especially useful when you are trying to determine what value(s) in related tables cause(s) referential integrity problems 32
  • 33.  You may wonder why the outer joins are labeled left and right.  The labels refer to the order in which the tables are listed in the SQL command. 33
  • 34. DIVIDE  Uses one single-column table (e.g., column “a”) as the divisor and one 2-column table (i.e., columns “a” and “b”) as the dividend.  The tables must have common column  Single column with the values of column “a” from the dividend table rows where the value of the common column (i.e., column “a” ) in both tables. 34
  • 35. CODE LOC CODE LOC DIVIDE A 5 A 5 B A 9 A 4 yields B 5 B 3 C 6 D 7 A. Table 1 is divided by Table 2 to produce Table 3. D 8 Tables 1 & 2 both contain the column CODE but E 8 do not share LOC. B. To be included in the resulting Table 3, a value in the unshared column (LOC( must be associated (in the dividing Table 2) with every value in Table 1. C. The only value associated with both A and B is 5. 35
  • 36. 36