Server-Side Swift with Vapor, Episode 13: Parent-Child Relationships |

In this episode, learn how to set up a parent-child relationship between two models and then query the relationship.

This is a companion discussion topic for the original entry at


I see the example sibling relation between two different model, but how to do it with the same table ?

Something like a table that contains all nations and a pivot table that contains two columns: nationParentId and nationChildId whitch point on the same table ?

Can you explain how to implement ?

It should be exactly the same. The pivot can hold a reference to the the two users pointing to the same table without an issue. Just make sure the column names and properties are different