Alex DeBrie - DynamoDB for Relational Database Diehards

Full Stack Radio


I guess maybe the best place to start would be. How do you describe what Dynamo DB even as if someone was just GonNa ask you like? What is this thing for? What do you use it for? Yep share so it's a no sequel database like you were saying and and that's not super descriptive because it basically just says what it isn't right. It's not a relational database. That a sequel. But you saw a lot of these sort of no sequel databases popping up in the last ten or fifteen years and one common thing about all these relational databases is They were they were built for larger scale you know as as he's sort of. Internet enabled platforms are happening where you have thousands or millions of of users around the world Like the single instance relational database just wasn't keeping up As well so polices started building these no sequel databases and I think one thing in common with most of these. No single databases is that they they charge your data across multiple instances so rather than having like this one monolithic database. You know you're you're my sequel instance. Your postcards instance. You'll have you know maybe five different shards of Mongo DB or with something like Dynamo DB there starting that behind the scenes sort of transparently to you Across a lot of large variety of machines The big thing that you need to do there with a no sequel database. Then is that data's going to be sharded and you need to make sure you sort of design your data correctly so that you're only hitting one Charlotte and doing efficient query rather than queering across like four or five different shards and having network calls. So that's that's a super high level but Yeah okay that makes sense so the the my sort of exposure to Dynamo. Db guests has been almost like guys have rightous alternative in a lot of situations. So I see a lot of times. People use read us for like a cash just like a key value store and I see people using Dynamo. Db FOR THAT A lot. If you're hosting your stuff on Amazon because a lot of the tools designed to work with us in that way can also interact with Dynamo. Db In that way But it sounds like a lot of people are also using Dynamo. Db is like their primary data store as Australia. Replacement for a relational database. Is that true in your experience. Yeah absolutely I think you know. A lot of people think it's only used for key value store like type Type Actions Media Session store and you can use it for that. But you can. Use It for highly relational models. You can handle one to many relationships. Many Dominion relationship all that in Dynamo. Db I show how to do that. And and there's a bunch of people doing that at a pretty large scale If if you're talking about like Amazon. Aws any of the Amazon retail. Any of the AWS stuff they. If it's a tier one service at one of those places which means if it's down it's losing money they're required to use. Dynamo. Db and they have relational models there. They have shopping carts with items in them and they belong to customers or or they'd aws stuff. That's all relational as well. So you can definitely handle these. These complex relational models not just a key value stores. Yeah cool that's really interesting so I think it'd be cool. It'd be sort of get into I. Guess like just understanding some of the core concepts and stuff around this technology. What some of the terminology is how some of it may be maps. Back to the relational database world for people who come from that. Same background as me. I'm familiar with the old tables and columns and rows model. You know what I mean. So what are some of like? What are the sort of terms and concepts that you have to understand but Dynamo DB to even get started with in the first place? How do you build like the right mental model for what it's doing? Yep sure so I'd say the four or five basic terms you want to start with and I'll just compare them to to relational houses. Well first of all. There's the notion of table which is going to be similar to a table in a relational database With some differences that get into on such as holds all your all your data in it and then each record in a table is called an item sets a row in a relational database or a document in Dynamo DB but just like a collection of data each when you create your table. What you're GonNa do is declare a primary key for your table and each item that you put into that table must have that primary key and it needs to be uniquely identified by that primary key so so there is that like is that is that auto generated by the database for you like it would be like sequel or you always have to provide it from the client yet. You need to provide it by the client. And it's usually going to be something meaningful as well. Like win a relational database. You know you might just have an auto incremental primary key like you're saying but this is GonNa be actually something meaningful life maybe username or In order ID or or something like that but you can actually use to identify that particular item because that primary keys actually gonNA drive your access patterns as well. You're going to be queering directly on that primary key. Okay interesting so I think. Like in the relational database world the advice that. I've often heard it's been like the opposite right like don't use your email column as your primary key in your users table because it's it's going to be inefficient or whatever in different ways compared to just using an auto implementing. Id but in in this case if as long as there's some existing unique identifier for the record the best practice leverage that don't add like some additional unique identifier. Yep generally and sometimes you might want to use something like a you. Id or or similar like if something like an order. Id you know you don't really have Anything meaningful about the order. You can generate a unique unique. Id and use that. But then you'll probably also refer to that that d like in your url path or whatever to help find that they'll be accessible to the client. If you needed to go do that look up. You know if someone goes to slash orders slash whatever that idea is then. Then you're back in knows. Hey this is order yet. I need to go fetch from the back end.

Coming up next