Appropriate DynamoDB Use Case?

I only have experience with relational databases but am interested in DynamoDB and doing a single table design if appropriate.

(This is example is analogous to my actual existing product.)

I have a bunch of recipes. Each recipes has a set of ingredients, and a list of cooking steps. Each cooking step consists of a list of texts, images and videos that are used by the app to construct an attractive presentation of the recipe.

Videos may be used in multiple recipes (e.g., a video showing how to dice onions efficiently.)

My access cases would be give me the list of recipes (name of recipe, author, date created); give me the ingredients for a particular recipe; give me the list of cooking steps for a particular recipe which entails returning a list of the steps and each step is itself a list of the components.

Is this an appropriate scenario for single table DynamoDB?


Related discussions:

non key condition expression on put item in dynamodb
Is there a REST framework for API Gateway + Lambda + DynamoDB?
CloudGuru vs Whizlab practice exam tests
Building Distributed Locks with the DynamoDB Lock Client
Looking for an OSS project using Dynamodb
Python & DynamoDB table Update issue
New – Amazon DynamoDB Continuous Backups and Point-In-Time Recovery
How should I structure this relationship in DynamoDB?
Do I need API Gateway + Lambda functions to perform CRUD operations on DynamoDB?
Best way to store a a list of DynamoDB keys
Best practices for serverless testing
Will it scale? Let’s load test geohashing on DynamoDB
Scanning DynamoDB
Is there a way to see a list of other AWS services that take in data from services like DynamoDB and S3 as input?
DynamoDB should make it easier to export backups. Data Pipeline/EMR is very inefficient and cumbersome.
How to use Projection Expression in this context: DynamoDB
If DynamoDB sucks at sorting/querying... which database should we use?
27 DynamoDB Best Practices [Bite-sized Tips]
Why am I being charged for DynamoDB read and write capacity under the free tier limit?
DynamoDB now supports empty values for non-key String and Binary attributes
Cognito Token Authentication In Lambda Function
Does a dynamodb scan return items in any particular order?
DynamoDB data modeling question. Many to many relationship?
⚡️ Dynatron - Bridge between AWS DynamoDB Document Client and Real World usage
Which of the new interfaces is the worst?
Integration Testing for API Gateway and DynamoDB
How to use API gateway WebSocket for real-time communication between front-end and backend
[Design question] Optimize an aggregation query for dynamodb
Dynamodb best way to update my table
Looking for DynamoDb architect (single table design)
The new AWS region in Zaragoza (Spain) is called eu-south-2
Visualizing DynamoDB Data
In dynamodb, what is better: 1 fat document or many small documents??
Is it an Anti-Pattern to get configuration details from a Dynamodb table using CDK?
Why are people using Strings to represent numbers in DynamoDB?
Secure (authorized) Pagination in DynamoDB
When would you NOT choose DynamoDB where you'd typically use RDBMS?
Amazon DynamoDB now supports table deletion protection
Does a DynamoDB query query every items w same partition key?
DynamoDB in a dev/canary/prod setup
Deez - A new DynamoDB library for Rust
Drank the serverless kool-aid, now switching back to EC2. What are your experiences?
Has anyone used scylladb as a drop in replacement for dynamo?
Is it okay to use full text search on dynamoDB if individual partitions are tiny?
EKS with RDS databases
Dealing with DynamoDB hot keys when you actually have occasional hot keys?
Designing my database
DynamoDB - What's the best way to query a frequently updating field?
Is anyone using aws dynamoDB for a large database?
Dynamodb models
DynamoDB down us-east-1
First production release as an AWS intern
AWS post event summary up for 19 Oct outage
Introducing bulk put items for Amazon DynamoDB: Load data from Amazon S3 into existing tables at scale
Just failed my SAA today
AWS Tutorial - AWS DynamoDB - Create Table Insert Items Scan and Query T...
How I get the AWS Solution Architect Associate Certificate in 90 hours. (SAA-C02)
Correct Answer?
AWS Service control policy - Allow.. What is that for?
DynamoDB vs S3 when using images
Developer Cert Done
Is there a way to limit the read units for Querying a DynamoDB table to just 1 per second?
Video course ideas for the AWS SDK?
One Year of DynamoDB at Timehop
DynamoDB to Redshift

If you’re asking these questions please use a relational DB. You’re going to miss an edge case at some point and it’s going to be hell to deal with.

If you know all the access / queries beforehand (sounds like you do) and can design good indexes around them, then it can work.

I don’t love single table design, but that’s mostly from trauma due to working with a poorly designed single dynamo table with data that was super relational and should have just been in postgres or something

If you are curious, try it. See how it goes!

You will never really know how it works and when to apply it without trying it out. Plenty of good libs for single table design.

If you just want to get it done easily, grab some SQL thing… Not rds or aurora.

While dynamo looks cool and interesting, it has massive drawbacks that need to be carefully considered.

  • The design gets clunky, because it’s not optimized for development productivity, but for raw performance. What would have looked elegant in SQL, is complicated in dynamo

  • It’s a proprietary tool - if this was a work project for you, think about staffing your team with people proficient in dynamo. With RDBMS it’s simple, everyone knows some SQL dialect and most of the knowledge is transferable. It’s not the same here, if somebody went from SQL to dynamo for the first time, there’s a learning curve

  • Pricing can be tricky to understand and if your design is poor, your wallet will compensate for your lack of expertise with dynamo. Of course, this is only a concern when you have big datasets, it sounds like it’s not a problem for you

Using Dynamo is essentially a performance optimization. I have used it and will use it again, but unless it’s something very simple that I never want to have to worry about scaling on, I’d rather use Postgres. I have a batch service that I wrote using DDB because it kind of needed to be slapped together quickly, and five years later I still regret it every time I have to mess with it.

Yep! And it will be much cheaper than storing and retrieving it from DynamoDB. At least, that’s the common complaint from DynamoDB users who ask the DBA team how to migrate their data out of DynamoDB to a relational database.

To answer your question:

Yes you can use DDB for that. Just consider what the (minimal) amount of data is for each page you want to render. Then you try to load all that data in a single ddb call using an optimized index.

Just don’t think relational. You usually need to duplicate data which some people really don’t like leading to relational data structures and inefficient query patterns.

Contrary to the prevailing wisdom here, I think Dynamo is a reasonably good fit here, where recipes are broadly independent documents.

It only falls down if you ever want to query things like “show me all recipes that use onions” or aggregate across recipes.

i don’t think this covers all your use cases.

you say, get the list of recipes. all of them? unfiltered?

if this is really all you need, you don’t even need dynamodb, even a file storage like s3 can do the job. although dynamo might be cheaper and faster.

I mean, an S3 bucket would arguably have fewer question marks in terms of cost and inevitably hitting document size limits.

I would suggest you have more to do to figure out your access patterns. The hard parts are in the smaller details (e.g. “allow recipe title to be updated. don’t allow duplicated recipe names on create. don’t allow duplicate recipe names on update. list recipes by date created. list recipes by title. list recipes by average review. search for recipe by ingredient. update all recipes with specific ingredient.” etc,. etc)

What you listed alone it would be doable in dynamodb pretty easily (deciding how to model your shared videos, as an example, would require a fair amount of thinking), but if you’re goal is to learn DynamoDB on a small / hobby project, go for it I say, what you listed out alone could be a great wya to get some practice.

That said, you would almost certainly (in my opinion of course) be better off, by far, with a relational database for this type of use case. The relationship between videos for common ingredients and stuff would be a natural fit for a relational database (e.g. have a tagging system that relates video resources to ingredients, ingredients associated to recipes, and an easy way to go between these things, manage them easily, etc).

Sidenote: I am a human, btw, though I wonder as I’m typing all of this what the point of me typing all of this anymore is.

Dear moderators, these auto-generated links to AWS services feel like commercial spam. Please consider disabling this bot.

Your access patterns, as stated, are well-defined, key-based, and hierarchical which means that DynamoDB would likely be a good fit. DynamoDB obviously has some benefits over a typical RDBMS such as the ability to send stateless API-based queries (vs. persistent connections), built-in backups and point-in-time recovery, low to zero operational cost when not in use, etc.

But, I would think ahead to how your users might eventually want to query your database. Let’s say you have above 100 recipes. At that point, simply presenting a list of recipes to the user wouldn’t be ideal. The user would likely want to fuzzy search for a recipe e.g. indicating one word in the recipe title or even mis-spelling the recipe or search for recipes using a specific ingredient. You can’t generally solve these type of ad hoc queries with DynamoDB.

So, if this is a learning exercise for you and you don’t require ad hoc query support, then DynamoDB would be good. Otherwise, I’d suggest an RDBMS (or even Elasticsearch).

Take a look at DSQL, all the cost/scale/performance benefits of DDB but with a SQL interface.

The opensearch integration can help here

DynamoDB ois never a good fit because of aws pricing

It’s expensive when misused but at low scale it’s practically free.

I might be confusing it with DocumentDB, but typically it goes like im asked “install this software”, “setup this service”, or “spin up this service” and im trying to convert the docker image to fargate.

then i get to the database or whatever it uses that i cant persist in fargate, or shouldnt run in fargate with out putting it on efs.

then it turns out whatever that container is in the compose that needs to be externalized from the fargate task is at minimum $50~/month for the aws service that replaces it.

or the cost is “well its based on usage if you use it a little you can afford it, but if you use it a lot dont use it”

so then i have to spin up that docker compose on a ec2 instance running docker just to try and figure out the usage amount.

Avoid Building RDS schemas by linking tables in your head get a proper RDS once you notice you are building defacto foreign key relations.
When you can live with a single table and some redundancy like in star schemas of some BA tools and you can foresee queries then dynamo may be good candidate