title: How to access child of child from parent in sqlalchemy?
body: <p>Lets suppose i have a gift, each gift has a sub-category 'i.e perfumes' each sub-category is inside a category 'i.e female gifts' (in other words that will look like in the URL: "/female-gifts/perfumes/foo-gift" OR "male-gifts/perfumes/bar-gift")</p>
  
  <pre><code>class Category(db.Model):
      __tablename__ = 'category'
  
      id = db.Column(db.String(32), primary_key=True)
      name = db.Column(db.String(40), unique=True)
      sub_categories = db.relationship("SubCategory", backref="category")
  
  class SubCategory(db.Model):
      __tablename__ = 'sub_category'
  
      id = db.Column(db.String(32), primary_key=True)
      name = db.Column(db.String(40), primary_key=True)
      category_id = db.Column(
          db.String(32), db.ForeignKey('category.id'), primary_key=True)
  
  class Gift(db.Model):
      __tablename__ = 'gift'
  
      id = db.Column(db.String(5), primary_key=True)
      sub_category_id = db.Column(
          db.String(32), db.ForeignKey('sub_category.id'))
      sub_category = db.relationship(SubCategory, uselist=False, backref='gifts')
      category = # WHAT SHOULD I WRITE HERE???
  </code></pre>
  
  <p>I want to get all gifts in the category 'not the sub category' by these statements:</p>
  
  <pre><code>Gift.query.filter_by(category_id='1234').all()
  
  Category.query.filter_by(id='1234').first().gifts
  </code></pre>
  
  <p>The above statements will return the same results</p>
  
  <p>My question is: how to configure that relationships "inside the classes" to make the above statements work?</p>
  
  <p>Thanks :)</p>