Consider this (django) model:
class Source(models.Model): # Some other fields type = models.ForeignKey(\'Type\') class Type(models.Model): # Some othe
Such a structure can easily be retrieved using a recursive common table expression.
An example is e.g. here: http://www.postgresql.org/docs/current/static/queries-with.html