title: How to query a parent based on a childs length in sqlalchemy
body: <p>i have a the following model:</p>
  
  <pre><code>class Tables(db.Model):  # fixme: rename the table name to table.
      __tablename__ = "tables"
      id = db.Column(db.Integer, primary_key=True)
      store_id = db.Column(db.Integer)
      name = db.Column(db.String(64))
      active = db.Column(db.Integer, default=0)
      orders = db.relationship("Order", backref='table', lazy='dynamic')
  </code></pre>
  
  <p>So far i have this.</p>
  
  <pre><code>tables = Tables.query.filter_by(store_id=1).all()  
  
  free_tables = []
  for table in tables:
      if len(table.orders.all()) == 0:
          free_tables.append(table.id)
  </code></pre>
  
  <p>what i want are the ids of the tables that have no orders bound to them. Is there a way to write this in a single line? thank you.</p>