非关系型数据库有多少种
Working on your next project but not sure which back-end technology to use? For starters, databases come in two flavors: relational and non-relational. Both have their own set of rules, pros and cons which help in determining which type of application they should be used in. Let us delve into these differences so that we would be able to decide which one is better suited for us.
正在进行下一个项目,但不确定要使用哪种后端技术? 首先,数据库有两种形式:关系型和非关系型。 两者都有自己的一套规则,优缺点有助于确定应使用哪种类型的应用程序。让我们深入研究这些差异,以便我们能够确定哪个更适合我们。
关系数据库: (Relational Databases:)
Relational databases store data in the form of tables containing rows (representing entries) and columns (containing a set of information) having a unique key for each row. These keys can either be primary or foreign. It is based on a form of algebraic set theory known as relational algebra, which is used in the relational modeling of data. They are better suited for applications where many transactions are involved, also known as transactions-oriented applications (OLTP).
关系数据库以表的形式存储数据,该表包含对每一行具有唯一键的行(代表条目)和列(包含一组信息)。 这些键可以是主键,也可以是外键。 它基于一种称为关系代数的代数集理论形式,用于数据的关系建模。 它们更适合涉及许多事务的应用程序,也称为面向事务的应用程序(OLTP)。
They use SQL (Structured Query Language) as a language for the maintenance and querying of databases. We can use MySQL, SQL Server, SQLite, MS Access, Oracle, Sybase, PostGreSQL, or Informix.
他们使用SQL(结构化查询语言)作为维护和查询数据库的语言。 我们可以使用MySQL,SQL Server,SQLite,MS Access,Oracle,Sybase,PostGreSQL或Informix。
They are normalized databases i.e they are in accordance with a series of so-called “normal forms” in order to reduce data redundancy and improve data integrity.
它们是规范化的数据库,即它们遵循一系列所谓的“规范形式”,以减少数据冗余并提高数据完整性。
优点: (Advantages:)
1) They are useful for applications requiring a lot of transactions, complex queries and routine analysis of data
1)对于需要大量事务,复杂查询和数据常规分析的应用程序很有用
2) They are robust, simple, structured and flexible.
2)它们健壮,简单,结构化且灵活。
3) They ensure reliable data transactions through ACID (Atomity, Consistency, Isolation, Durability).
3)它们通过ACID(原子性,一致性,隔离性,耐久性)确保可靠的数据交易。
4) Easier to use because of GUI (Graphical User Interface)
4)由于GUI(图形用户界面)而更易于使用
缺点: (Disadvantages:)
1) Their main disadvantage is that it is impossible to horizontally scale them. If our business requirements increase, then we need to move on to bigger systems, making them more costly in the long run.
1)它们的主要缺点是无法水平缩放它们。 如果我们的业务需求增加,那么我们需要转向更大的系统,从长远来看,使它们的成本更高。
2) Images and other multimedia files cannot be stored.
2)无法存储图像和其他多媒体文件。
3) We cannot use them for geospatial data
3)我们不能将它们用于地理空间数据
4) They can cause ORM Impedance Mismatch
4)它们可能导致ORM阻抗不匹配
Here is a basic CRUD demo of MySQL using Node.js. You need to install the relevant software before running the examples in the repository.
这 是 使用 Node.js 的 MySQL 的基本CRUD演示 。 在 存储库中 运行示例之前,需要安装相关软件 。
非关系数据库: (Non-Relational Databases:)
Non-relational databases, more commonly known as NoSQL, are a form of databases which were created for the purpose of overcoming the shortcomings of SQL based DBMS. They are for data that cannot be modeled on tables of rows and columns.
非关系数据库(通常称为NoSQL)是一种数据库形式,旨在克服基于SQL的DBMS的缺点。 它们用于无法在行和列的表上建模的数据。
In a NoSQL database, there are no rules of normalization to follow since the data stored is already denormalized.
在NoSQL数据库中,没有遵循规范化的规则,因为存储的数据已经被规范化了。
Using No-SQL, data can be structured using the following:
使用No-SQL,可以使用以下结构化数据:
· Graphs — they use graphical structures for organizing data, this makes it easier to traverse between the connected values and relationships.
·图形-它们使用图形结构来组织数据,这使得在连接的值和关系之间更容易遍历。
Examples: Titan, neo4J, OrientDB
示例:Titan,neo4J,OrientDB
· Columns — they use keyspaces to contain all the column families
·列-它们使用键空间包含所有列族
Examples: Cassandra, ApacheHBase
示例:Cassandra,ApacheHBase
· Key-Value — they use associative arrays as the main data model. The data is in the form of key-value pairs and the key will appear at least once in the collection. We can store any value like strings, integers, JSON structures, or arrays along with a key to reference them.
·键值-它们使用关联数组作为主要数据模型。 数据采用键值对的形式,并且键在集合中至少出现一次。 我们可以存储任何值,例如字符串,整数,JSON结构或数组以及引用它们的键。
Examples: Amazon DynamoDB, Redis
示例:Amazon DynamoDB,Redis
· Documents — they are semi-structured data used in document-based DBMS.
·文档-它们是基于文档的DBMS中使用的半结构化数据。
Examples: Couchbase, MongoDB
示例:Couchbase,MongoDB
优点: (Advantages:)
· NoSQL can handle all forms of data; either structured, semi-structured or unstructured
·NoSQL可以处理所有形式的数据; 结构化,半结构化或非结构化
· It is easier to implement horizontal scaling on them
·在它们上实现水平缩放更容易
· Better suited for Big Data and real-time web applications
·更适合大数据和实时Web应用程序
· Faster and more cost-effective
·更快,更具成本效益
缺点: (Disadvantages:)
· They use a CLI (Command Line Interface) thus are more daunting to use and require greater technical skills
·他们使用CLI(命令行界面),因此使用起来更加艰巨,需要更高的技术技能
· Less support due to their open source nature
·由于其开源特性,支持较少
· Less mature, they are still growing, and many features are still being implemented
·不成熟,它们仍在增长,许多功能仍在实施中
· Lack of consistency with respect to CAP Theorem
· CAP定理缺乏一致性
· ACID transactions can only be supported through document-based DBMS but that too is not encouraged
·ACID事务只能通过基于文档的DBMS支持,但也不鼓励
I’ve written some basic CRUD code for MongoDB using Node.js which can be found here.
我已经 使用Node.js 为 MongoDB 编写了一些基本的CRUD代码 ,可以在 这里 找到 。
结论: (Conclusion:)
Both relational and non-relational databases have their own usages which would be unique to the context in which they are used for. If your application requires data on runtime then non-relational DBMS would be your friend, however if your requirement is more towards the security and robustness side then you better pair up with relational DBMS.
关系数据库和非关系数据库都有自己的用法,这对于使用它们的上下文来说是唯一的。 如果您的应用程序在运行时需要数据,那么非关系型DBMS会是您的朋友,但是,如果您的需求更侧重于安全性和健壮性,那么最好与关系型DBMS配对。
翻译自: https://medium.com/swlh/to-relational-or-not-to-relational-ebc9ddbc43a6
非关系型数据库有多少种