50 likes | 173 Vues
This guide provides an overview of fundamental SQL operations such as selection, projection, cross-product, set difference, union, intersection, join, division, and renaming. Through practical exercises, users can learn to extract information about sailors who have reserved specific boats, including identifying those with red, green, or all boats. Each operation is explained, emphasizing its purpose and application within the context of boat reservations. While mastering these SQL concepts, users will improve their database query skills for better data management.
E N D
Solution 2: Exercises Reserves Sailors Boats • Solution 1: Basic operations: Selection ( σ ) gives a subset of rows. Projection ( π ) Deletes unwanted cols. Cross-product( ) combine two relations. Set-difference ( — ) Tuples in reln. 1, but not in reln. 2. Union( ) Tuples in reln. 1 and in reln. 2. Additional operations: Intersection () – Tuples in both relns. Join ( ) – like but only keep tuples where common fields equal Division ( / ) – tuples from reln 1 with matches in reln 2 Renaming ( ρ) – Rename columns Find names of sailors who’ve reserved boat #103
A more efficient solution: Exercises Reserves Sailors Boats Basic operations: Selection ( σ ) gives a subset of rows. Projection ( π ) Deletes unwanted cols. Cross-product( ) combine two relations. Set-difference ( — ) Tuples in reln. 1, but not in reln. 2. Union( ) Tuples in reln. 1 and in reln. 2. Additional operations: Intersection () – Tuples in both relns. Join ( ) – like but only keep tuples where common fields equal Division ( / ) – tuples from reln 1 with matches in reln 2 Renaming ( ρ) – Rename columns Find names of sailors who’ve reserved a red boat
Exercises Reserves Sailors Boats Basic operations: Selection ( σ ) gives a subset of rows. Projection ( π ) Deletes unwanted cols. Cross-product( ) combine two relations. Set-difference ( — ) Tuples in reln. 1, but not in reln. 2. Union( ) Tuples in reln. 1 and in reln. 2. Additional operations: Intersection () – Tuples in both relns. Join ( ) – like but only keep tuples where common fields equal Division ( / ) – tuples from reln 1 with matches in reln 2 Renaming ( ρ) – Rename columns Find sailors who’ve reserved a red or a green boat
Exercises Reserves Sailors Boats Basic operations: Selection ( σ ) gives a subset of rows. Projection ( π ) Deletes unwanted cols. Cross-product( ) combine two relations. Set-difference ( — ) Tuples in reln. 1, but not in reln. 2. Union( ) Tuples in reln. 1 and in reln. 2. Additional operations: Intersection () – Tuples in both relns. Join ( ) – like but only keep tuples where common fields equal Division ( / ) – tuples from reln 1 with matches in reln 2 Renaming ( ρ) – Rename columns Find sailors who’ve reserved a red and a green boat
Exercises Reserves Sailors Boats Basic operations: Selection ( σ ) gives a subset of rows. Projection ( π ) Deletes unwanted cols. Cross-product( ) combine two relations. Set-difference ( — ) Tuples in reln. 1, but not in reln. 2. Union( ) Tuples in reln. 1 and in reln. 2. Additional operations: Intersection () – Tuples in both relns. Join ( ) – like but only keep tuples where common fields equal Division ( / ) – tuples from reln 1 with matches in reln 2 Renaming ( ρ) – Rename columns Find the names of sailors who’ve reserved all boats