relational databases and non-relational databases
The difference between a relational database and a non-relational database is that a relational database has only a data structure that is "tables", and not a relational database system has other data structures that have other operations on them.
With the continuous development of the network, the simple relational database faces the challenge.
Characteristics of relational and non-relational databases 1. Relational database
Relational database refers to a database that uses a relational model to organize data.
In simple terms, the relational model refers to a two-dimensional tabular model, and a relational database is a data organization composed of two-dimensional tables and their linkages.
Common concepts in the relational model:
- Relationship: Can be understood as a two-dimensional table, each relationship has a relationship name, which is usually said table name
- Tuples: Can be understood as a row in a two-dimensional table, often referred to as records in a database
- Properties: A column in a two-dimensional table that is often referred to as a field in a database
- Domain: The value range of a property, that is, the value limit of a column in a database
- Keywords: A set of properties that uniquely identify a tuple, often referred to as a primary key in a database, consisting of one or more columns
- Relational pattern: Refers to the description of the relationship. The format is: the relationship name (attribute 1, property 2, ..., attribute N), which becomes the table structure in the database
The benefits of a relational database:
- Easy to understand: the two-dimensional table structure is very close to the logical world of a concept, relational model relative to the mesh, hierarchy and other models easier to understand
- Easy to use: Universal SQL language makes it easy to manipulate relational databases
- Ease of maintenance: rich integrity (Entity integrity, referential integrity, and user-defined integrity) greatly reduces the probability of data redundancy and data inconsistency
2. Relational database bottlenecks
- High concurrent read and write requirements
Website user concurrency is very high, often up to tens of thousands of read and write requests per second, for the traditional relational database, hard disk I/O is a big bottleneck
- High-efficiency reading and writing of massive data
The amount of data generated per day is huge, and for relational databases, it is very inefficient to query in a table containing huge amounts of data.
- High scalability and availability
In the Web-based architecture, the database is the most difficult to scale out, when the number of users and access to an application system is increasing, the database is not as simple as Web server and app server to add more hardware and service nodes to expand performance and load capacity. For many websites that need to provide 24-hour uninterrupted service, it is very painful to upgrade and extend the database system, which often requires downtime maintenance and data migration.
Many of the features of a relational database are no longer needed for a Web site:
- Transactional consistency
Relational database has a lot of overhead in maintaining the consistency of things, and now many web2.0 systems do not have high consistency in the reading and writing of things.
For a relational database, a query immediately after inserting a piece of data is sure to be able to read this data, but for many Web applications it is not required to be so high-real-time, such as after sending a message, a few seconds or even more than 10 seconds to see this dynamic is completely acceptable
- Complex SQL , especially multi-table association queries
Any large data volume of the Web system, are very taboo multiple large tables of association queries, as well as complex data analysis type of complex SQL report query, especially the SNS type of Web site, from the requirements and product class angle, to avoid the emergence of this situation. Often more than just a single table of primary key query, as well as single table simple conditional paging query, SQL function greatly weakened
The most important cause of poor performance in a relational database is the association query for multiple tables, as well as complex SQL report queries with complex types of data analysis. In order to ensure the acid property of the database, we must try to design according to its required paradigm, and the tables in the relational database are all stored in a formatted data structure. The composition of each tuple field is the same, even if not all of the fields are required for each tuple, but the database assigns all the fields to each tuple, which makes it easy to link between the banner tables, but from another point of view it is also a factor in relational database performance bottlenecks.
3. NoSQL
In early 2009, Johan Oskarsson held a discussion about open-source distributed databases, and Eric Evans introduced the term "NoSQL" in this discussion to refer to non-relational, distributed, and generally not guaranteed adherence to the acid principles of data storage systems. Eric Evans uses the term nosql, not because of the literal "no SQL" meaning, he just feels that a lot of classic relational database names are called "**sql", so in order to express with these relational database in the location of the very different, is using the word "NoSQL".
Note: Database transactions must have acid characteristics, acid is atomic atomicity, consistency consistency, isolation isolation, durability persistence.
The non-relational database proposes another idea, for example, to store the key-value pair, and the structure is not fixed, each tuple can have a different field, each tuple can add some of their own key-value pairs as needed, so that the fixed structure will not be limited, you can reduce the cost of some time and space. In this way, users can add the fields they need as needed, so that in order to get different information of the user, it is not necessary to query the multi-tables in the relational database. The query can be completed only by taking the corresponding value out of the ID. However, the non-relational database has little constraints, and he is not able to provide a query that is provided by SQL, where this is the case for field property values. And it is difficult to embody the integrity of the design. He is only suitable for storing some simpler data, and SQL database is more appropriate for data that requires more complex queries.
4. The difference between relational database and non-relational database
The most important feature of a relational database is transactional consistency: traditional relational database read and write operations are transactional and acid-based, and this feature enables relational databases to be used in almost all conformance-compliant systems, such as typical banking systems.
However, in the Web application, especially in the SNS application, the consistency is not so important, user a sees the content and User B see the same User C content update inconsistency is tolerable, or, two people see the same friend's data update time difference so a few seconds can be tolerated, so, The biggest feature of a relational database is useless here, at least not so important.
On the contrary, the great cost of relational database in order to maintain consistency is its poor read and write performance, and the application of SNS such as Weibo, Facebook, which is very demanding for concurrent reading and writing ability, the relational database has been unable to cope (in terms of reading, traditionally in order to overcome relational database defects, improve performance, is to increase the level of memcache to static Web pages, and in SNS, changes too fast, Memchache is powerless to do so, it is necessary to use a new data structure storage to replace the relational database.
The other characteristic of the relational database is that it has a fixed table structure, so its extensibility is very poor, and in SNS, the upgrading of the system, the increase of the function, often means the huge change of data structure, this relational database is also difficult to cope with, need new structured data storage.
Therefore, the non-relational database comes into being, because it is impossible to meet all the new requirements with a data structure, so the non-relational database is strictly not a database, it should be a collection of data structure storage methods.
It must be emphasized that persistent storage of data, especially the persistent storage of large amounts of data, or the need for a relational database.
Links: http://www.zhihu.com/question/24225007/answer/32091571
Source: Know
1. Substance.
The essence of non-relational database: the non-relational database product is a functional castrated version of traditional relational database, which can greatly improve the performance of products by reducing the functions that are not used or seldom used.
2. Price.
At present, most of the mainstream non-relational databases are free. But more famous relational database, such as Oracle, DB2, MSSQL is charged. Although MySQL is free, it requires a lot of work to be formally used for production.
3. function.
In actual development, there are many business requirements, in fact, do not need a complete relational database function, the function of non-relational database is enough to use. In this case, using a non-relational database with higher performance and lower cost is certainly a smarter choice. The non-relational database is very useful in certain fields, such as redis as the data cache, the data is stored in memory, so the performance is very good, the underlying only 30,000 code, it seems to know that the use of Redis as a database.
The current mainstream relational databases are Oracle, DB2, Microsoft SQL Server, Microsoft Access, MySQL, and more.
Non-relational databases have NOSQL, Cloudant.
NoSQL and relational database comparisons?
Advantages:
1) Cost: NoSQL databases are simple and easy to deploy, basically open source software, and do not need to spend a lot of money to buy using Oracle, compared to the relational database is cheaper than the price.
2) query speed: NoSQL database stores data in cache, relational database stores data on hard disk, natural query speed is far less than NoSQL database.
3) format for storing data: NoSQL storage formats are key,value forms, document forms, picture forms, and so on, so you can store the underlying types and objects or collections, and the database supports only the underlying types.
4) Extensibility: The limitations of a relational database with a multi-table query mechanism like join cause the extension to be difficult.
Disadvantages:
1) Maintenance of tools and information is limited, because NoSQL is a new technology, not with the relational database 10几 years of technology in the same breath.
2) does not provide support for SQL, if it does not support industry standards such as SQL, will generate a certain user's learning and use costs.
3) does not provide a relational database to deal with things.
The difference between relational and non-relational databases--reprint