Hi, I have created two tables with one to many relationship. Let's say parent and child. i placed a foreign key in the child table referencing the parent. I would like to add a new column ( Foreign key) in parent table which references a subset of rows in child table depending on a child's table column value: let's say i want to reference the id of the eldest child of each parent ( is_first_born == True).
How can add i reference only one row with a foreign key in SQLAlchemy ? class Parent(Base): __tablename__ = 'parent' id = Column(Integer, primary_key=True) eldest_child_id = Column(Integer, ForeignKey('child.id')) class Child(Base): __tablename__ = 'child' id = Column(Integer, primary_key=True) is_first_born = Column(Boolean) parent_id = Column(Integer, ForeignKey('parent.id')) Thanks in advance. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.