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.

posta 2 anni fa570 visualizzazioni
2 Risposte
0
con risposta 2 anni fa
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.

con risposta 2 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande