An Introduction To NoSQL Databases

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys in this guide we're going to be looking at no SQL databases so a lot of you guys have been following me know that I like to take complex topics and try to break them down so that anyone can understand them alright so we're going to start from scratch so if you know absolutely nothing about no SQL then you're in the right place we're not going to stick with any specific database MongoDB is probably the most popular but I mean we'll talk about but there's other there's many other database systems and even other types of no SQL databases available all right so one common misconception with with no SQL is people some people think that it actually stands for no SQL like it's not possible when really it stands for not only SQL because it is quite possible to use SQL on some of these these databases it's not you know it's not extremely common but it is possible so in my opinion I think a better word to describe it is a non relational database alright because you know we have Oracle we have MySQL Postgres relational databases they have tables and columns and so on well no SQL databases do not ok they don't use tables or columns or the traditional aspects of a relational database ok no Askew all databases are known for working well with big data which I'll talk about in a second as well as real time web applications ok so these these are some places where you're going to find no SQL databases there's also multiple types okay we have document databases like MongoDB we have column databases key value stores and so on and I'm going to get into the specific types in a little bit all right so big data is a term that's thrown around pretty often you've probably heard it what this is it describes data sets that are they become so large that traditional methods of storage and processing are starting to become inadequate alright there's been a massive increase in data volume within the last decade or so and this is mostly due to you know huge social networks like Facebook with our search engines like Google and other websites and applications that store a ton of data if you think of you know every Facebook profile every post in everyone's feed that's all stored somewhere and that's just a huge amount of data and some of the challenges with this with this data is storing it capturing and analyzing it and transferring it all right so this is where no SQL comes in now please don't think that anything that I say in this video is you know please don't think I'm saying relational databases are dead no SQL is going to take over the entire industry anyone that says that has absolutely no clue what they're talking about or they're just trying to sell you something some kind of no SQL service there's a lot of situations and a lot of applications where a relational database is the obvious tool no SQL and relational database is kind of like a hammer and an axe they're both going to be useful they're always going to be useful they just have you know certain purposes you're not going to use an axe to bang in a nail you're not going to use a hammer to chop down a tree but they're both necessary all right and we're also going to talk about the advantages of relational databases so we've already discussed big data in how you know that's a huge benefit of knowest well that it handles a lot of data and it does it very quickly another huge advantage is datum it's data model which is extremely flexible all right so if we look at relational databases like let's say MySQL our postgrads we have to go in and structure the data in a predefined schema you guys that have worked with SQL know that you have to go in and create the database you have to model everything that you need the tables the the fields the constraints even the datatype of each field alright so is it a varchar' as a text and integer and so on and this is all stuff that you have to do when you're working with relational databases yes you can find tools that can make it a little easier but at its core at its core level has to be done in the data layer this brings us to the next advantage which is the data structure not only do you not have to define your tables and columns well there is no tables and columns but you don't have to define anything like that you don't even have to know your data structure now unless it's going to be a completely dynamic data model you should at least plan out and have an idea of how your data is going to look and then handle that on the application layer okay there's a lot of different tools there's object relational mapper z-- that we can use to actually create a schema on the application layer all right so hopefully that makes sense no oscuro databases are in many cases much cheaper than to manage then relational databases there is you know there's less of a need for multiple system admins because there's not there's not as much to do okay there's not as much to manage so it's going to be cheaper also scaling scaling is a huge advantage of no SQL it uses something called horizontal scaling or scaling out versus a relational database which uses vertical scaling or scaling up and I'm going to go over what this means in a second but scaling ISM is extremely important in this industry because it's always growing successful websites and applications are always going to gain more users and more data Facebook is never going to really lessen their their data load unless they get rid of critical parts of their interface and their functionality so scaling is definitely key when you're working with lots of data all right so let's take a look at an image here that kind of shows you scaling up ver scaling out all right now this image on the right here scaling out is also known as horizontal scaling and this is what no SQL databases do and then over here is an example of scaling up or vertical scaling and I know it's a scale in but this image is close enough to explain what I'm talking about so let's start with scaling up okay which is relational databases so this means that in order to scale and you know build up our system we need to add components so we need to add storage you know drives memory CPU power network ports and other resources that are very very expensive so it's easy to see that that there are some hard limits just by looking at this because obviously you can only put so much into this one box you can replace it with a bigger box in a bigger system but you're talking about huge amounts of money and huge amounts of time so the huge downside to this method is limitation and cost now scaling out or scaling horizontally which is what most no SQL systems do this means that you can use much cheaper commodity hardware and you can simply add additional nodes expanding your disk size your memory your memory and so on alright and a group of nodes like this is called a cluster which you may have heard before once you reach the limitations of your cluster of your nodes you can simply add another one and for a fraction of the cost of you know if you were scaling up and you were adding these expensive components or even worse if you were to the max and you needed to still scale up you'd have to you know you need a whole new infrastructure which can be a huge pain in the ass so no SQL you know scaling is definitely one of the advantages all right so now let's talk about relational databases and what they have over no SQL databases so you don't have to know much about any of this - guess that relational databases are great for relational data you have a schema where you always know what columns exist for a certain row you know that a user can have a blog post you know exactly how these two tables are related even though being schema lists is looked at as a plus in many cases having assets keymod also allows you to better understand the structure and the relation of the data stored all right it takes more maintenance and so on but it is safer many cases where data is closely related this type of database is actually the better choice okay relational databases also use something called normalization which organizes data in a way that eliminates redundancy so all the data is stored in one place normalization is really important because it allows a database to take up as little space as possible which also results in better performance now there's all types of normalization there's one N F 2 n F and it gets really complicated I'm not going to get into that though that's a whole other video on its own relational databases also use SQL or structured query language which is an old technology but very solid and then in my opinion very easy to learn most SQL or relational databases also allow you to enforce data integrity rules using foreign constraints so to give you an example let's say that we had an authors table and a blog post table and we had an author that created a post well we can create a constraint so that we wouldn't be able to delete a user that had written a post because if we did that we would have a post with no author ok or no user we don't really have these constraints available at the data level in no SQL so the last advantage here is that a lot of relational databases are acid compliant so this is a it's an acronym it stands for our atomicity consistency isolation and durability and this is a kind of a complex topic so I'm not going to go into depth but the gist of it is that it's an all-or-nothing rule so when we make database transactions for example a bank account transfer let's say from one account to the other we have a series of actions for that so we have to do multiple queries we have to take money out of one account and then we have to put it into another we have to do some math and tallying and so on well most relational databases can use acid compliance to say we're either going to do all of all of the actions or none of them because could you imagine transferring money to you know from one account to another and only the money gets taken out from the first account and then something goes wrong and crashes and it never goes into the other account so that would cause mass havoc so this is something that's very important now this isn't to say that we can't do that with no SQL because we can it's just not built into the course system at the level that relational it is with relational databases all right so hopefully that makes sense now now that we looked at the advantages and disadvantages of both relational and no SQL let's talk about the different types of no SQL databases all right now there's actually more than this but these are by far the most common so first we have document databases and the most popular document database or no SQL database in general is MongoDB I have a crash course on MongoDB which I would strongly recommend watching after this video if you haven't already documented databases store data similar to Jason or JavaScript object notation where we have curly braces inside that we have key value pairs they can hold strings numbers arrays embedded objects and so on now on the database level they are completely schema lists so your application can be very dynamic if you wanted to have let's say users be able to add custom fields to their profile a document database is definitely the way to go one profile may have an address one may not some may have BIOS or contact info some not so with relational databases we would have to we'd have to strictly define everything from the table to the fields and so on so this would not be ideal for something like that with dynamic data so we also have column databases which is optimized for reading and writing data in columns instead of rows an example of this would be Apache Cassandra this is a great this is great for things like analytics and it reduces the overall disk i/o requirements and the amount of data that needs to be loaded for disk okay so it can be quite optimized then we have key value stores which is the simplest type of no SQL database you have a key in a value this is optimal for huge data sets with very simple data it's extremely fast but not very intricate and customizable and it's similar to an associative array or a hash all right now we also have cache systems like Redis which is also a key value store but can also be used as a cache system for temporary values Redis can be used as a database and actually write data to the disk or can just store data in cache all right I have a crash course on Redis on my channel if you want to learn more about that so next we have graph databases which aren't that common but I think they're very interesting I actually did a course on neo4j which is the most popular type of or the most popular graph database everything integral databases looked at as a node and they can have relationships with other nodes through what's called an edge all right so if you have some extra time I would definitely suggest checking it out looking at neo4j because it's really interesting and yeah these are these are used for huge data sets like social networks where everything is related all right so before we go I just want to give you a visualization of a relational relational database on the left with columns and rows and then on the right we have a document database which has a very similar structure to Jason all right now the relational database these all have to be set you have to know what tables you have what columns and so on with a document database you have data stored in kind of like JSON objects and these don't have to be defined okay you can just define these as you go in your application and that's what makes it very flexible all right and very dynamic so that's going to be it guys hopefully you were able to soak up some of the information and I explained it explained it well enough and if you like this please leave is like please subscribe whatever you can do is fine and thanks for watching
Info
Channel: Traversy Media
Views: 257,977
Rating: 4.9367518 out of 5
Keywords: nosql, nosql database, nosql vs relational, relational databases, document databases, database, databases, mongodb, couchdb, key value stores, nosql tutorial
Id: uD3p_rZPBUQ
Channel Id: undefined
Length: 15min 40sec (940 seconds)
Published: Wed May 24 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.