11. How can you fetch data from a result set obtained through an execute() command? A. Using the get() method B. By calling fetch() C. By iterating through the result set D. By using the fetch_data() function Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C Solution: Data from a result set is typically fetched by iterating through the result set using loops.
12. What does the commit() method do in the context of database transactions? A. It creates a new database B. It inserts new records into the database C. It saves changes made during a transaction D. It cancels a transaction Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C Solution: The commit() method saves the changes made during a database transaction.
13. What is an ORM (Object-Relational Mapping) in database connectivity? A. A way to create images from databases B. A programming language for databases C. A technique to map database tables to object-oriented classes D. A tool for compressing database files Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C Solution: ORM is a technique that maps database tables to object-oriented programming classes, simplifying database interactions.
14. Which ORM library is popular for Python database connectivity? A. SQLLink B. ORMpy C. SQLAlchemy D. PyORM Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C Solution: SQLAlchemy is a widely used ORM library for Python, supporting various database management systems.
15. How do you define a class that maps to a database table using SQLAlchemy? A. By subclassing the Database class B. By using the @database_table decorator C. By inheriting from the Base class and defining attributes D. By using the map_table() function Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C Solution: In SQLAlchemy, you inherit from the Base class and define attributes to map a class to a database table.
16. What is a primary key in a database table? A. A key used to access the database B. A unique identifier for each row C. A password for the database D. A column used for calculations Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B Solution: A primary key is a unique identifier for each row in a database table.
17. What is the role of a foreign key in a relational database? A. To prevent unauthorized access B. To ensure data integrity and relationships C. To index the database table D. To encrypt data Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B Solution: A foreign key is used to establish relationships between tables, ensuring data integrity and referential integrity.
18. What does the term "CRUD" stand for in the context of databases? A. Create, Read, Update, Delete B. Control, Remove, Update, Deliver C. Copy, Read, Upload, Delete D. Create, Retrieve, Upload, Deliver Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
19. How can you update data in a database table using SQL? A. Using the UPDATE statement B. Using the MODIFY statement C. Using the ALTER statement D. Using the EDIT statement Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A Solution: The UPDATE statement is used to modify data in a database table.
20. What is the purpose of a stored procedure in a database? A. To store data backups B. To define data types C. To encapsulate SQL code for reuse D. To generate random data Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C Solution: A stored procedure is a precompiled collection of SQL statements that can be reused and executed in a database.