So, if I understand your question correctly, you want to reference the currencies_many table from the orders table. If so, you are right about the relationship of the foreign key to the currencies_many table.
However, on the way you may encounter some problems when you want to request orders from the banks table. I would suggest that, although it seems redundant, to create a one-to-many relationship between Order and Bank , as well as between Order and Currency .
bank_id = db.Column(db.Integer, db.ForeignKey('bank.id')) currency_id = db.Column(db.Integer, db.ForeignKey('currency.id'))
And then in the Bank class
orders = db.relationship('Order', backref='bank')
This gives you a more intuitive query interface.
bank_orders = bank.orders
It also makes your data model cleaner. It would be inconvenient to request orders from the staging table, which also contains the currency. Only my two cents, but with ease to understand the data model, is better than creating an uncomfortable relationship to preserve some redundancy.
source share