Unit 4: Indexing and Aggregation Framework - Subjective Questions

CSE494 — Intelligent Nosql Databases • Practice Questions with Detailed Answers

20 questions

1

Define a single-field index in a NoSQL database such as MongoDB. Explain how it is created, how it supports query execution, and identify situations where it is most useful.

2

Explain compound indexes and describe how field order affects query performance. Use an example involving a compound index on department and salary.

3

Compare single indexes and compound indexes with respect to structure, supported queries, storage, sorting, and maintenance overhead.

4

What is a text index? Explain how it supports textual search, including tokenization, relevance, and language-related considerations.

5

Distinguish between a text index and a regular single-field index. Explain why a regular index is not a replacement for full-text search.

6

Explain how indexing improves database performance. Discuss selectivity, index traversal, document scanning, and the effect of indexes on write operations.

7

Describe the main stages of query execution that can be analyzed using explain(). Interpret the meaning of collection scans, index scans, and examined documents.

8

What is a covered query? State the conditions required for a query to be covered and explain its performance benefits and limitations.

9

Derive a method for evaluating whether an index is beneficial using explain() statistics. Include relevant ratios or comparisons and interpret their meaning.

10

Explain the concept of an aggregation pipeline. Describe how documents flow through stages and why the order of stages matters.

11

Explain the purpose of $match, $project, and $group stages in an aggregation pipeline. Provide a suitable example for each stage.

12

Describe the use of $sort, $limit, $unwind, and $lookup in aggregation pipelines. Mention one practical use case for each stage.

13

Construct an aggregation pipeline to calculate total sales and average order value for each product from documents containing productId, quantity, and unitPrice.

14

Explain how an aggregation pipeline can be used to produce a monthly revenue report. Include the operations needed to extract a month, group revenue, and sort the output.

15

Discuss the performance relationship between indexes and aggregation pipelines. Explain when an index can be used by $match and $sort stages.

16

Explain why excessive indexing can harm a NoSQL database. Discuss storage, write latency, memory pressure, and index redundancy.

17

Compare equality, range, and sorting predicates when designing a compound index. State a general rule for arranging fields and explain its limitations.

18

Explain how array fields affect indexing and aggregation. Discuss multikey indexes and the role of $unwind in processing arrays.

19

Design an aggregation pipeline that identifies the top three products by quantity sold from order documents containing an items array.

20

Explain the role of $lookup in real-world aggregation. Describe its benefits, limitations, and performance considerations when joining orders with customer data.