How to explain the difference between SQL and NoSQL to grandma

This article introduces the origin of SQL and relational algebra, there is no dry goods, please read carefully.

How to explain SQL and NoSQL to your grandma

Recently, an interview question appeared on Medium: How to explain the difference between SQL and NoSQL to your grandma. I think the author uses his own structured family tree to compare the difference between sql and nosql. The writing is good but a bit verbose. The interviewer doesn't have time to listen to you talking about it. I personally think that the difference between sql and nosql is over. One or two sentences can not be summarized, let alone tell your grandma, so if you are really asked this question, you can choose one of the most important differences. The analogy is just fine, such as sql is universal, nosql is dedicated. So my answer is this:

Dear grandmother, a database is a warehouse used to store data, just like the containers in our lives, but there are also general and special containers. For example, plastic bags are general-purpose containers, because plastic bags can hold all kinds of things: You can hold candy or pencils. But we can also choose a more suitable storage method: use candy boxes to store candies, and use pen holders to store pencils. Candy boxes and pen holders are special containers. Data and items can also be stored in general or special purpose. Each has its advantages and disadvantages. SQL is a general database and NoSQL is a special database. This is the difference between them.

Set Theory and Relational Algebra

But why can SQL be universal? There are tens of thousands of data structures in the world. Why can SQL meet various needs and not be outdated for half a century?

Although the only constant is change, the computer industry has been undergoing fission, but some basic things will never change, or change very slowly: JavaScript, the most popular programming language in the world today, still complies with the Lisp language 60 years ago. Standard, modern operating systems Windows, OSX, and Linux all come from the common ancestor Unix.

The development of the database is the same, no matter how the form changes, its essence is designed around set theory and relational algebra. Basic theory determines everything. In the software industry, as long as you master the basic mathematical theory, you will master the laws of all changes. This is the secret of SQL that will never go out of style.

Everything is linear

Software scientists realize that the entire computer industry is based on the one-dimensional utilization of data: whether it is memory, external storage, or the network, storage and transmission are all one-dimensional data. One-dimensional data is also a linear table. All complex data structures are based on linear tables. Any two-dimensional or three-dimensional data structure is also composed of linear tables. Linear tables are commonly known as lists. From the theory of "human beings are repeaters", everything in the world is composed of lists (collections).

In the universe, an important symbol of the level of technological civilization is the microscopic dimension it can control and use. The one-dimensional use of elementary particles began when our ancestors with long hair and naked bodies started a bonfire in a cave. The control of chemical reactions is to manipulate microscopic particles on a one-dimensional level. Of course, this kind of control also ranges from low to high, from bonfires to later steam engines to later generators; now, the level of one-dimensional control of microscopic particles by humans has reached its peak, with computers and nanomaterials. But all of this is limited to one-dimensional control of microscopic dimensions. From the perspective of a higher civilization in the universe, there is no essential difference between bonfires and computers, nanomaterials, etc., and they belong to the same level.

------"Three Body I: Past Events on Earth"

Science Fiction "Three-Body" Liu Cixin

Based on this theory (or world view), set theory is used to study databases. For example, the set in our mathematics textbook requires the elements of the set to be mutually different and disordered: because they are mutually different, we have the unique primary key of the database ; Because of the disorder, the database sorting is done by the index.

Set theory is a branch of mathematics itself. After the emergence of database science, in order to study the relationship between sets and sets, a new branch was derived: relational algebra.

Relational algebra studies various operations that can occur between two-dimensional linear tables, that is, table language. The most basic operations include horizontal and vertical divisions in matrix science: corresponding to selection and projection, respectively. SQL (Structured Query Language) is an implementation of relational algebra, so SQL database is also called relational database. The corresponding relationship between relational algebra and sql is as follows:

Although the SQL syntax has always been complained: messy and easily ambiguous, it is not very elegant. But because of the solid mathematical foundation of SQL, SQL has been popular until now. But it does not mean that the foundation of NoSQL is not stable. On the contrary, NoSQL is a concrete analysis of specific structures. The mathematical foundation of NoSQL is often simpler and stronger.

Unification of tables and charts

Both tables and various statistical graphs are unified in data, and they are all two-dimensional lists (also called lists of lists). A table can be transformed into a bar chart, line chart, radar chart, and pie chart without loss. . . So the table can be regarded as a special kind of chart. The famous front-end framework ag-grid was born on this theory:

Relational algebra, SQL, NoSQL, linear tables, statistical graphs, tables, and ag-grid are all researches on sets, lists, and the most essential and eternal things. That’s why so many scholars have devoted themselves to this eternal Timeless realm.

Although this article is all big and empty concepts, there is no dry goods at all, but it still does not prevent it from becoming an introductory chapter for you to learn relational algebra and SQL. If one day I think of it, I will write you a non-watery one. "Introduction to Relational Algebra." (I guess I can’t wait)

what? Don't you know ag-gird? Choose a day and post an article to introduce this god-like framework. mua~

(Finish)

Guess you like

Origin blog.csdn.net/github_38885296/article/details/103249146
Recommended