ITPub博客

首页 > > > 系统设计组件:NoSQL数据库简介

系统设计组件:NoSQL数据库简介

作者:浪花小雨滴 时间:2020-06-23 16:17:42 0 删除 编辑

本文主要参考自:

https://github.com/donnemartin/system-design-primer#nosql​github.com

什么是NoSQL

NoSQL是一系列非关系性数据库的统称。它们通常:

  1. 采取如下形式之一来表现数据:
    1. key-value store,
    2. document store,
    3. wide column store,
    4. graph database
  2. 数据被去正则化(denormalized)
  3. Join操作通常由application来执行,而非数据库
  4. 绝大部分NoSQL数据库缺乏ACID,而更青睐eventual consistency.

BASE 通常被用来描述NoSQL数据库的属性。与 CAP Theorem 相比较, BASE选择可用性而不是一致性:

  • Basically available 大致可用 - 系统保证一定程度的可用性。the system guarantees availability.
  • Soft state 软状态 - 系统状态随时可变,甚至在没有输入的情况下。the state of the system may change over time, even without input.
  • Eventual consistency 最终一致性 - 系统经过一段时间之后最终变得一致,即使此段时间内系统并没有接收到输入。the system will become consistent over a period of time, given that the system doesn't receive input during that period.

NoSQL数据库的分类

根据数据表现形式的不同,NoSQL可以被分为如下几类。了解它们的属性可以让我们更好的选择是使用SQL还是NoSQL。

Key-Value Store

抽象表示:HashTable

  • 通常允许O(1)读写操作,而且由内存或者SSD支持。
  • key通常保持字母表顺序,支持范围选取操作。
  • 支持储存metadata
  • key-value store通常具有高性能,一般用在简单而快速改变的小data上,例如一层in-memory的cache layer
  • 因为它只提供简单操作,所以更复杂的操作被移到了application layer
  • 通常是作为更复杂结构的基础,例如document store

Document Store

抽象表示:将document存储为value的key-value store

  • Document Store的中心是documents(如XML,JSON,binary等),每个document都存有一个object的所有信息。
  • Document Store提供API或者搜索语言,以搜索文章内部。
  • 根据DataBase实现方式的不同,document以collections, tags, metadata, 或者directories来归类。
  • 有些document stores,像MongoDB和CouchDB提供类似SQL的复杂查询语言。DynamoDB同时支持key-values与documents.
  • Document stores提供高可变性,通常被用于偶尔改变的数据。

Wide column store

抽象表示:嵌套映射 nested mapColumnFamily<RowKey, Columns<ColKey, Value, Timestamp>>

  • Wide column的基础单位是column(name/value pair)
  • 一个column可以被group到一组column里面,与SQL类似
  • 超级column组可以进一步group column组,形成嵌套
  • 在一组超级column里,你可以用rowkey来访问每个单独的超级column。共有rowkey的子column组成一个row
  • 每个value都带有timestamp,可以用来解决conflict
  • 常见实现:Google的Bigtable, FB的Cassandra
  • Wide column store具有高可用性与高扩展性,经常被用在巨大的数据表上。

Graph database

抽象表示:图

  • 每个节点都是一个数据记录,每条边都是数据点之间的关系
  • 优化以表现复杂数据关系,例如很多foreign key,或者many-to-many relationships
  • Graph database为复杂关系的数据提供高性能实现,如社交网络
  • 这是一个很新的数据库结构,还未被广泛使用

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31537575/viewspace-3127245/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2018-05-16

  • 博文量
    4259
  • 访问量
    39933