Recommendations on schema for reviews

0

I need to store reviews and each review is actually made of multiple sub-reviews, represented as JSON it would look something like this:


{
    farm_reviews: [
        {
            user_id: 'AAAA',
            review_id: 'BBBB',
            date: '2022-03-26'
            name: 'Bobs Farm'
            animal_review: [
                cow: 8,
                chicken: 4,
                horse: 10
            ]
        },
        {
            user_id: 'AAAA',
            review_id: 'CCCC',
            date: '2022-03-25'
            name: 'Jims Farm'
            animal_review: [
                cow: 3,
                chicken: 2,
                horse: 6
            ]
        },
        ...
    ]
}

What's the most efficient way to store this data so I can show user AAAA his 10 most recent farm reviews while at the same time supporting the ability to show him every farm review he rated a cow greater than 5?

質問済み 2年前200ビュー
1回答
0

Hi - It depends on the database type (assuming this is for nosql) and overall access pattern. Also assuming this is for DynamoDB, you may want to review best practices and data modeling techniques based on end to end requirements.

  1. Best practices for designing and architecting with DynamoDB
  2. AWS re:Invent 2021 - Data modeling with Amazon DynamoDB

You may also think about selecting the right partition key like https://aws.amazon.com/blogs/database/choosing-the-right-dynamodb-partition-key/ and also indexes https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SecondaryIndexes.html

What you have a basic structure is fine assuming that these reviews can be replaced or may be cumulative in nature meaning user_id: 'AAAA' may provide a new review for name: 'Bobs Farm' with a new review_id or same and hence the history may co-exist or replaced. But you have to pull only latest . So think on all partition keys and indexes. See process here https://docs.aws.amazon.com/prescriptive-guidance/latest/dynamodb-data-modeling/step3.html

profile pictureAWS
エキスパート
回答済み 2年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ