How to model Student/Classes with DynamoDB (NoSQL)

前端 未结 2 823
南旧
南旧 2021-02-04 03:51

I\'m trying to get my way with DynamoDB and NoSQL.

What is the best (right?) approach for modeling a student table and class tables with respect to the fact that I need

2条回答
  •  忘掉有多难
    2021-02-04 04:01

    To join two Amazon DynamoDB tables

    The following example maps two Hive tables to data stored in Amazon DynamoDB. It then calls a join across those two tables. The join is computed on the cluster and returned. The join does not take place in Amazon DynamoDB. This example returns a list of customers and their purchases for customers that have placed more than two orders.

    CREATE EXTERNAL TABLE hive_purchases(customerId bigint, total_cost double, items_purchased array) 
    STORED BY 'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler'
    TBLPROPERTIES ("dynamodb.table.name" = "Purchases",
    "dynamodb.column.mapping" = "customerId:CustomerId,total_cost:Cost,items_purchased:Items");
    
    CREATE EXTERNAL TABLE hive_customers(customerId bigint, customerName string, customerAddress array) 
    STORED BY 'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler' TBLPROPERTIES ("dynamodb.table.name" = "Customers",
    "dynamodb.column.mapping" = "customerId:CustomerId,customerName:Name,customerAddress:Address");
    
    Select c.customerId, c.customerName, count(*) as count from hive_customers c 
    JOIN hive_purchases p ON c.customerId=p.customerId 
    GROUP BY c.customerId, c.customerName HAVING count > 2;
    

提交回复
热议问题