class Membership(db.Model):
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True)
team_id = db.Column(db.Integer, db.ForeignKey('team.id'), primary_key=True)
role_id = db.Column(db.Integer, db.ForeignKey('role.id'), primary_key=True)
How to three-way many-to-many relationship in flask-sqlalchemy