Question 29
Consider the following tables ‘product’ and ‘category’ that represent models ‘Product’ and ‘Category’ in SQLite database and answer the given subquestions.
class Product(db.Model): product_id = db.Column(db.Integer(), primary_key = True) product_name = db.Column(db.String(50), unique = True) category = db.Column(db.Integer(),db.ForeignKey('category.category_id')) cat = db.relationship('Category', back_populates = 'products')
class Category(db.Model): category_id = db.Column(db.Integer(), primary_key = True) category_name = db.Column(db.String(50), unique = True) products = db.relationship('Product', back_populates = 'cat')Which of the following statements about the tables ‘product’ and ‘category’ is correct?
Multiple instances of Product can belong to a single instance of Category.
Multiple instances of Category can belong to a single instance of Product but the converse in not true.
Multiple instances of Product can belong to a single instance of Category and vice versa.
One instance of Category can belong to any one instance of Product only.