From the course: Relational Databases Essential Training

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Self joins

Self joins

From the course: Relational Databases Essential Training

Start my 1-month free trial

Self joins

- [Instructor] Relationships are almost always made between two different data tables but it is possible for a column and a table to relate to another column in the same table. This is called a self join. A self join, also known as a self-referencing relationship or a recursive relationship follows all of the same rules as the relationships created between two tables. They can be one-to-one, one-to-many, or many-to-many relationships. The same unique constraints still apply and you still you need to consider cardinality when determining the type of join. So where might a self join be useful? They're used to model hierarchies within the same class. For instance, consider this table of employees. Each employee has an ID and the table also stores the ID of the employee's direct supervisor. If you mentally connect the supervisor ID column back to the employee ID column, you can see that Marisol is supervisor to both…

Contents