Question 30
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')Consider ‘C1’, an instance of table ‘category’ whose category_id is 2. The correct way of adding a product ‘compass’ to this category is: