最後更新時間 02/22/2022
One weekend, I sat on the couch and thought about why I feel exhausted when there is change. Suddenly, an old memory returned. My mind jumped back to the first semester of a database class when Prof. Scott used the involved and abstruse words to explain what databases are. I realized something from them!
The history of SQL and NoSQL seems like our life! Why did I say that?
Let me introduce SQL and NoSQL first. They refer to types of methods for querying, used to communicate with databases. One is a relational (SQL) and one is a non-relational (NoSQL) data structure. SQL came first and then NoSQL was developed. Have you ever wondered why we needed NoSQL even though we already had SQL?
SQL databases, a traditional database, prefer more predictable, structured data. When deciding to use SQL databases, we have to set all of the rules first and then follow the rules. There is no flexibility. However, is it really possible for us to think about all situations for our business from the very beginning? It’s possible, but it’s really difficult. What should we do if we feel another way or if other rules are more suitable after a while? We cannot change, or adjust anything in a SQL database after we build it. That is why NoSQL databases were designed. NoSQL databases are flexible, scalable, and capable of rapidly responding to the data management demands of modern businesses.
Can you imagine what is this history like? It’s like our life!
The blueprint of our life is long. Normally, when we are children, our parents hope we live in the standard model, follow the rules, and the “success pattern”. It’s like the features of SQL. Nevertheless, it’s hard to require a person to limit some places and some thoughts. Sometimes, life will be out of control and become disordered. If we keep sticking to one thought, even when we already know it doesn’t work, then we will start to feel painful and frustrated. The solution we have is making a mechanism in our brain. When we meet these changes, we can choose to accept it, tolerate it, adjust it, or change it. It seems like NoSQL!
In terms of their names, SQL is an abbreviation for Structured Query Language. Its language has distinct layers and the rule is organizational. When we do the query, we should give it clear instructions. NoSQL is ‘Not Only SQL’, which means in addition to the SQL query, but there are also more ways to do queries.
Many companies developed databases based on SQL and NoSQL. For example, Oracle’s MySQL and Microsofts’s SQL Server use SQL for their databases; MongoDB is the database for NoSQL.
To put it simply, there are plenty of limitations and regulations if we want to store data in the SQL database. You need ACID compliancy (Atomicity, Consistency, Isolation, Durability).
‘Atomicity’ is an all-or-nothing proposition, which means every transaction is a whole atom and it cannot be sliced. Every transaction will be executed completely no matter how many actions are in the transaction. ‘Consistency’ means once something is wrong, it will go back to the beginning. It never leaves the database in a half-finished state. ‘Isolation’ keeps transactions separated from each other until they’re finished. ‘Durability’ guarantees that the database will keep track of pending changes in such a way that the server can recover from an abnormal termination.
See…it’s so hard to completely know everything that I want before I build the database; it’s like we even don’t know what we want to do until we do something!
Someone discovered this problem, and in response NoSQL was developed. NoSQL databases are classified based on the two CAP characteristics. CAP theorem is consistency, availability, and partition tolerance.
Consistency does not have the same meaning as consistency in ACID for SQL. Here, it means that all clients see the same data at the same time, no matter which node they connect to; Availability means that any client making a request for data gets a response, even if some nodes are down.
Then, P is partition tolerance. I feel this is a really interesting feature. In terms of name, it looks imperfect but demanding. It tolerates a certain degree of error and keeps moving on. Specifically, the cluster must continue to work despite any number of communication breakdowns between nodes in the system.
As I mentioned, NoSQL databases are classified based on the two of three CAP characteristics. It will not be “perfect” to fit all on three characteristics. For SQL databases, they have to obey all properties of ACID. SQL and NoSQL are really different, right?
Now, I will give you some examples. For NoSQL, it is suitable for collecting data, like Facebook collecting information of users all the time, or apps which try to collect brands, models, and the OS of users’ phones. These kinds of data are scattered and inconsistent. If these data should stick on ACID compliancy (Atomicity, Consistency, Isolation, Durability), companies will never collect those data for analyzing. For SQL, its preciseness is suitable for finance, banking, or telecommunications.
This development makes me think that our life seems similar! People will not live in the same way in each stage of life. We usually change based on time and space. John Fitzgerald Kennedy once said, “there is nothing more certain and unchanging than uncertainty and change.” If we keep thinking we must live in the ‘best’ way or ‘comfortable’ way, and refuse to change, we will suffer pain. When we encounter exceptions, accidents or even unconscious changes, we can think about how to solve it, adjust it or accept the situation.
延伸閱讀:
從 SQL 到 NoSQL 悟人生 (中文版)
Is it possible to predict a person’s future by linear regression?
Ways the Job Search Process Resembles Machine Learning: Gradient Descent Helps Us to Get Dream Jobs