A database is nothing more than a way to store and retrieve data. The “relational” part of it has to do with how that data is organized. Some data organization has very strict rules, some have less strict rules.
Lets look at toy cars as an example. If you had a giant pile of hundreds of toy cars, and you wanted to organize them in such a way that they were easy to find, you could assign attributes about those cars to a model. How many doors, what color is the paint, what company made the car, etc. Then, once all the cars are organized, it becomes easy to ask a question like “I want a blue, 4-door, Hot Wheels car”. You know if one exists, if multiple exist, if none exist, etc because organizational structure forces you to have answers to all those questions for each car.
A relational database is a way to structure the relationship between the car and it’s attributes. You know that all cars have wheels, all cars have a manufacturer, and all cars have a paint color. All cars have all 3, and a car cannot exist without having all three. The attributes are strongly related object it is describing.
However, such a rigid structure has some downsides. For example, lets say one of your cars has a jetpack attached to it. How do you record that in our previous model? Do you add a 4th attribute that says “car has jetpack” and put “no” on every car except this one? You can. . . but it’s a lot of wasted data. So the alternative is to weaken the relationship between the “car” object and it’s attributes. In a non-relational database we can assign whatever attributes we want to “car”. So this car can have a color and a manufacturer, but no doors. This one can have doors and a jetpack, but no manufacturer. This one may just have a color and the date that you purchased it. There is still data describing each car, but the data-set describing each car are not “related” to each other. So if you ask “give me all blue cars”, you can still answer that question, but you just have to ignore all cars that do not have the “color” attribute.
There are lots of different ways to organize large data set depending on which problems you are trying to solve. I will not even attempt to say which is “better” for fear of starting a holy-war in the comments.
Latest Answers