title: SQLAlchemy circular dependency - how to solve it?
body: <p>I have two tables, <code>News</code> and <code>Files</code>:</p>
  
  <pre><code># unrelated columns removed
  class News(db.Model): 
      id = db.Column(db.Integer, primary_key=True)
      file_id_logo = db.Column(db.Integer, db.ForeignKey('files.id'))
      logo = db.relationship('File', lazy=False)
  
  class File(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      news_id = db.Column(db.Integer, db.ForeignKey('news.id'))
      news = db.relationship('News', lazy=False, backref=db.backref('files'))
  </code></pre>
  
  <p>After adding the <code>file_id_logo</code> fkey, SQLalchemy raised a CircularDependencyError.
  I've already tried <code>post_update=True</code> in the <code>logo</code> relation, but it did not change anything.</p>
  
  <p>What's the proper way to solve this?</p>
  
  <p>The following cases are possible (in case it matters):</p>
  
  <ul>
  <li>A File has no or exactly one News assigned.</li>
  <li>If a File has no News, there's also no News with this file referenced as its logo.</li>
  <li>There can be multiple Files for a single News, but only one of these Files can be its <code>logo</code>.</li>
  <li>So if a News has a <code>logo</code>, the referenced File also has this news as its <code>news</code>.</li>
  </ul>