What is the cartesian product of two relations with a common attribute

1k Views Asked by At

What I know about the Cartesian Product

I just learned about the cartesian product in my introduction to Databases. The example that was provided was pretty clear. For a relation A with n tuples and relation B with m tuples, I need to create a relation C that will have n*m tuples. Every tuple i from A will create m new tuples, for each tuple from B, in the Relation C.

Example of a Cartesian Product in the first image

Actual Question:

In the next example I learned how to make natural join from two relations that share a common attribute and have common values for that common attribute.

I was wondering how - if even possible - I could take the cartesian product from that example.

See picture two from the first link.

What I have tried:

My attempt at making the cartesian product

[Edit:] In this attempt I created a new table. The blue bits are the tuples that contain the values from the A/B table that I got from the example in the natural join. The red bits are the tuples that I got from the B/D relation from the natural join example. I was wondering if I was allowed to combine them in such a way to make the cartesian product easier to see.

The table of the example of the natural join is in the second image in the first link.

I have tried searching my question online, I'm sure someone must have answered it somewhere already. However I couldn't define my problem well enough. What could I have modified to my query to have gotten to the result?

Thanks

PS: I don't have 10 reputation points yet, So I can't embed images in my text yet and I can't have more than two links.