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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠