Download presentation
Presentation is loading. Please wait.
Published byHolly Young Modified over 9 years ago
1
Texas State Technical College DISCOVER! Cartesian Product Cover all the bases.
2
Texas State Technical College DISCOVER! Cartesian Product Whenever more than one table is included in a SELECT statement, SQL must know how the individual records between the tables are to be joined. If this information is not provided, SQL defaults to a Cartesian Product between all the records. A Cartesian Product is simply a multiplication between the tables in which all possible combinations of the records are produced. Overview
3
Texas State Technical College DISCOVER! Visualization PRIMARY KEY Vehicle Table VehicleIDNameEngine Text SVT-C96CobraSVT-V8 TM-C96MustangTorrence-V6 [ ENGINE ] Engine Table PRIMARY KEY ManufacturerConfigurationEngineID Text FordV-6Torrence-V6 FordV-8SVT-V8 Chrysler4 CylinderCRY-4C Given these two tables from our engines and vehicles example… Cartesian Product
4
Texas State Technical College DISCOVER! Visualization The following code would produce a Cartesian Product between the vehicle and engine tables. SELECT*FROM engine, vehicle ; No join criteria is specified, thus Cartesian is defaulted. [ ENGINE ] Cartesian Product
5
Texas State Technical College DISCOVER! Visualization [ ENGINE ] Engine Table ComponentsVehicle Table Components ManufacturerConfigurationEngineIDEngineNameVehicleID Text FordV-6Torrence-V6SVT-V8CobraSVT-C96 FordV-6Torrence-V6 MustangTM-C96 FordV-8SVT-V8 CobraSVT-C96 FordV-8SVT-V8Torrence-V6MustangTM-C96 Chrysler4 CylinderCRY-4CSVT-V8CobraSVT-C96 Chrysler4 CylinderCRY-4CTorrence-V6MustangTM-C96 The results of a Cartesian Product of the two tables. Cartesian Product
6
Texas State Technical College DISCOVER! The number of records returned from a Cartesian Product is calculated the same way as combinations in mathematics. Problem The number of records returned by a Cartesian Product of tables 1, 2, and 3. Calculation #Results = #Records(1) * #Records(2) * #Records(3) Computation Cartesian Product
7
Texas State Technical College DISCOVER! Domain Marketing Company The database contains a table of customers and a table of announcements. If the boss wanted a mailing label generated for each customer for each announcement, a Cartesian product would be used to generate the label records. Usage Example Cartesian Product
8
Texas State Technical College DISCOVER! In Summary… Whenever multiple tables are included in a SELECT statement and no joining criteria is specified, SQL assumes it is a Cartesian Product join. A product join is the listing of all possible combinations between the records of each table. Cartesian Product
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.