You want to store user profiles in Firebase Realtime Database. Which data structure is best to allow quick access to each user by their unique ID?
Think about how you can quickly find a user profile by ID without scanning all data.
Using a dictionary with user IDs as keys allows direct access to each profile without scanning a list, making reads efficient.
You have a list of products and a list of orders referencing those products. What is the best way to model this to avoid duplicating product details in each order?
Think about how to keep data consistent and avoid repeating the same information.
Referencing product IDs in orders and keeping product details separately avoids duplication and keeps data consistent.
You want to restrict write access so users can only update their own profile data nested under /users/{userId}. Which Firebase Realtime Database rule correctly enforces this?
Users should only write to their own user ID path, not others.
Rule D checks that the user is authenticated and their ID matches the userId in the path, restricting writes properly.
What happens when you attach a listener to /messages that triggers on child_added event?
Think about how Firebase sends data when you first attach a listener.
The child_added event fires once for each existing child at the time of attachment, then for every new child added afterward.
You have a chat app with thousands of users and millions of messages. Which data modeling approach best supports fast queries and scalability?
Think about how to limit data downloaded and keep queries efficient.
Nesting messages under chat rooms and paginating by timestamp limits data size per query and improves scalability.