Unit 3: Schema Design and Data Modeling - Practice Quiz

CSE494 — Intelligent Nosql Databases 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What does MongoDB's schema-less nature allow?

Schema-less Nature of MongoDB Easy
A. Documents in a collection can have different fields
B. Collections can contain only identical documents
C. Documents can store only text values
D. Databases can have only one collection

2 Which data format does MongoDB use to store documents internally?

Schema-less Nature of MongoDB Easy
A. XML
B. YAML
C. BSON
D. CSV

3 In MongoDB, what is a collection?

Schema-less Nature of MongoDB Easy
A. A link between two servers
B. A group of related documents
C. A rule for sorting values
D. A single field in a document

4 What does embedding mean in MongoDB data modeling?

Embedding vs. Referencing Easy
A. Deleting repeated fields from documents
B. Storing related data inside one document
C. Storing related data on another server
D. Creating separate databases for each field

5 What does referencing mean in MongoDB?

Embedding vs. Referencing Easy
A. Combining every collection into one document
B. Connecting documents by storing an identifier
C. Converting document fields into indexes
D. Copying all data into each collection

6 When is embedding commonly preferred?

Embedding vs. Referencing Easy
A. When the nested array grows without limit
B. When documents belong to separate databases
C. When related data changes independently
D. When related data is usually read together

7 Which example represents a one-to-one relationship?

One-to-One Relationships Easy
A. One store and many products
B. One teacher and many students
C. Many authors and many books
D. One employee and one ID card

8 How can a one-to-one relationship be modeled when both records are commonly accessed together?

One-to-One Relationships Easy
A. Store each record in a database
B. Place each field in a collection
C. Duplicate both records repeatedly
D. Embed one record in the other

9 Which example represents a one-to-many relationship?

One-to-Many Relationships Easy
A. One citizen and one passport
B. One product and one serial number
C. Many students and many courses
D. One customer and many orders

10 How can a small, bounded one-to-many relationship be stored in MongoDB?

One-to-Many Relationships Easy
A. Create one database per item
B. Store every value as plain text
C. Remove the relationship identifiers
D. Embed the many items in an array

11 When is referencing often preferred for a one-to-many relationship?

One-to-Many Relationships Easy
A. When the number of related items can grow greatly
B. When the related data always remains very small
C. When the relationship has exactly one item
D. When all values fit in a single nested object

12 Which example represents a many-to-many relationship?

Many-to-Many Relationships Easy
A. One city and many streets
B. One user and one profile
C. Many students and many courses
D. One author and many drafts

13 What is a common way to model a many-to-many relationship in MongoDB?

Many-to-Many Relationships Easy
A. Create one server for each relationship
B. Remove identifiers from related documents
C. Store arrays of related document identifiers
D. Store all records in one text field

14 What should primarily guide a MongoDB data model?

Data Modeling Best Practices Easy
A. The alphabetical order of fields
B. The application's data access patterns
C. The number of database users
D. The length of collection names

15 Why should unbounded arrays generally be avoided?

Data Modeling Best Practices Easy
A. They can make documents grow excessively
B. They prevent documents from having identifiers
C. They automatically delete older documents
D. They allow only numeric field values

16 What is denormalization in MongoDB data modeling?

Data Modeling Best Practices Easy
A. Duplicating selected data to improve reads
B. Removing all indexes from collections
C. Encrypting every field before storage
D. Splitting each document into databases

17 In a blog application, where can a small number of comments be stored when they are always shown with a post?

Case Studies and Examples Easy
A. Inside the user password field
B. Inside the post document
C. Inside the database settings
D. Inside the collection name

18 In an online store, why might products be referenced from orders instead of fully embedded?

Case Studies and Examples Easy
A. Collections cannot store product names
B. Orders cannot store nested documents
C. Products cannot contain text fields
D. Products may be shared across many orders

19 What is the purpose of schema validation in MongoDB?

Validation Rules and Constraints Easy
A. To sort all documents by _id
B. To rename collections automatically
C. To enforce rules on document structure
D. To create backups after every query

20 Which MongoDB feature can define validation rules for fields?

Validation Rules and Constraints Easy
A. JSON Schema
B. HTML Form
C. CSV Header
D. DNS Record

21 A MongoDB collection stores products from several categories. Books have an author field, while laptops have a processor field. What does MongoDB's schema-less nature allow in this situation?

Schema-less Nature of MongoDB Medium
A. Documents may contain different fields in the same collection
B. Every document must contain both category-specific fields
C. Fields are automatically moved into separate collections
D. Field differences are allowed only for unindexed data

22 An application stores price as a number in some documents and as a string in others. A range query produces unreliable results. What is the best design response?

Schema-less Nature of MongoDB Medium
A. Store price consistently as a numeric type
B. Move each price type to a separate database
C. Convert every numeric price into an array
D. Remove the price field from all indexes

23 A user profile has one shipping address that is small, displayed with the profile, and rarely updated separately. Which model is most suitable?

Embedding vs. Referencing Medium
A. Reference the address from a separate collection
B. Store the user inside the address document
C. Duplicate the address across multiple databases
D. Embed the address inside the user document

24 Thousands of orders may refer to the same customer, and customer contact details change regularly. Which approach best avoids widespread duplicate updates?

Embedding vs. Referencing Medium
A. Embed the complete customer in each order
B. Store all orders inside the customer name field
C. Create a new customer document for every order
D. Reference the customer from each order

25 A blog post contains an embedded array of comments that can grow without a practical limit. What is the primary modeling concern?

Embedding vs. Referencing Medium
A. The post document may become excessively large
B. The comments automatically lose their identifiers
C. The post can no longer contain scalar fields
D. The comments become relational database rows

26 An employee has exactly one security profile. The security profile is sensitive, accessed only by administrators, and updated independently. How should it usually be modeled?

One-to-One Relationships Medium
A. Duplicate it in all department documents
B. Store it separately with an employee reference
C. Combine all profiles into one global array
D. Embed it in every employee query result

27 A vehicle document has one engine specification object that is always displayed with the vehicle and cannot exist independently. Which design is most appropriate?

One-to-One Relationships Medium
A. Create one collection for each engine property
B. Embed the engine specification in the vehicle
C. Reference an engine collection from the vehicle
D. Store the vehicle identifier inside every engine field

28 A department has at most eight employees, and the department page always displays basic employee details. Which model favors a single read?

One-to-Many Relationships Medium
A. Store departments and employees in unrelated databases
B. Create a department document for each employee
C. Embed a bounded employee array in the department
D. Reference the department from separate employee records

29 A sensor produces millions of readings over time. Each reading belongs to one sensor, but readings are queried by date range. Which model is most scalable?

One-to-Many Relationships Medium
A. Store only the latest reading for each sensor
B. Duplicate each sensor for every date range
C. Store readings separately with a sensor reference
D. Embed all readings in one sensor document

30 Orders embed line items because they are usually retrieved together. A product's name may later change, but old orders must preserve the purchased name. What should each line item store?

One-to-Many Relationships Medium
A. The names of every product in the catalog
B. Only a live reference to the current product name
C. No product information beyond the order identifier
D. A snapshot of the product name at purchase time

31 Students can enroll in many courses, and each course can contain many students. Enrollment also stores grade and enrolledAt. What is the best model?

Many-to-Many Relationships Medium
A. Store grades directly in the database name
B. Embed every student document inside each course
C. Use an enrollment collection referencing both entities
D. Embed every course document inside each student

32 Articles can have many tags, and tags can belong to many articles. The application mainly retrieves articles by tag. Which index is most useful when article documents store an array named tagIds?

Many-to-Many Relationships Medium
A. A geospatial index on tagIds
B. A multikey index on tagIds
C. A TTL index on the article title
D. A text index on article _id

33 Authors and books have a many-to-many relationship. Book pages are requested far more often than author pages, and each book has only a few authors. Which representation best supports the main access pattern?

Many-to-Many Relationships Medium
A. Create a separate database for each author
B. Place all authors and books in one document
C. Store complete books inside every author document
D. Store author references in each book document

34 A team is designing a MongoDB schema for an analytics application. Which factor should most strongly influence whether related data is embedded or referenced?

Data Modeling Best Practices Medium
A. The application's common query and update patterns
B. The alphabetical order of collection names
C. The number of developers using the database
D. The visual length of the document fields

35 A collection frequently executes queries using customerId and a descending createdAt sort. Which index is the best starting choice?

Data Modeling Best Practices Medium
A. A TTL index on { createdAt: 1 }
B. A text index on { customerId: "text" }
C. A single-field index on { status: 1 }
D. A compound index on { customerId: 1, createdAt: -1 }

36 A customer document contains a growing orders array, causing frequent document movement and slow updates. Which redesign is most appropriate?

Data Modeling Best Practices Medium
A. Duplicate the customer document for each update
B. Increase every order field to a larger data type
C. Replace the orders array with one long string
D. Move orders to a collection with customerId references

37 An e-commerce order must preserve item prices as they were at checkout, even if catalog prices later change. Which schema feature best meets this requirement?

Case Studies and Examples Medium
A. Embed the checkout price in each order item
B. Calculate all historical prices from product ratings
C. Read the current price from the product collection
D. Store one current price in the customer document

38 A social application displays a user's latest 10 notifications on every login but retains older notifications for auditing. Which design balances fast access and long-term growth?

Case Studies and Examples Medium
A. Embed recent notifications and reference archived ones
B. Delete every notification after it has been displayed
C. Embed all notifications forever in the user document
D. Store all users' notifications in one shared array

39 A collection validator uses $jsonSchema to require email and specify that it must be a string. Which document violates the validator?

Validation Rules and Constraints Medium
A. { "name": "Ravi", "email": 42 }
B. { "email": "sam@example.com", "age": 21 }
C. { "email": "lee@example.com", "active": true }
D. { "name": "Ravi", "email": "ravi@example.com" }

40 A team adds a validator to a collection containing legacy documents. It wants new and modified documents checked, while existing documents may remain unchanged until updated. Which validationLevel should be used?

Validation Rules and Constraints Medium
A. off
B. warning
C. moderate
D. strict

41 A rolling deployment changes customer.address from a string to an object. Millions of legacy documents still use the old representation, and deployments cannot pause writes. Which migration strategy best preserves availability and schema correctness?

Schema-less Nature of MongoDB Hard
A. Backfill while old writers remain active, then deploy readers that support only the new representation.
B. Require the object representation immediately, reject legacy documents, and backfill after deployment.
C. Write both representations indefinitely, query either representation, and avoid adding schema validation.
D. Read both representations, write the new representation, backfill legacy data, then tighten validation.

42 A collection stores purchase, login, and shipment events with different required fields. Queries always specify the event type before filtering subtype-specific fields. Which design best supports controlled polymorphism and efficient indexing?

Schema-less Nature of MongoDB Hard
A. Use a discriminator, type-specific validation branches, and partial indexes restricted by event type.
B. Store each event as an encoded string, validate it in application code, and index the entire string.
C. Use no discriminator, infer each subtype from its fields, and create global indexes for every field.
D. Place subtype fields in one fixed structure, assign missing fields null, and use sparse indexes.

43 An amount field contains integers, decimal values, and numeric strings because different application versions wrote different BSON types. Range queries and sorting must have numeric semantics. What is the most robust remedy?

Schema-less Nature of MongoDB Hard
A. Add separate indexes for every BSON type and merge the independently sorted result sets.
B. Convert query boundaries to strings because lexical ordering is equivalent for all numeric values.
C. Rely on BSON type ordering and convert each result to a number after the query completes.
D. Normalize stored values to one numeric type and add validation preventing incompatible future values.

44 A popular article can receive millions of comments. Comments are paginated, moderated independently, and rarely fetched with the article body. Which model is most appropriate?

Embedding vs. Referencing Hard
A. Embed every comment in the article and use array slicing to return each requested page.
B. Store article identifiers inside one global comments array and scan it for matching comment entries.
C. Embed recent comments and permanently discard older comments when the array reaches a fixed size.
D. Store comments separately with articleId and index the fields used for pagination and moderation.

45 An order service must atomically append a line item and update the order's stored subtotal without using a multi-document transaction. Which model directly enables this guarantee?

Embedding vs. Referencing Hard
A. Embed order identifiers in line items and calculate the subtotal whenever the order is subsequently read.
B. Embed line items in the order and update the array and subtotal in one document operation.
C. Reference line-item documents and update the order subtotal through a later change-stream consumer.
D. Reference line-item documents and issue two unordered writes using the same application request identifier.

46 Each employee has at most one security-clearance record. Clearance data is large, rarely read, and protected by stricter authorization than ordinary employee data. Which design best matches these requirements?

One-to-One Relationships Hard
A. Embed clearance data in every employee document and exclude it through projections for ordinary reads.
B. Store clearance data separately, reference the employee, and enforce a unique index on employeeId.
C. Store employee data inside the clearance document and duplicate it whenever employee information changes.
D. Place both records in one polymorphic collection without a discriminator or relationship constraint.

47 A users collection and a profiles collection implement an optional one-to-one relationship. Which database mechanism guarantees that no user can have two profile documents, assuming profiles store userId?

One-to-One Relationships Hard
A. A sparse index on users._id, combined with application-side checking before inserting a profile.
B. A regular index on profiles.userId, combined with a schema validator requiring an object identifier.
C. A schema validator on users._id, combined with majority read concern during profile creation.
D. A unique index on profiles.userId, with an appropriate partial filter if the field is optional.

48 A sensor emits 20 readings per second indefinitely. Each reading averages 400 bytes before indexing, and most queries retrieve 15-minute intervals. Which model best controls document growth while preserving locality?

One-to-Many Relationships Hard
A. Store one ever-growing bucket per sensor and rely on compression to avoid the BSON document size limit.
B. Create bounded time buckets containing about readings per sensor and interval.
C. Embed all readings in the sensor document because one-to-many relationships should always be colocated.
D. Create one document per reading and omit the sensor identifier because timestamps uniquely identify readings.

49 A customer can have at most 12 delivery addresses. Addresses are owned exclusively by that customer, usually loaded with the customer, and updated together with customer preferences. Which model is strongest?

One-to-Many Relationships Hard
A. Place all customers' addresses in one shared document grouped by postal code.
B. Store addresses separately and execute a $lookup for every customer read.
C. Store customer data inside each address and select an arbitrary address as canonical.
D. Embed the addresses as a bounded array within the customer document.

50 Support tickets belong to one account at a time but are frequently reassigned, queried independently, and retained after an account is deleted. Which representation best supports these operations?

One-to-Many Relationships Hard
A. Store tickets separately with accountId and index fields such as accountId and status.
B. Duplicate complete ticket documents in both the old and new accounts whenever reassignment occurs.
C. Store ticket identifiers in account arrays and use those arrays as the only ownership records.
D. Embed tickets in account documents and move array elements between accounts during reassignment.

51 Students enroll in courses, and each enrollment has grade, enrolledAt, and status. The system must prevent duplicate active enrollment pairs and query efficiently from either side. Which design is best?

Many-to-Many Relationships Hard
A. Use an enrollment collection with a unique compound student-course index and a reverse lookup index.
B. Embed complete course documents in students and complete student documents in courses for every enrollment.
C. Store only student identifiers in courses and scan every course when retrieving one student's enrollments.
D. Store only course identifiers in students and calculate enrollment attributes from the array positions.

52 An undirected friendship must treat (A, B) and (B, A) as the same relationship while rejecting self-friendship. Which representation enforces this most reliably?

Many-to-Many Relationships Hard
A. Store identifiers in arbitrary order and create separate unique indexes on each individual identifier.
B. Store both directional documents and periodically remove duplicates using a scheduled aggregation.
C. Store friend identifiers in both user documents and rely on application retries to preserve symmetry.
D. Store the lower identifier first, add a unique compound index, and reject equal identifiers.

53 A proposed enrollment document contains both a studentIds array and a courseIds array. The team wants one compound index covering both fields. What is the best redesign?

Many-to-Many Relationships Hard
A. Create one enrollment edge per student-course pair and index the two scalar identifiers.
B. Convert both arrays to comma-separated strings and create a compound text index over the strings.
C. Retain both arrays and use a wildcard index because wildcard indexes remove parallel-array restrictions.
D. Retain both arrays and declare the compound index as sparse so MongoDB ignores excess array entries.

54 A messaging system stores millions of messages per conversation. The dominant query retrieves the newest 50 messages for one conversation, while participant metadata is small and stable. Which model and index best fit the query?

Data Modeling Best Practices Hard
A. Store all messages in daily global documents and index each day's embedded message array.
B. Embed every message in the conversation and index the nested message timestamp array.
C. Store messages separately and index {conversationId: 1, createdAt: -1}.
D. Store each participant's copy of every message and index only the sender identifier.

55 A service maintains a materialized event counter, but event delivery is at least once and consumers may retry after uncertain failures. Which design best prevents double counting?

Data Modeling Best Practices Hard
A. Increment the counter for every delivery and periodically estimate duplicates from matching timestamps.
B. Read the counter before every increment and reject an event when the counter has recently changed.
C. Insert a unique event marker and increment the counter in one transaction only for a new marker.
D. Use an atomic counter increment because atomicity automatically deduplicates repeated event identifiers.

56 An e-commerce order must preserve the product name, tax category, and unit price as they existed at checkout, while still allowing navigation to the current product. Which model is most appropriate?

Case Studies and Examples Hard
A. Store only productId and always join the current product record when displaying historical orders.
B. Store only the product name and price because retaining a product identifier creates unnecessary coupling.
C. Embed a purchase-time product snapshot in each line item and retain productId as a reference.
D. Embed the complete current product record and synchronize every historical order after product updates.

57 A social network precomputes home feeds. Fan-out-on-write works for ordinary accounts, but celebrity posts would require millions of immediate writes. Which strategy best handles both workloads?

Case Studies and Examples Hard
A. Use fan-out-on-write for every account and increase the write concern for celebrity posts.
B. Use fan-out-on-read for every account and scan all followed accounts for each feed request.
C. Embed every follower's feed inside the celebrity document and paginate the resulting nested arrays.
D. Use fan-out-on-write normally but merge celebrity posts at read time using a hybrid feed.

58 A multi-tenant order platform has several very large tenants. Every request contains tenantId, order identifiers are nonsequential, and references must not cross tenants accidentally. Which strategy is strongest?

Case Studies and Examples Hard
A. Use tenantId plus a hashed orderId as the shard key and include tenantId in relationship keys.
B. Shard only by order identifier, use global references, and filter tenant ownership in application memory.
C. Shard by creation time, store tenantId only in users, and infer order tenancy through user references.
D. Shard only by tenantId, omit it from references, and verify tenant ownership after each lookup.

59 User email is optional, but every string-valued email must have valid syntax and be unique. Missing or null email values may occur many times. Which combination best enforces this requirement?

Validation Rules and Constraints Hard
A. Use a required email validator and a regular unique index that includes missing and null values.
B. Use a syntax validator and a partial unique email index restricted to string-valued email fields.
C. Use a sparse unique email index alone because sparse indexes also validate email syntax and type.
D. Use a syntax validator alone because validation rules compare values across all documents automatically.

60 A new validator is introduced on a collection containing legacy invalid documents. New inserts must comply, but unrelated updates to legacy invalid documents must remain possible during migration. Which setting has the required behavior?

Validation Rules and Constraints Hard
A. Use validationLevel: "moderate" and validationAction: "error" during the migration.
B. Use validationLevel: "strict" and remove the validator from all application update operations.
C. Use validationLevel: "off" and validationAction: "warn" until every document is repaired.
D. Use validationLevel: "strict" and validationAction: "error" for every insert and update.