数据库 按照 一定规则保存 数据, 程序再发起 查询 取回所需的数据。
Web 程序 最常用基于 关系模型的数据库,这种 数据库 也称为 SQL 数据库, 因为使用结构化查询语言。
But in recent years document-oriented and key-value databases, informally known together 
as NoSQL database, have become popular alternative.
 
SQL Databases && NoSQL Databases
Databases that do not follow the relational model described in the previous section are 
collectively referred to as NoSQL databases.
One common organization for NoSQL databases uses collections instead of tables and 
documents instead of records
NoSQL databases are designed in a way that makes joins difficultso most of them do not support 
this operation at all.
ex : 
For a NoSQL database structured as below, listing the users with their roles requires the application itself 
to perform the join operation by reading the role_id field of each user and then searching the roles table for it 
A more appropriate design for a NoSQL database is shown as below.
This is the result of applying an operation called denormalization, which reduces the number of tables 
at the expense of data duplication.
A database with this structure has the role name explicitly stored each user.
Renaming a role can then turn out to be an expensive operation that may require updating a large number of number of documents
But it isnt all bad news with NoSQL databases.
Having the data duplicated allows for faster querying. 
Listing users and their roles is traightforward because no joins are needed.
 
SQL or NoSQL
SQL 数据库 擅长于高效且紧凑的 形式存储结构化数据。 这种 SQL 数据库需要花费大量精力 保证数据的一致性。
NoSQL 数据库放宽了 对这种数据一致性的要求,从而 获得性能上的 优势。
对 中小型程序来说, SQL 和 NoSQL 数据库都是 很好的选择,且性能相当。
 
posted on 2015-09-23 15:44  beyond_Acm  阅读(125)  评论(0编辑  收藏  举报