In-Class exercise: Firestore DB design
We'll be working with a Yelp clone named FriendlyEats
(a Firestore starter app)
:
Your goal is to design a data model for this application.
- Try out the app at https://yelp-clone-5208e.web.app/.
Add reviews, and try changing the filtering and sorting.
- What top-level collection(s) will you have?
- What will the document for "Place Place" contain (fields and values)?
- Does this document contain any subcollections? If so, what are they? What are the fields and values
of a document in that subcollection?
- Assume the following:
- 100 restaurants
- Each restaurant has, on average, 15 reviews.
- The app usually displays 6 restaurants on the initial app page.
-
What sort of a data model would require retrieving 96 documents (on average) to display the
initial app page?
- Can you redesign the documents so that you only have to retrieve 6 documents?
- Before the redesign, what needs to happen if a new review is added?
- After the redesign, what needs to happen if a new review is added?
- What index(es) are needed in order to support the the following filters:
- Brunch places located anywhere with any price sorted by rating:
- Brunch places located anywhere with any price sorted by # of reviews:
- Brunch places located in Atlanta with any price sorted by # of reviews: