Faculty of Engineering and Mathematical Sciences 
Not logged in (login)


This forum is provided to promote discussion amongst students enrolled in Agile Web Development (CITS3403).
RSS cloud
Jump to:

Database Schema

1 of 419 articles shown, currently no other people reading this forum.
Date: Mon 11th May 2020, 10:02am


Hey Tim,

I'm trying to implement such schema so that Question can have many Options and 
correct_option_id can only have 1 correct answer. But this gave me an error:

"Could not determine join condition between parent/child tables on relationship 
Question.options - there are multiple foreign key paths linking the tables.  Specify the 
'foreign_keys' argument, providing a list of those columns which should be counted as 
containing a foreign key reference to the parent table."

Do I need many-to-many relationship?

class Question(db.Model):
    __tablename__ = 'question'
    id = db.Column(db.Integer, primary_key=True)
    set_id = db.Column(db.Integer, db.ForeignKey('set.id'))
    question_text = db.Column(db.Text)
    correct_option_id = db.Column(db.Integer, db.ForeignKey('option.id'))
    options = db.relationship('Option', backref='question', lazy='dynamic')
class Option(db.Model):
    __tablename__ = 'option'
    id = db.Column(db.Integer, primary_key=True)
    question_id = db.Column(db.Integer, db.ForeignKey('question.id'))
    option_text = db.Column(db.Text)

Related articles

Database Schema (all 6) RSS
├─ original   Tue 5th May 2020, 3:35pm, ANONYMOUS
├─ reply 1   Wed 6th May 2020, 10:59am, Takoyaki N.
├─ reply 2   Wed 6th May 2020, 12:13pm, Timothy F.
├─ THIS   Mon 11th May 2020, 10:02am, ANONYMOUS
├─ reply 4   Wed 13th May 2020, 12:37pm, Takoyaki N.
└─ reply 5   Wed 13th May 2020, 1:16pm, Timothy F.
This Page

Program written by: [email protected]
Feedback welcome
Last modified: 11:27am Sep 21 2020