Database Trigger :
a. What is a database trigger, and what is its primary purpose in a relational database system? Provide an example scenario where a trigger might be useful, and explain how it would work.
Database Joins:
a. Explain the different types of joins commonly used in SQL, including INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN. Provide an example for each type of join and describe the results you would expect to obtain.
Views:
a. Create a view that combines data from two different tables in your database. Explain the purpose of this view and provide the SQL statement to create it. Then, demonstrate how to query this view to retrieve specific information from the underlying tables.
Cursors:
a. Write a SQL cursor to iterate through a result set and perform an action for each row. Provide a specific use case for using a cursor in a database application, and explain how the cursor would be implemented and executed in that context.
Inserting and Saving Documents:
a. Describe the process of batch inserting multiple documents into a MongoDB collection. Provide a step-by-step example of how you would batch insert data and explain any considerations for performance and efficiency.
Removing and Updating Documents:
a. Explain the difference between document replacement and using modifiers when updating documents in MongoDB. Provide a practical example for each approach, including the relevant MongoDB query or command for both document replacement and modifier-based updates.
Certainly, here are two questions related to executing MongoDB queries that demonstrate various querying techniques:
1. Query Criteria and Cursors:
a. Describe the use of MongoDB query conditionals, such as `$eq`, `$gt`, `$lt`, and `$in`. Provide an example where you need to find documents that meet specific criteria using these conditionals. Additionally, show how you can limit the number of returned documents using the `limit` and `skip` options.
2. Advanced Query Options and Database Commands:
a. Explore the use of database commands in MongoDB. Explain the purpose and syntax of a specific MongoDB database command, such as `db.collection.createIndex()` or `db.collection.aggregate()`. Provide a practical example where this command is useful and describe the expected outcomes when using it in a MongoDB database.