educative.io

The alternative solution for example 1

Isn’t it SELF INNER JOIN rather than INNER JOIN here?


Course: https://www.educative.io/collection/5352985413550080/6335716377231360
Lesson: https://www.educative.io/collection/page/5352985413550080/6335716377231360/6529091323822080

Hi @lifch !!
In the lesson, the original query uses a NATURAL JOIN to join the “Actors” table with the “DigitalAssets” table. This NATURAL JOIN attempts to match columns in both tables that have the same name without explicitly specifying the join condition.

Is this behavior is equivalent to a “SELF INNER JOIN.”? It’s important to clarify the terminology here:

  1. NATURAL JOIN: This type of join matches columns with the same name between two different tables. In the original query, it’s joining the “Actors” table with the “DigitalAssets” table based on columns with matching names. This is not a self-join because it involves two distinct tables.

  2. “SELF INNER JOIN”: A self-join is when you join a table to itself. In this case, you are treating the same table as if it were two separate tables, giving them different aliases, and joining them together. This is typically done to compare rows within the same table, and you specify the join condition explicitly.

So, in the original query, it’s not a self-join. It’s a join between two different tables using the NATURAL JOIN syntax, which automatically matches columns with the same name in both tables. If you were to perform a self-join, you would be joining a table to itself, which is a different concept.
I hope it helps. Happy Learning :blush: