SQLAlchemy how to define multiple foreign keys in a table

if there are multiple foreign keys in a table, such as student table, course table and score table, is it correct for me to define it this way?

class Student(Base):
    __tablename__ = "students"
    id = Column(Integer, primary_key=True)
    name = Column(String(20), nullable=False, index=True)
    sex = Column(Integer, nullable=True)
    score = relationship("Score", backref="student")

class Subject(Base):
    __tablename__ = "subjects"
    id = Column(Integer, primary_key=True)
    Name = Column(String(10), nullable=False, index=True)
    score = relationship("Score", backref="score")

class Score(Base):
    __tablename__ = "score"
    id = Column(Integer, primary_key=True)
    score = Column(Integer, nullable=False)
    subject_id = Column(Integer, ForeignKey("subjects.id"))
    student_id = Column(Integer, ForeignKey("students.id"))

how do I add student information and score information at the same time?

Jul.18,2022
Menu