Question 2
Consider the below flask_sqlalchemy data models “Product”, “Supplier” and “Supply” given in the code below.
class Product(db.Model): __tablename__ = "product" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String, nullable=False)
class Supplier(db.Model): __tablename__ = "supplier" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String, nullable=False) address = db.Column(db.String, nullable=True)
class Supply(db.Model): __tablename__ = "supply" id = db.Column(db.Integer, primary_key=True) product_id = db.Column(db.Integer, db.ForeignKey("product.id")) supplier_id = db.Column(db.Integer, db.ForeignKey("supplier.id"))What will be the cardinality of the “Product” and “Supplier” relationship?
One to One
One to Many
Many to Many
Many to One