 What's going on everybody? Welcome back to another video. Today we're gonna be taking a look at SQL versus NoSQL. Now if you've watched my videos for a while now, I am sure you know what SQL is, but I'm guessing a lot of people haven't heard of what NoSQL is, and that's exactly where I was about maybe two or three years ago when I joined my current company and they said we use a NoSQL database. I was understandably pretty confused because I never heard of what that is. I'd really only heard of what a SQL database was. And so I thought it was worth looking at with all of you to kind of explain the differences so that if you do encounter a NoSQL database, you aren't completely unprepared like I was. Now when we say SQL versus NoSQL, what we really mean is a SQL database versus a NoSQL database. SQL is of course the querying language to be able to retrieve data from that database. And that database is typically or always a relational database. Now a relational database is gonna have tables that have columns and rows that store your data for you. So it's very organized. Rows are gonna store your data as well as have unique identifiers which helps you distinguish your different rows from one another. And a relational database is also gonna be vertically scalable. So let's take a look at this picture really quick. So as you can see on this left hand side, there's a vertical scaling and it says increase the size of your instance, a RAM or CPU. So you can picture this as if you were trying to pick up a very large couch and it's just a little bit too big for you. And so you take some steroids and you get a little bit stronger and you're able to lift that very heavy couch. Now this is compared to horizontal scaling on the right side, which is you add more instances. So instead of you just getting larger and picking up the couch, you invite some of your friends over and you all pick up the couch together. Horizontal scaling has been proven to be quite a bit more efficient because you're not putting so much workload on just one server or one instance. What you're doing is really spreading it out and allowing a lot of people to help at once or a lot of instances to help at once. Some examples of a relational database or a SQL database is MySQL, PostgreSQL and Microsoft SQL Server. A quick example of how data would be stored in a relational database is you have your columns at the top. So this employee ID, first name, last name, those are columns. And then for rows, we have 1,001, 2, and 3. And in each one, that is a unique identifier. So that 1,001, 2, and 3, those are unique to that individual. And that is also labeled the primary key for this table. To query from a SQL database, you're gonna be using the SQL syntax, which you can see right here. So we have select from and where and a few other things as well. And then we have our output on the bottom. And again, it's in that same format of columns and rows. So now let's look at NoSQL, which is kind of a short version for saying not only SQL. It can still hold relational data, but it doesn't store it in a table with columns and rows like a relational database does. It also can store completely unstructured or semi-structured data, which a relational database cannot do. A NoSQL database is also horizontally scalable, which if you remember from before, is where it brings on more instances to decrease the load on one specific instance. Now there's not just one type of NoSQL database, it's many different types that you can pull in many different types of unstructured and semi-structured data. So we have a key value database, a column-oriented database, a document database, and a graph database. And each one is specifically used for that purpose. Some examples of NoSQL databases are things like MongoDB, Cassandra, and many others that you can see right here. So now let's take a look at how these two databases can store their data differently. A relational database like we looked at before can store it in columns and rows within a table. But for a NoSQL database, it's gonna look a little bit like this at the bottom, where it's in this semi-structured form. It has the exact same data as above, but it's just stored in a semi-structured way. Now to show you how to query out of a NoSQL database, we're gonna take a look at MongoDB. And there are a lot of languages that you can use to query a NoSQL database, but you can't use SQL. Now to show how you can query the data out of a NoSQL database, we're taking a look at MongoDB, which is one I am most familiar with. There are a lot of languages that you can use to actually retrieve your data from a NoSQL database. The one that I'm most familiar with would be Python, but I've also used the MongoDB query language as well. Now there's really no way of saying which one is better because they really have different use cases. I personally have used SQL for a lot longer, and I really like the simplicity of it and the organizational abilities of using a SQL database, but there are so many different purposes for a NoSQL database. So if you're looking for a place to store your data, here's some things that you may wanna look at in order to determine which one will be better to store your data in. So for a SQL database, it's gonna be very good at storing structured data, has very easily understood data integrity or a lot more understandable than a NoSQL database. It's gonna be very flexible with how you're querying it and the things that you can do to kind of manipulate it when you're retrieving that data. And it also handles medium level of transactions well. Now I say medium level because if it's taking in a ton of transactions, if 10,000 or hundreds of thousands per second, then it really gets bogged down and can even break. Whereas typically a NoSQL database can handle those high transactions a lot better. So for a NoSQL database, it stores unstructured data or semi-structured data very well. It also is very highly scalable. So if you're bringing in a ton of data, a NoSQL database will be able to handle that a lot better than a SQL database. And it also has a very low latency for data retrieval or it typically has a much lower latency for data retrieval. It just depends on what you're querying and how much data is actually there. So I hope that that was helpful. I know that when I started using a NoSQL database about two or three years ago, I had no idea what they were. So hopefully you know a little bit better about the differences and the use cases for those types of databases. Thank you guys so much for watching. I really appreciate it. If you liked this video, be sure to like and subscribe below and I'll see you in the next video.