资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

nosql笔记,数据库 nosql

SQL笔记-03

2017-03-09

创新互联主营迪庆州网站建设的网络公司,主营网站建设方案,App定制开发,迪庆州h5小程序设计搭建,迪庆州网站营销推广欢迎迪庆州等地区企业咨询

1.查询三要素:

1)查那张表的数据?class

2)查那些列?sname,salary,company

3)要查哪一行?where条件

mysqlselect sname,salary,company fromclass where id=1

2.暴力查询,利用*代表所有列:

3.取出class中所有人的姓名和工资;

mysqlselect sname,salary from class;

3.查id大于1的所有列

mysqlselect * from class where id1;

4.取部分行部分列:取id小于等于2的姓名和饭补

mysqlselect sname,fanbu from classwhere id=2;

5.建表的过程就是一个声明字段(声明列)的过程,列类型的存储范围和占据字节的关系

1)数值型

整型:一般而言,占N字节则:0-2^8N-1或2^(8N-1)~+2^(8N-1)-1

tinyint:1个字节 -128~+127 或0~255;

smallint:2个字节 -32768~+32767或0-65535

mediumint:3个字节

int:4个字节

bigint:8个字节

声明tinyint怎么样让他0-255怎么样让他-128~=127:

整型声明的时候的参数问题:

1建表:

mysqlcreate table class1(

-sname varchar(10) notnull default ‘’,

-age tinyint not nulldefault 0

-)engine myisamcharset utf8;

2查看表结构

mysqldesc class1;

3插入数据,age到底是-128~+127还是0-255:

mysqlinsert into class1

-(sname,age)

-values

-(‘刘备’,128);

报错:超出范围所以说明范围不是0-255,再测试127成功

经过测试,默认范围是-128~+127;

故:int系列不加说明默认有符号

4通过声明int类型的符号,来走无符号的0-255范围,给class1加一个列

mysqlalert table class1 add chengji tinyint unsigned not nulldefault 0;

插入数据范围测试,故再列类型后加unsigned可以范围切换成正数范围

5分析列类型的m参数,m参数必须和zerofill配合才有意义,给class1增加一个学号列(学号一般不为负,而且位数相同如000013,012345不够位数也会用0填充;

mysqlalter table class1 add xuehao smallint(5) zerofill not nulldefault 0;

查看表结构

往表中插入学号数字

插入的是345 但是会自动补齐0,这就是先用m规定了学号列的长度,然后不足长度部分用0不足是zerofill的定义实现的。

查看表结构发现,只要声明了是zerofill那么就属于unsigned类型了

GitHub 上有哪些值得推荐的开源电子书

语言无关类

操作系统

鸟哥的Linux私房菜 (简体)

Linux 系统高级编程

The Linux Command Line (中英文版)

Linux 设备驱动 (第三版)

深入分析Linux内核源码

UNIX TOOLBOX

Docker中文指南

Docker —— 从入门到实践

FreeRADIUS新手入门

Mac 开发配置手册

FreeBSD 使用手册

Linux 命令行(中文版)

智能系统

一步步搭建物联网系统

web服务器

Nginx开发从入门到精通 (淘宝团队出品)

版本控制

Git教程 (本文由  @廖雪峰 创作,如果觉得本教程对您有帮助,可以去  iTunes 购买)

git – 简易指南

猴子都能懂的GIT入门

Git 参考手册

Pro Git

Git Magic

GotGitHub

Git Community Book 中文版

Mercurial 使用教程

HgInit (中文版)

沉浸式学 Git

Git-Cheat-Sheet (感谢 @flyhigher139 翻译了中文版)

GitHub秘籍

NoSQL

NoSQL数据库笔谈 (PDF)

Redis 设计与实现

Redis 命令参考

带有详细注释的 Redis 3.0 代码

带有详细注释的 Redis 2.6 代码

The Little MongoDB Book

The Little Redis Book

Neo4j 简体中文手册 v1.8

Neo4j .rb 中文资源

MySQL

MySQL索引背后的数据结构及算法原理

项目相关

持续集成(第二版) (译言网)

让开发自动化系列专栏

追求代码质量

selenium 中文文档

Joel谈软件

约耳谈软体(Joel on Software)

Web

关于浏览器和网络的 20 项须知

前端知识体系

浏览器开发工具的秘密

Chrome 开发者工具中文手册

Chrome扩展开发文档

Grunt中文文档

移动Web前端知识库

正则表达式30分钟入门教程

前端开发体系建设日记

移动前端开发收藏夹

JSON风格指南

HTTP 接口设计指北

前端资源分享(一)

前端资源分享(二)

前端代码规范 及 最佳实践

w3school教程整理

大数据

大数据/数据挖掘/推荐系统/机器学习相关资源

编程艺术

程序员编程艺术

每个程序员都应该了解的内存知识(译)【第一部分】

取悦的工序:如何理解游戏 (豆瓣阅读,免费书籍)

其他

OpenWrt智能、自动、透明翻墙路由器教程

语言相关类 AWK

awk程序设计语言

C/C++

C++ 并发编程指南 (@傅海平ICT)

Linux C编程一站式学习 (宋劲杉, 北京亚嵌教育研究中心)

CGDB中文手册

100个gdb小技巧

100个gcc小技巧

ZMQ 指南

How to Think Like a Computer Scientist (中英文版)

跟我一起写Makefile(PDF)

GNU make中文手册

GNU make 指南

Google C++ 风格指南

C/C++ Primer (by @andycai)

简单易懂的C魔法

Cmake 实践 (PDF版)

C++ FAQ LITE(中文版)

C++ Primer 5th Answers

CSS/HTML

学习CSS布局

通用 CSS 笔记、建议与指导

CSS参考手册

Emmet 文档

前端代码规范 (腾讯alloyteam团队)

Dart

Dart 语言导览

Fortran

Fortran77和90/95编程入门

Java

实时 Java 系列

Apache Shiro 用户指南

使用 Eclipse 和 Java SE 6 创建独立 Web Services 应用程序

第 1 部分: Web Services 服务端应用程序

第 2 部分: Web 服务客户端应用程序

JavaServer Faces 1.2 入门

第 1 部分: 构建基本应用程序

第 2 部分: JSF 生命周期、转换、检验和阶段监听器

用 Eclipse Europa 进行 Web 开发

第 1 部分: Eclipse Java EE

第 2 部分: PHP 开发工具

第 3 部分: Ruby Development Toolkit 和 RadRails

使用 JavaServer Faces 构建 Apache Geronimo 应用程序

第 1 部分: 使用 Eclipse 和 Apache MyFaces Core 构建基本的应用程序

第 2 部分: 在 JavaServer Faces 中使用 Tomahawk

第 3 部分: 使用 ajax4jsf 添加 Ajax 功能

第 4 部分: 使用 Apache Trinidad 组件扩展 JSF

第 5 部分: 将 JSF 应用程序与 Spring 集成

Apache Geronimo 和 Spring 框架

第 1 部分: 开发方法学

第 2 部分: 构建第一个应用程序

第 3 部分: 集成 DAO 与 ORM

第 4 部分: 混合使用 Spring AOP 和 Spring Web Flow

第 5 部分: Spring MVC

第 6 部分: Spring MVC:使用 Web 视图技术

终极 mashup —— Web 服务和语义 Web

第 1 部分: 使用与组合 Web 服务

第 2 部分: 管理 Mashup 数据缓存

第 3 部分: 理解 RDF 和 RDFs

第 4 部分: 创建本体

第 5 部分: 切换 Web 服务

Jersey 2.x 用户指南

MyBatis中文文档

JavaScript

Google JavaScript 代码风格指南

Airbnb JavaScript 规范

JavaScript 标准参考教程(alpha)

Javascript编程指南 (源码)

javascript 的 12 个怪癖

JavaScript 秘密花园

JavaScript核心概念及实践 (PDF) (此书已由人民邮电出版社出版发行,但作者依然免费提供PDF版本,希望开发者们去购买,支持作者)

《JavaScript 模式》翻译,此书中文版有售,但是纸质书翻译的还没有这个版本翻译的好

命名函数表达式探秘 (注:原文由为之漫笔翻译,原始地址无法打开,所以此处地址为我博客上的备份)

学用 JavaScript 设计模式 (开源中国)

深入理解JavaScript系列

ECMAScript 6 入门 (作者:阮一峰)

jQuery

jQuery 解构

简单易懂的JQuery魔法

How to write jQuery plugin

Node.js

Node入门

七天学会NodeJS

Nodejs Wiki Book (繁体中文)

express.js 中文文档

koa 中文文档

使用 Express + MongoDB 搭建多人博客

Express框架

nodejs文档

Node.js 包教不包会

Learn You The Node.js For Much Win! (中文版)

Node debug 三法三例

underscore.js

Underscore.js中文文档

backbone.js

backbone.js入门教程 (PDF)

Backbone.js入门教程第二版

Developing Backbone.js Applications(中文版)

AngularJS

AngularJS最佳实践和风格指南

AngularJS中译本

AngularJS入门教程

构建自己的AngularJS

在Windows环境下用Yeoman构建AngularJS项目

zepto 简明中文手册

Sea.js

Hello Sea.js

CoffeeScript

CoffeeScript Cookbook

The Little Book on CoffeeScript中文版

ExtJS

Ext4.1.0 中文文档

Chrome扩展及应用开发

JavaScript入门教程

PHP

PHP调试技术手册(PDF)

XDebug 2中文手册(译) (CHM)

PHP之道

PHP 最佳实践

PHP安全最佳实践

深入理解PHP内核

PHP扩展开发及内核应用

CodeIgniter 用户指南

Laravel4 中文文档

Laravel 入门

Symfony2中文文档 (未译完)

Phalcon中文文档(翻译进行中)

YiiBook几本Yii框架的在线教程

简单易懂的PHP魔法

swoole文档及入门教程

iOS

iOS开发60分钟入门

iOS7人机界面指南

Google Objective-C Style Guide 中文版

iPhone 6 屏幕揭秘

Apple Watch开发初探

马上着手开发 iOS 应用程序

网易斯坦福大学公开课:iOS 7应用开发字幕文件

Android

Android Design(中文版)

Google Android官方培训课程中文版

Android学习之路

Python

小白的Python教程

简明Python教程

零基础学Python

Python 2.7 官方教程中文版

Python 3.3 官方教程中文版

深入 Python 3

PEP8 Python代码风格规范

Google Python 风格指南 中文版

Python入门教程 (PDF)

Python的神奇方法指南

笨办法学 Python (PDF版下载)

Django 文档中文版

Django 最佳实践

The Django Book 中文版

web.py 0.3 新手指南

Web.py Cookbook 简体中文版

Dive Into Python 中文版

Bottle 文档中文版 (需翻墙)

Flask 文档中文版

Jinja2 文档中文版

Werkzeug 文档中文版

Flask之旅

Introduction to Tornado 中文翻译

Python自然语言处理中文版 (感谢陈涛同学的翻译,也谢谢  @shwley 联系了作者)

Python 绘图库 matplotlib 官方指南中文翻译

Scrapy 0.25 文档

ThinkPython

Ruby

Ruby 风格指南

Rails 风格指南

笨方法学 Ruby

Ruby on Rails 指南

Ruby on Rails 实战圣经

Ruby on Rails Tutorial 原书第 2 版 (本书网页版免费提供,电子版以 PDF、EPub 和 Mobi 格式提供购买,仅售 9.9 美元)

编写Ruby的C拓展

Ruby 源码解读

Shell

Shell脚本编程30分钟入门

Go

Go编程基础

Go入门指南

学习Go语言 (PDF)

Go Web 编程 (此书已经出版,希望开发者们去购买,支持作者的创作)

Go实战开发 (当我收录此项目时,作者已经写完第三章,如果读完前面章节觉得有帮助,可以给作者捐赠,以鼓励作者的继续创作)

Network programming with Go 中文翻译版本

Groovy

实战 Groovy 系列

LaTeX

一份其实很短的 LaTeX 入门文档

一份不太简短的 LATEX 2ε 介绍 (PDF版)

LISP

ANSI Common Lisp 中文翻译版

Lua

Lua编程入门

Haskell

Real World Haskell 中文版

R

R语言忍者秘笈

Scala

Scala课堂 (Twitter的Scala中文教程)

Effective Scala(Twitter的Scala最佳实践的中文翻译)

Scala指南

Swift

The Swift Programming Language 中文版

Perl

Modern Perl 中文版

Perl 程序员应该知道的事

Prolog

笨办法学Prolog

Vim中文文档

Vimscript

笨方法学Vimscript 中译本

Vim中文文档

读书笔记及其它 读书笔记

编译原理(紫龙书)中文第2版习题答案

把《编程珠玑》读薄

Effective C++读书笔记

Golang 学习笔记、Python 学习笔记、C 学习笔记 (PDF)

Jsoup 学习笔记

学习笔记: Vim、Python、memcached

图灵开放书翻译计划–C++、Python、Java等

蒂姆·奥莱利随笔 (由译言网翻译,电子版免费)

Octave 入门 (PDF版)

SICP 解题集

精彩博客集合

正则表达式简明参考

分布式系统领域有哪些经典论文

分布式领域论文译序

sqlnosql年代记

SMAQ:海量数据的存储计算和查询

一.google论文系列

1. google系列论文译序

2. The anatomy of a large-scale hypertextual Web search engine (译 zz)

3. web search for a planet :the google cluster architecture(译)

4. GFS:google文件系统 (译)

5. MapReduce: Simplied Data Processing on Large Clusters (译)

6. Bigtable: A Distributed Storage System for Structured Data (译)

7. Chubby: The Chubby lock service for loosely-coupled distributed systems (译)

8. Sawzall:Interpreting the Data--Parallel Analysis with Sawzall (译 zz)

9. Pregel: A System for Large-Scale Graph Processing (译)

10. Dremel: Interactive Analysis of WebScale Datasets(译zz)

11. Percolator: Large-scale Incremental Processing Using Distributed Transactions and Notifications(译zz)

12. MegaStore: Providing Scalable, Highly Available Storage for Interactive Services(译zz)

13. Case Study GFS: Evolution on Fast-forward (译)

14. Google File System II: Dawn of the Multiplying Master Nodes

15. Tenzing - A SQL Implementation on the MapReduce Framework (译)

16. F1-The Fault-Tolerant Distributed RDBMS Supporting Google's Ad Business

17. Elmo: Building a Globally Distributed, Highly Available Database

18. PowerDrill:Processing a Trillion Cells per Mouse Click

19. Google-Wide Profiling:A Continuous Profiling Infrastructure for Data Centers

20. Spanner: Google’s Globally-Distributed Database(译zz)

21. Dapper, a Large-Scale Distributed Systems Tracing Infrastructure(笔记)

22. Omega: flexible, scalable schedulers for large compute clusters

23. CPI2: CPU performance isolation for shared compute clusters

24. Photon: Fault-tolerant and Scalable Joining of Continuous Data Streams(译)

25. F1: A Distributed SQL Database That Scales

26. MillWheel: Fault-Tolerant Stream Processing at Internet Scale(译)

27. B4: Experience with a Globally-Deployed Software Defined WAN

28. The Datacenter as a Computer

29. Google brain-Building High-level Features Using Large Scale Unsupervised Learning

30. Mesa: Geo-Replicated, Near Real-Time, Scalable Data Warehousing(译zz)

31. Large-scale cluster management at Google with Borg

google系列论文翻译集(合集)

二.分布式理论系列

00. Appraising Two Decades of Distributed Computing Theory Research

0. 分布式理论系列译序

1. A brief history of Consensus_ 2PC and Transaction Commit (译)

2. 拜占庭将军问题 (译) --Leslie Lamport

3. Impossibility of distributed consensus with one faulty process (译)

4. Leases:租约机制 (译)

5. Time Clocks and the Ordering of Events in a Distributed System(译) --Leslie Lamport

6. 关于Paxos的历史

7. The Part Time Parliament (译 zz) --Leslie Lamport

8. How to Build a Highly Available System Using Consensus(译)

9. Paxos Made Simple (译) --Leslie Lamport

10. Paxos Made Live - An Engineering Perspective(译)

11. 2 Phase Commit(译)

12. Consensus on Transaction Commit(译) --Jim Gray Leslie Lamport

13. Why Do Computers Stop and What Can Be Done About It?(译) --Jim Gray

14. On Designing and Deploying Internet-Scale Services(译) --James Hamilton

15. Single-Message Communication(译)

16. Implementing fault-tolerant services using the state machine approach

17. Problems, Unsolved Problems and Problems in Concurrency

18. Hints for Computer System Design

19. Self-stabilizing systems in spite of distributed control

20. Wait-Free Synchronization

21. White Paper Introduction to IEEE 1588 Transparent Clocks

22. Unreliable Failure Detectors for Reliable Distributed Systems

23. Life beyond Distributed Transactions:an Apostate’s Opinion(译zz)

24. Distributed Snapshots: Determining Global States of a Distributed System --Leslie Lamport

25. Virtual Time and Global States of Distributed Systems

26. Timestamps in Message-Passing Systems That Preserve the Partial Ordering

27. Fundamentals of Distributed Computing:A Practical Tour of Vector Clock Systems

28. Knowledge and Common Knowledge in a Distributed Environment

29. Understanding Failures in Petascale Computers

30. Why Do Internet services fail, and What Can Be Done About It?

31. End-To-End Arguments in System Design

32. Rethinking the Design of the Internet: The End-to-End Arguments vs. the Brave New World

33. The Design Philosophy of the DARPA Internet Protocols(译zz)

34. Uniform consensus is harder than consensus

35. Paxos made code - Implementing a high throughput Atomic Broadcast

36. RAFT:In Search of an Understandable Consensus Algorithm

分布式理论系列论文翻译集(合集)

三.数据库理论系列

0. A Relational Model of Data for Large Shared Data Banks --E.F.Codd 1970

1. SEQUEL:A Structured English Query Language 1974

2. Implentation of a Structured English Query Language 1975

3. A System R: Relational Approach to Database Management 1976

4. Granularity of Locks and Degrees of Consistency in a Shared DataBase --Jim Gray 1976

5. Access Path Selection in a RDBMS 1979

6. The Transaction Concept:Virtues and Limitations --Jim Gray

7. 2pc-2阶段提交:Notes on Data Base Operating Systems --Jim Gray

8. 3pc-3阶段提交:NONBLOCKING COMMIT PROTOCOLS

9. MVCC:Multiversion Concurrency Control-Theory and Algorithms --1983

10. ARIES: A Transaction Recovery Method Supporting Fine-Granularity Locking and Partial Rollbacks Using Write-Ahead Logging-1992

11. A Comparison of the Byzantine Agreement Problem and the Transaction Commit Problem --Jim Gray

12. A Formal Model of Crash Recovery in a Distributed System - Skeen, D. Stonebraker

13. What Goes Around Comes Around - Michael Stonebraker, Joseph M. Hellerstein

14. Anatomy of a Database System -Joseph M. Hellerstein, Michael Stonebraker

15. Architecture of a Database System(译zz) -Joseph M. Hellerstein, Michael Stonebraker, James Hamilton

四.大规模存储与计算(NoSql理论系列)

0. Towards Robust Distributed Systems:Brewer's 2000 PODC key notes

1. CAP理论

2. Harvest, Yield, and Scalable Tolerant Systems

3. 关于CAP

4. BASE模型:BASE an Acid Alternative

5. 最终一致性

6. 可扩展性设计模式

7. 可伸缩性原则

8. NoSql生态系统

9. scalability-availability-stability-patterns

10. The 5 Minute Rule and the 5 Byte Rule (译)

11. The Five-Minute Rule Ten Years Later and Other Computer Storage Rules of Thumb

12. The Five-Minute Rule 20 Years Later(and How Flash Memory Changes the Rules)

13. 关于MapReduce的争论

14. MapReduce:一个巨大的倒退

15. MapReduce:一个巨大的倒退(II)

16. MapReduce和并行数据库,朋友还是敌人?(zz)

17. MapReduce and Parallel DBMSs-Friends or Foes (译)

18. MapReduce:A Flexible Data Processing Tool (译)

19. A Comparision of Approaches to Large-Scale Data Analysis (译)

20. MapReduce Hold不住?(zz)

21. Beyond MapReduce:图计算概览

22. Map-Reduce-Merge: simplified relational data processing on large clusters

23. MapReduce Online

24. Graph Twiddling in a MapReduce World

25. Spark: Cluster Computing with Working Sets

26. Resilient Distributed Datasets: A Fault-Tolerant Abstraction for In-Memory Cluster Computing

27. Big Data Lambda Architecture

28. The 8 Requirements of Real-Time Stream Processing

29. The Log: What every software engineer should know about real-time data's unifying abstraction

30. Lessons from Giant-Scale Services

五.基本算法和数据结构

1. 大数据量,海量数据处理方法总结

2. 大数据量,海量数据处理方法总结(续)

3. Consistent Hashing And Random Trees

4. Merkle Trees

5. Scalable Bloom Filters

6. Introduction to Distributed Hash Tables

7. B-Trees and Relational Database Systems

8. The log-structured merge-tree (译)

9. lock free data structure

10. Data Structures for Spatial Database

11. Gossip

12. lock free algorithm

13. The Graph Traversal Pattern

六.基本系统和实践经验

1. MySQL索引背后的数据结构及算法原理

2. Dynamo: Amazon’s Highly Available Key-value Store (译zz)

3. Cassandra - A Decentralized Structured Storage System (译zz)

4. PNUTS: Yahoo!’s Hosted Data Serving Platform (译zz)

5. Yahoo!的分布式数据平台PNUTS简介及感悟(zz)

6. LevelDB:一个快速轻量级的key-value存储库(译)

7. LevelDB理论基础

8. LevelDB:实现(译)

9. LevelDB SSTable格式详解

10. LevelDB Bloom Filter实现

11. Sawzall原理与应用

12. Storm原理与实现

13. Designs, Lessons and Advice from Building Large Distributed Systems --Jeff Dean

14. Challenges in Building Large-Scale Information Retrieval Systems --Jeff Dean

15. Experiences with MapReduce, an Abstraction for Large-Scale Computation --Jeff Dean

16. Taming Service Variability,Building Worldwide Systems,and Scaling Deep Learning --Jeff Dean

17. Large-Scale Data and Computation:Challenges and Opportunitis --Jeff Dean

18. Achieving Rapid Response Times in Large Online Services --Jeff Dean

19. The Tail at Scale(译) --Jeff Dean Luiz André Barroso

20. How To Design A Good API and Why it Matters

21. Event-Based Systems:Architect's Dream or Developer's Nightmare?

22. Autopilot: Automatic Data Center Management

七.其他辅助系统

1. The ganglia distributed monitoring system:design, implementation, and experience

2. Chukwa: A large-scale monitoring system

3. Scribe : a way to aggregate data and why not, to directly fill the HDFS?

4. Benchmarking Cloud Serving Systems with YCSB

5. Dynamo Dremel ZooKeeper Hive 简述

八. Hadoop相关

0. Hadoop Reading List

1. The Hadoop Distributed File System(译)

2. HDFS scalability:the limits to growth(译)

3. Name-node memory size estimates and optimization proposal.

4. HBase Architecture(译)

5. HFile:A Block-Indexed File Format to Store Sorted Key-Value Pairs

6. HFile V2

7. Hive - A Warehousing Solution Over a Map-Reduce Framework

8. Hive – A Petabyte Scale Data Warehouse Using Hadoop

转载请注明作者:phylips@bmy 2011-4-30

为什么不用NoSQL

当为大家描述我们的整体服务架构时,最常见的两个问题是:

为什么采用结构化方式将数据存储在SQL数据库中,而不使用NoSQL平台?

为什么自己维护数据中心,而不将Evernote托管到云服务提供商?

这两个问题都很有趣,我们先来探讨第一个。

对特定的应用而言,相比一个单一的SQL实例,一个现代的键值存储引擎具备显著的性能优势和可扩展性。

CREATE TABLE notebooks ( id int UNSIGNED NOT NULL PRIMARY KEY, guid binary(16) NOT NULL, user_id int UNSIGNED NOT NULL, name varchar(100) COLLATE utf8_bin NOT NULL, ... ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE notes ( id int UNSIGNED NOT NULL PRIMARY KEY, guid binary(16) NOT NULL, user_id int UNSIGNED NOT NULL, notebook_id int UNSIGNED NOT NULL, title varchar(255) NOT NULL, ... FOREIGN KEY (notebook_id) REFERENCES notebooks(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

如果你在Windows客户端上创建了一个名为“Cooking”的记事本,并立即在其中粘贴了一个名为“Quick Tomato Sauce”的食谱,客户端会立刻进行如下同步:

调用NoteStore.createNotebook() 请求服务器创建记事本,并返回以创建记事本的GUID。

通过指定记事本的GUID,调用NoteStore.createNote()在记事本中创建笔记。

每次API调用都通过SQL事物予以实现,可以让客户端完全信任服务器的任何提示。ACID兼容的数据库可以做到这些:

原子性(Atomicity):如果API调用成功,那么所有的改动都会保存;如果API调用失败,所有的改动都不会提交。

一致性(Consistency): 在API调用完成后,所有的账户都可用,并能保证内部状态的一致性。每篇笔记都与记事本相关联,以避免出现孤立项。数据库不允许删除关联有记事的记事本,这得感谢FOREIGN KEY约束。

持久性(Durability):当服务器发送记事本已创建完毕的回执后,客户端会认为它的存在具有持久性,以便进行后续的操作。变更的持久性,可以让客户端知道在任何时刻对服务状态的影响都能保持一致性。

对我们的同步协议而言,持久性最为重要。如果客户端不能确定服务器端的变更具有持久性,那么协议将会变得复杂而低效。

“大数据”问题

得益于事务处理的数据库的ACID属性,同样使得数据集非常难以扩展,以超出单台服务器的范围。数据库集群和多主复制技术并不理想,键值存储为实现可扩展性提供了一条捷径。

所幸,Evernote暂时不需要考虑这个问题。即便是我们有近10亿的笔记,和近20亿的资源文件,这也并不能称得上是一个大数据集。通过按用户分区,它被划分成了2千万个独立的数据集。

我们尚未遇到所谓“大数据”引发的问题,倒是遇到了许多“中数据”的存储问题,这就是通过规整分区形成的分片存储架构。

也许以后……

我们对新的存储系统非常感兴趣,非常乐意应用在哪些对ACID要求不强,但确实需要横向扩展的新项目中。例如,我们的报告分析系统已经逐渐超出了MySQL平台的承受力,需要被更快、更先进的系统所取代。

我们现在对以Evernote用户元数据为基础的MySQL分片存储颇为满意,尽管这不会引起那些IT弄潮儿的兴趣。


当前标题:nosql笔记,数据库 nosql
文章地址:http://cdkjz.cn/article/phisjs.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220