#community-help

Structuring Database for Different Data Types in a Travel App

TLDR Robert asked for advice on structuring database for a travel app. Jason suggested separate collections for each element type with multi-search, then use a popularity metric to determine the top result.

Powered by Struct AI

1

4
30mo
Solved
Join the chat
Jun 04, 2021 (30 months ago)
Robert
Photo of md5-a0aba3e46685345ae57c342a8130989f
Robert
05:00 AM
Hi guys! Congrats for what you have built. I have one question for now. Within our travel app (and database) we have different types (and tables) of elements, such as Attractions, Destinations, Countries, Users. What’s the best way to structure the index so we can be able to display something like this on the front-end? For example when someone is searching for “Paris”: we expect to have a top result (which can be any type, just getting the 1st search result), then all the results separately based on the element type.

Thanks!
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:08 AM
Thanks Robert!

The UI was very helpful context. I'd recommend storing each of Attractions, Destinations, Countries, Users, etc in separate collections and then do a multi-search to get results from multiple collections.

Then to show the top result, one thing you could do is: assuming you have some sort of metric in each record across different types to indicate popularity (for eg number of reviews, etc), you could pick the first result from each of the individual collections' results, see which one has the max popularity score and display that
05:09
Jason
05:09 AM
You might even have a different popularity metric for each of Attractions, Destinations, Countries, Users, etc. Then you'd want to figure out some sort of normalization scale to identify if for eg X number of reviews for Destinations is the same level of popularity as Y number of followers (for eg) for a given User
Robert
Photo of md5-a0aba3e46685345ae57c342a8130989f
Robert
05:15 AM
Thanks Jason. Will start testing early next week and will come back with updates on this.

1