Sample create dynamodb table CLI script for relational data

0

I'm looking for a full example of how to create a dynamodb table based on current relational data. I've been working with relational databases for 25 years and I just can't get my head around how to create a dynamodb table to contain this data, I've gone through the best practice example on AWS, but this doesn't actually show the syntax for creating the table, and it's this bit I'm struggling with. I need the CLI syntax for now, not how to do it at the console although this might be useful in the future. An example with just two or three relational tables will be enough, just to give me a starter and hopefully aid my understanding. Thanks in anticipation.

已提問 2 年前檢視次數 570 次
2 個答案
0
已回答 2 年前
0

It took me a while to get used to the fact that DynamoDB wasn't a relational database. Basically, you need to go ahead and generate a precomputed column, possibly with a key that combines values from multiple other fields, or possibly use post-query filtering, for things you would have done with a union. This may mean more records are needed for a single datum to support the different kinds of access, but the assumption is that storage is cheap. Setting the maximum number of returned results together with the direction of sorting can help reduce that to the intended record.

For example: My first draft of my podcast-like app had one table for details about an episode, and one table mapping broadcast date to episode (because episodes may be rebroadcast). In DynamoDB, there's instead a record ("item") for every broadcast date with no attempt to optimize rebroadcasts. If I'm fetching by date, that works directly. If I'm searching by episode number, I use a secondary key which sorts by that field and tell it to stop after finding one record (I usually don't care which one since outside of date they all have the same values).

Best advice I have is to not try to bring relational experience to it, and instead go through the DynamoDB tutorials. They'll show you what Dynamo can and can't do, and how to cheat it into doing some things by using additional and/or non-obvious keys.

已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南