C100DBA · Question #101
A collection and a document in MongoDB is equivalent to which of the SQL concepts respectively?
The correct answer is B. Table and Row. In MongoDB, a collection maps to a SQL table - both are containers that group related records together. A MongoDB document maps to a SQL row - both represent a single record or entry within that container. Why the distractors are wrong: A (Column and Row): Reverses the analogy an
Question
A collection and a document in MongoDB is equivalent to which of the SQL concepts respectively?
Options
- AColumn and Row
- BTable and Row
- CDatabase and Table
- DTable and Column
How the community answered
(28 responses)- A7% (2)
- B86% (24)
- C4% (1)
- D4% (1)
Explanation
In MongoDB, a collection maps to a SQL table - both are containers that group related records together. A MongoDB document maps to a SQL row - both represent a single record or entry within that container.
Why the distractors are wrong:
- A (Column and Row): Reverses the analogy and misidentifies the collection - columns are individual fields within a record, not containers for records.
- C (Database and Table): Both MongoDB and SQL share the concept of a "database" at the top level, so this conflates two different levels of the hierarchy; a collection is inside a database, not equivalent to one.
- D (Table and Column): Correctly identifies "table" but maps a document to a column, which is backwards - a column is a single field, while a document contains many fields.
Memory tip: Think of it this way - a collection holds cards (documents), just like a table holds tuples (rows). The outer container = table/collection; the inner record = row/document.
Topics
Community Discussion
No community discussion yet for this question.