From 3e445a31334ddb48583f82f3a6ddd4a3f9289ee5 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 22 Dec 2019 10:22:46 +0000 Subject: [PATCH] Add a foreign key to the triple table. --- depicts/model.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/depicts/model.py b/depicts/model.py index b23c3c1..3c92751 100644 --- a/depicts/model.py +++ b/depicts/model.py @@ -105,10 +105,14 @@ class Item(Base): class Triple(Base): __tablename__ = 'triple' - subject_id = Column(Integer, primary_key=True) + subject_id = Column(Integer, + ForeignKey('item.item_id'), + primary_key=True) predicate_id = Column(Integer, primary_key=True, index=True) object_id = Column(Integer, primary_key=True, index=True) + subject = relationship('Item', backref='triples') + class HumanItem(Base): __tablename__ = 'human' item_id = Column(Integer, primary_key=True, autoincrement=False)