educative.io

Yelp Storage Allocation and Bytes needed for Parameters

Hi all,

I saw similar posts to these but only a few of them had been addressed. So here are my questions:

  1. Why do we need 8 bytes for LocationID? Is it basic convention to keep it as a multiple of 4? Even if it’s only 5 bytes (something bigger than the initial 4), it would be enough to handle the 20% growth per year.
  2. Why do allocate 8 bytes for the Latitude and Longitude? Is it the same reasons as 1) or something else?
  3. For the categories, is 1 byte only needed because it the number of categories are limited? How many characters/words/categories can you store in 1 bytes anyways?
  4. For ReviewID, it mentioned that it requires 4 byes and the description says that it is because we are assuming any location will not have more than 2^32 views. How do these two relate to each other?
  5. For “What if both primary and secondary servers die at the same time?”, since the only given solution is to do the brute-force method of iterating through the whole db and filter LocationIDs using our hash function to figure all the required places that will be stored on the new server, does it mean that that’s the only choice we could do? Do the users just have to wait until every locations’ populated back to the servers?

Apologies for the lengthy post, some of these questions may not be too complicated but I may not understood them initially because of my lack of background knowledge in storage and memory allocation.

Thanks in advance!