Skip to content

Cartesian Product, Join Operations

Cartesian Product

  • The cartesian product operation allows us to combine informationf rom two relations
  • If a column appears in two relations, we distinguish between them by writing the name of each table as a prefix in the combined table

Example

Table Instructors

ID name dept_name salary
222 Hello Physics 165005
351 World Chemistry 150406

Table Topics

ID chapter_name days_alloted dept
20 Atomic Theory 12 Physics
13 Molecular Mixing 15 Chemistry
25 Waves and Particles 10 Physics

We can merge these tables with \(\(\quad instructors\; X \; topics\)\) To select these values, we will use \(\sigma(instructors\; X \; topics)\)


Join

  • The Join operation allows us to combine a \(\sigma\) and an \(X\) into a single operation
  • \(r \, \bowtie_{\,\theta}\; s\) is the same thing as \(\sigma_\theta \;(r\; X \; s)\)

Example

The statement \(\(\quad \sigma_{\,instructors.dept\_name\,=\,topics.dept}\;(instructor\;X\; topics)\)\) is equivalent to \(\(\quad instructors\; \bowtie_{\;instructors.dept\_name\,=\,topics.dept}\;topics\)\)