我有以下表格(非常简明的版本):
class Profile(Base):
__tablename__ = profile
id = Column(Integer, primary_key = True)
name = Column(String(65), nullable = False)
def __init__(self, name):
self.name = name
class Question(Base):
__tablename__ = question
id = Column(Integer, primary_key = True)
description = Column(String(255), nullable = False)
number = Column(Integer, nullable = False, unique = True)
def __init__(self, description, number):
self.description = description
self.number = number
class Answer(Base):
__tablename__ = answer
profile_id = Column(Integer, ForeignKey( profile.id ), primary_key = True)
question_id = Column(Integer, ForeignKey( question.id ), primary_key = True)
value = Column(Integer, nullable = False)
def __init__(self, profile_id, question_id, value):
self.profile_id = profile_id
self.question_id = question_id
self.value = value
概况通过许多与人的关系与问题挂钩。 在连接表(Answer)中,我需要储存答案的价值。
这些文件说,我需要使用一个协会反对这样做,但它使我感到困惑,我不得不这样做。
我如何用回答作为中间表格来界定简介和问答表的许多对人的关系?