class Item(db.Model):
id = db.Column(db.Integer, primary_key=True)
# ... other columns ...
main_image = db.relationship(db.Integer, db.ForeignKey('image.id', nulllable=True))
class Image(db.Model):
id = db.Column(db.Integer, primary_key=True)
# ... other columns ...
item_id = db.Column(db.Integer, db.ForeignKey(Item.id), nullable=True)
item = db.relationship(Item, backref='images')