Vik G
Vik G

Reputation: 649

Need some advice on DynamoDb Tables schema

I am building a review site. It will review hotels, restaurants and cafes (lets call them listings), so there will be three categories of listings. Each of these listings will have reviews.

Now end users will be able to like / dislike the listing or individual reviews. I am using AWS Amplify to build this site.

The way the front end will query the data would as follows.

  1. A search box may want to see restaurants in a given location say Sydney / London etc.
  2. when the list of restaurants has come up, the end user can click on each restaurant to see the reviews for this restaurant.
  3. The end user can like / dislike the restaurant or do the same like / dislike for individual reviews.

I am new to NoSQL Database concepts, so need some advice on how this should be structured. Below image shows what I have in mind.

enter image description here

Upvotes: 0

Views: 293

Answers (1)

Aditya
Aditya

Reputation: 542

NoSQL schema modeling should performed based on the access patterns of the data. Based on the access patterns you provided

  1. Restaurants for a given location can be searched the Listing Secondary Partition and in addition to that you can also sort them using the listing rating.
  2. For each restaurant you can get the reviews associated with that. Are you storing the original review blobs here? If so be cautioned about the maximum row size and consider compressing the review or use S3 to store the original review.
  3. Incrementing the columns for Review_Likes and Dislikes would solve your use case 3.

However, to completely validate your schema I need the following information. In Listing table the Primary Partition key - Category values are in very small number (Hotel, Cafe, Restaurant, etc.) and this can cause hot partitions. DynamoDB expects the primary keys to be uniformly distributed for optimal performance.

Upvotes: 2

Related Questions