How to Retrieve Data from DynamoDB Without Primary Keys?

0
11
Asked By PineappleWizard42 On

I'm new to using DynamoDB with Python and I'm trying to figure out how to access data without relying on primary keys. Specifically, I want to pull data from columns like School, Color, and Spelling for a character such as Student1, even if the data resides in different tables or under different keys. Any suggestions?

3 Answers

Answered By CuriousCoder101 On

Just a heads up, DynamoDB is a NoSQL database and it doesn’t support joins or lookups like you would find in SQL databases. If you lack access to primary keys for retrieving specific data, your options are somewhat limited. Consider setting up Global Secondary Indexes to make queries possible on the attributes you're interested in. You could potentially also scan the entire table, but be mindful of that approach as it can be quite resource-intensive.

Answered By TechieTurtle88 On

DynamoDB operates differently from traditional relational databases. It primarily uses primary keys for data retrieval. If you don't have the primary keys available, there are a couple of strategies you could consider. First, you might want to explore setting up Global Secondary Indexes (GSIs) for the attributes you want to search by such as School, Color, and Spelling. Keep in mind that a GSI can allow you to query on those attributes, but it will be eventually consistent. Alternatively, if you have a smaller dataset and want a simple solution, you could perform a table scan, though this isn't optimal for larger datasets due to potential performance issues.

Answered By SearchGuru_99 On

In DynamoDB, aiming for a lookup using columns instead of primary keys isn't typical. If you have to work with DynamoDB, I suggest considering using Global Secondary Indexes (GSIs) to facilitate your queries based on non-key columns like School, Color, and Spelling. You can create GSIs for these columns, but remember that you'd be limited to a maximum of 20 GSIs per table. Another option, albeit less efficient, is performing a full table scan to check for matching records, but this can lead to high read capacity usage, so be cautious.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.