I'm diving into DynamoDB for the first time with Python, and I'm a bit confused about data retrieval. I don't have matching primary keys (PKs) and would like to know if there's a way to fetch data using column names instead. Specifically, I'm interested in retrieving information from the columns School, Color, and Spelling for a character like Student1, even if this data is in different tables or associated with various keys. Any guidance on this would be really appreciated!
3 Answers
Also, keep in mind that because DynamoDB is NoSQL, traditional joins or lookups across different tables aren't supported. If your data relationships are critical, a SQL option might be worth considering for future projects.
DynamoDB is quite different from a traditional relational database! The primary use case is using primary keys to look up your items. If you don't have your keys handy, you might want to consider two options:
One good approach is to use Global Secondary Indexes (GSIs). These let you create indexes based on other attributes like School, Color, and Spelling. Just keep in mind, you can have a maximum of 20 GSIs per table, and they are eventually consistent. If that doesn't work for you, there's also the option of performing a full table scan, which isn't the most efficient method, but could be acceptable for smaller tables.
What are those options? I'd love to know how to make this work without primary keys!