I'm a junior software engineer working on a backend application using FastAPI. My system needs to handle both relational and non-relational data, and I'm considering using DynamoDB as my sole database. Before I go ahead with this decision, I want to know if there are any potential issues regarding maintainability, scalability, data modeling, or long-term flexibility with DynamoDB, especially for workloads involving many-to-many and many-to-one relationships. Would it be better to also use a relational database like PostgreSQL alongside DynamoDB for managing the relational aspects? I'd appreciate hearing your experiences or any edge cases I should be mindful of.
4 Answers
DynamoDB isn't designed to be a relational database. It mainly operates as a key-value store, so if your app requires traditional relational data handling, you might want to consider using a relational database alongside it. There's nothing wrong with using both; it can often provide a better architecture overall for complex data relationships.
Using DynamoDB for relational data can lead to performance issues and increased costs. In many cases, a relational database like PostgreSQL would manage these relationships more effectively, especially when dealing with complex queries and ensures data consistency. It could save you trouble down the road.
Absolutely, if you're facing many-to-many relationships, consider sticking with traditional RDBMS. DynamoDB doesn’t natively support joins and such, so opting for a relational database might simplify your implementation.
If you don't define your access patterns beforehand, DynamoDB might not serve your needs well. It's important to map out how you intend to retrieve and manipulate your data to make the most of its capabilities. I'm not saying it can't handle your use case, but expect to invest time in planning your schema and key design.
Here’s what I’m thinking about: I've got a hierarchy of Users, Folders, Subfolders, and Files managing storage, where the files live in S3. I need to ensure my relationships are maintained properly in the database. Do you think DynamoDB can achieve this cleanly, or will it get messy as I scale?
While DynamoDB can store data that seems relational, it lacks the first-class support for relationships you'd usually expect in SQL databases, like cascading updates or guaranteed integrity. If your data relationships are crucial, it may be better to lean towards a relational database to handle those aspects properly.
That makes sense. I think I’ll need a NoSQL database for parts that require flexible schemas, which is why I'm caught between the two. Do you have recommendations for setting up a system that encompasses both well?

I get that DynamoDB can do some relational modeling, like using item collections for relationships, but it might not be the best fit for every scenario, especially if you have structured data with many complex relationships.