A Firestore document path includes the 'documents' segment and alternates between collections and documents. Option B correctly shows a collection 'users' and a document 'user123'. Option B incorrectly uses 'collections' instead of 'documents'. Option B points to a collection, not a document. Option B reverses the order of collection and document.
Firestore creates collections implicitly when you create a document inside them. You do not need to create collections manually. So, if the parent collection does not exist, Firestore creates it automatically.
Storing orders as a top-level collection with a userId field allows querying all orders across users efficiently. Nested subcollections require collection group queries, which are more complex and less performant for large datasets. Arrays inside documents are limited and not suitable for large or complex order data. Separate databases complicate data access.
match /users/{userId}/orders/{orderId} {
allow read, write: if request.auth.uid == userId;
}The rule allows access only if the authenticated user's ID matches the userId in the document path, ensuring users can access only their own orders. Option D incorrectly compares to orderId. Option D denies access to the owner. Option D checks email verification but does not restrict by user.
Firestore documents have a size limit of 1 MiB. Storing large lists as subcollections keeps documents small and allows efficient querying and pagination. Storing all data in one document risks exceeding size limits. Large arrays are inefficient and limited. Data duplication can cause consistency issues.