What is a Firestore collection?
Answer
A Firestore collection is a container for documents — similar to a table in a relational database or a MongoDB collection. Collections have these characteristics: (1) Identified by a path — e.g., /users, /posts; (2) Cannot hold raw data — only documents; (3) Schema-flexible — documents within a collection can have different fields; (4) Auto-created — collections are created implicitly when you create the first document in them; (5) Auto-deleted — collections disappear when all their documents are deleted (they are virtual containers). You reference a collection with collection(db, "users") in the Firebase SDK. Collections can only be created at the root level (top-level collections) or as subcollections inside documents. Subcollections enable hierarchical data organization: /users/{userId}/posts/{postId}.