Data Models Questions with Answers

27 practice questions on Data Models (NoSQL & MongoDB) with answers and step-by-step solutions. Try 10 samples below, then practise all 27 free in the AptiNest app.

Sample questions

Question 1Easy

In MongoDB, a row of a relational table most closely corresponds to a:

  1. Collection of documents
  2. Database instance
  3. Cursor over results
  4. Document

Answer: D. Document

Explanation

Each record is a document made of field-value pairs.

Step-by-step solution

  1. A row in a relational table is a single record.
  2. In MongoDB, a single record is called a document.
  3. Documents contain field-value pairs like rows in tables.
  4. Collections hold multiple documents similar to tables holding rows.
  5. So, a row corresponds to a document.

Why the other options are wrong

  • A. A collection is a group of documents, so it is closer to a table than to one row.
  • B. A database instance holds many collections; it is larger than a single row.
  • C. A cursor is the result of a query being iterated, not a stored record in a table.

Question 2Easy

What format does MongoDB use internally to store documents?

  1. XML
  2. BSON
  3. CSV
  4. YAML

Answer: B. BSON

Explanation

BSON is a binary-encoded serialization of JSON-like documents with extra types such as Date and ObjectId.

Step-by-step solution

  1. MongoDB stores data in a format similar to JSON.
  2. This format is called Binary JSON or BSON.
  3. BSON includes additional data types like Date and ObjectId.
  4. So, MongoDB uses BSON internally.
  5. Final answer: B (BSON).

Why the other options are wrong

  • A. XML is a text markup format, not the binary format MongoDB stores documents in.
  • C. CSV has no nested fields, so it cannot be MongoDB's internal document format.
  • D. YAML is a text format for config files, not MongoDB's internal storage format.

Tip: Remember BSON is the internal format for MongoDB.

Question 3Easy

MongoDB stores documents on disk in which binary format?

  1. JSON text
  2. XML
  3. BSON
  4. CSV

Answer: C. BSON

Explanation

MongoDB stores documents in BSON, a binary superset of JSON that adds types such as Date and ObjectId.

Step-by-step solution

  1. Documents are written by clients as JSON-like objects.
  2. The server serialises them to BSON.

Why the other options are wrong

  • A. BSON is binary, not plain JSON text.
  • B. XML is not used for storage.
  • D. CSV cannot hold nested documents.

Question 4Easy

Which of these is a typical use case for a graph database such as Neo4j?

  1. Finding friends-of-friends in a social network
  2. Storing simple session tokens
  3. Bulk numeric aggregation over billions of rows
  4. Storing large video files

Answer: A. Finding friends-of-friends in a social network

Explanation

Graph databases store relationships as first-class data, making multi-hop traversals efficient.

Step-by-step solution

  1. Graph databases excel at storing and querying relationships.
  2. Finding friends-of-friends requires checking connections between users.
  3. This is a natural fit for graph traversal queries.
  4. Storing session tokens needs key-value storage, not graphs.
  5. Bulk numeric aggregation uses columnar databases, not graphs.
  6. Storing video files needs object storage, not graphs.

Why the other options are wrong

  • B. Simple session tokens are key lookups, so they do not need a graph's relationship traversal.
  • C. Bulk numeric aggregation over huge tables is a column-store or warehouse job, not a graph's.
  • D. Video files are large binary blobs and belong in object storage, not a graph database.

Tip: Use graph databases when your data is relationship-rich and requires efficient traversal.

Question 5Medium

A schema validator with $jsonSchema in MongoDB does what?

  1. Rejects or warns on documents that do not match defined rules
  2. Creates new tables for each document type found in the collection
  3. Locks field types forever so they can never change
  4. Replicates the data to other members

Answer: A. Rejects or warns on documents that do not match defined rules

Explanation

validationAction can error or warn.

Step-by-step solution

  1. Define rules on the collection.

Why the other options are wrong

  • B. MongoDB has no tables; $jsonSchema validates documents in a collection.
  • C. $jsonSchema does not lock field types forever.
  • D. Validation rules do not replicate data to other members.

Question 6Medium

A wide-column store such as Cassandra organises data primarily by which structure?

  1. Foreign keys between tables, joined at read time by the storage engine
  2. A single global B-tree of all rows
  3. Nested JSON documents
  4. Partition key then clustering columns within a row group

Answer: D. Partition key then clustering columns within a row group

Explanation

Rows are placed on nodes by the partition key and sorted inside the partition by clustering columns.

Step-by-step solution

  1. Hash the partition key to find the node.
  2. Within the partition, order by clustering columns.

Why the other options are wrong

  • A. Cassandra has no foreign keys.
  • B. Data is distributed, not one global tree.
  • C. Documents are the MongoDB model.

Question 7Medium

In MongoDB document modelling, when is embedding a sub-document usually preferred over referencing?

  1. When the child array can grow without limit
  2. When many parents share one huge child
  3. When child data is read with the parent and is bounded
  4. When the child must be updated independently by many documents

Answer: C. When child data is read with the parent and is bounded

Explanation

Embedding gives one-read access for data that belongs together, but unbounded growth or heavy sharing favours references.

Step-by-step solution

  1. Embedding is used when child data is accessed with the parent.
  2. Bounded child data fits well in embedded documents.
  3. Reading child data with parent reduces database queries.
  4. Unbounded growth or shared data needs references instead.
  5. Final answer: When child data is read with the parent and is bounded.

Why the other options are wrong

  • A. An array that grows without limit should be referenced, since embedded arrays cannot grow unbounded.
  • B. When many parents share one large child, referencing avoids duplicating that child in each parent.
  • D. A child updated independently by many documents is better kept in its own collection.

Tip: Use embedding for small, related data; use references for big or shared data.

Question 8Medium

Which type of NoSQL store is best suited to model friend-of-friend relationships with variable depth?

  1. Graph database
  2. Key-value store
  3. Wide-column store
  4. Document store

Answer: A. Graph database

Explanation

Graph databases store relationships as first-class edges so multi-hop traversals are cheap.

Step-by-step solution

  1. Relationships with variable depth need traversal.
  2. Graph stores traverse edges natively.

Why the other options are wrong

  • B. Key-value lookups cannot traverse.
  • C. Wide-column suits time-series and big writes.
  • D. Documents need repeated lookups for hops.

Question 9Medium

What is the difference between embedding and referencing?

  1. Embedding uses foreign key constraints enforced by the server, while referencing stores copies of the data
  2. Referencing nests the related data inside the parent document
  3. They are the same technique with different names
  4. Embedding nests data in one document; referencing stores an id pointing to another document

Answer: D. Embedding nests data in one document; referencing stores an id pointing to another document

Explanation

References require a second query or $lookup.

Step-by-step solution

  1. Embed = same doc.
  2. Reference = id link.

Why the other options are wrong

  • A. No constraints in MongoDB.
  • B. Referencing stores ids; embedding is what nests related data.
  • C. Embedding and referencing are different designs, not the same.

Question 10Medium

Why are NoSQL databases often described as schema-flexible?

  1. They cannot store any structured data at all
  2. Documents in one collection may differ in fields
  3. They forbid any validation
  4. They always require a fixed column list

Answer: B. Documents in one collection may differ in fields

Explanation

Many NoSQL stores do not force every record to share one structure, though optional validation is possible.

Step-by-step solution

  1. NoSQL databases do not require one fixed schema for all records.
  2. Documents in the same collection can have different fields.
  3. So the answer is option B.

Why the other options are wrong

  • A. NoSQL databases can store structured data, usually as documents.
  • C. Many NoSQL databases support validation rules, so validation is not forbidden.
  • D. A fixed column list is the relational model, not the flexible NoSQL model.

Tip: Schema-flexible does not mean no structure; the application still needs to keep fields consistent.

Practise all 27 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all NoSQL & MongoDB topics · All topics