nosql vs sql (by dmitriy beseda, js developer and coach binary studio academy)

30
NoSQL vs SQL

Upload: binary-studio

Post on 06-Jan-2017

300 views

Category:

Software


0 download

TRANSCRIPT

Page 1: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

NoSQL vs SQL

Page 2: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Who am I?Beseda DmitriyWeb developer at Binary Studio

email: [email protected]: [email protected]: dmitriy.b_binaryfacebook: https://www.facebook.com/profile.php?id=100001784445579

Page 3: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Plan1.Data nowadays

2.SQL advantages / disadvantages

3.NoSQL advantages / disadvantages

4.NoSQL history

5.SQL and NoSQL similarities and differences

6.ORM / ODM

7.Myths

8.Conclusions

Page 4: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Problem

Main “Bottleneck”

Page 5: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Data evolution- Data and web apps are growing rapidly day by day

- Hardware cannot keep pace with data growth

- Apps are moving to Cloud and becoming API driven

Conclusion: It is hard to scale data in a traditional way

Page 6: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Data in businessBusiness is successful if data are used properly

- Statistic, reports

- Real-time

- Recommendations

Conclusion:

- Web apps should be real-time and interactive

- User and services databases grow from tera to peta bytes each day

Page 7: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Pay attention●CRUD (Create Read Update Delete) operations

- Performance

- Reliability

●Data consistency (ACID) & Distributed network- Parallel immediate access

- Updates applying time to all users

●Loading- Data replication

- Sharding

Page 8: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Advantages:

●No duplications

●Data integrity

●Transactions

●Actions sequence

●Security

●Data consistency

SQLDisadvantages:

●Performance

●Work in distributed environment (locks)

●Horizontal scaling complexity

●Additional language to manipulate with data

●Scaling and Sharding

Page 9: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

SQL Products and customers

December, 2015

Page 10: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

NoSQLAdvantages:

●Performance (aggregation)

●Schemaless (easy to add / remove properties)

●Horizontal scaling (& sharding)

●Way of using memory

●Open source

Disadvantages:

●Absence of transactions

●Embedding limitations

●Lots of manual work (joins are absent)

●Model format is not guaranteed

Page 11: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

NoSQL products and customers

Page 12: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

NoSQL historyIn 1998 Carlo Strozzi implemented an open source DB, that stored ASCII files and used shell scripts for data manipulations

In June 2009 Eric Evans proposed NoSQL as a Twitter #tag for a conference for existing distributed databases

Page 13: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

- Consistency - “Is the data I am looking at now the same if I look at it somewhere else”

- Availability - “What will happen if my database goes down?”

- Partitioning - “What if my data is on a different node?”

SQL - CANoSQL - AP

CAP theorem (Consistency, Availability and Partition-tolerance)

Page 14: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

SQL and NoSQL similarities●Primary key or Id is necessary and unique

●Indexes help to increase performance

●Relationships exist

Page 15: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Goals of normalization- Free the database of modification anomalies (references)

- Minimize redesign

- Avoid any bias toward any particular access pattern

Page 16: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

SQL schema example

Page 17: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Schema design- Rich documents- Pre join / embed Data- No more joins- No constraints- Atomic operations- No declared schema

Page 18: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

NoSQL types●Key Value (Firebase, Dynamo, Redis ...)

●Document (MongoDB, CouchDB)

●Graph (InfoGrid, Neo4J ...)

●Column Family (Cassandra, HyperTable, BigTable)

Page 19: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Data store positioning

SQL Comfort zone

Key Value

Column

Document

GraphRelational

Standardized Model, Tooling, Complexity

Sca

labi

lity

Page 20: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

JSON- Array

var array = [ 1, 2, 3, 4, 5]

- Dictionaries

var doc = {

"prop1": "some string","prop2": { a: 2, b: 3},"prop3": array

}

Page 21: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

NoSQL document example{

"_id": ObjectId,"description": String,"total": Number,"notes": [{

"_id": ObjectId,"text": String

}],"exclusions": [{

"_id": ObjectId,"text": String

}],"categories": {

"ref1": {"name": String,"status": String,"price": Number

},"ref2": {

"name": String,"status": String,"price": Number

}}

}

Page 22: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

ORM and ODMORM:

●Entity Framework (.NET)

●Nhibernate (.NET)

●Hibernate (Java)

●Django (Python)

●Sequelize (JS)

ODM:

●Mongoose (Mongo)

Page 23: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Myths- NoSQL supersedes SQL

- NoSQL is better / worse than SQL

- SQL vs NoSQL is a clear distinction

- The language/framework determines the database

Page 24: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Use SQL if:●Data integrity is essential

●Standards-based proven technologies with good developer experience and support

●Logical related discrete data requirements which can be identified up-front

●Prefer SQL

Page 25: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Use NoSQL if:●Data requirements are unrelated, indeterminate or evolving

●Project objectives are simpler of less specific and allow starting to code immediately

●Speed and scalability is imperative

●Prefer NoSQL

Page 26: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Always remember● Если бы мы действительно ждали завершения каждой транзакции в мировой сети ATM (банкоматов),

транзакции занимали бы столько времени, что клиенты убегали бы прочь в ярости. Что происходит, если ты и твой партнер снимаете деньги одновременно и превышаете лимит? — Вы оба получите деньги, а мы поправим это позже.

● Мы вступаем в эру polyglot persistence — эру, когда для различных потребностей используются разные хранилища данных. Теперь нет монополизма реляционных баз данных, как безальтернативного источника данных. Все чаще архитекторы выбирают хранилище исходя из природы самих данных и того, как мы ими хотим манипулировать, какие объемы информации ожидаются. И поэтому все становится только интереснее.

● A well-designed SQL database will almost certainly perform better than a badly designed NoSQL equivalent and vice versa.

Page 27: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)
Page 28: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

SummarySQL - works great, isn’t scalable for large data 😞NoSQL - works great, isn’t suitable for everyone 😞SQL + NoSQL 😊

Page 29: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

References1.SQL vs NoSQL: The Differences

2.MongoDB university

Page 30: NoSQL vs SQL (by Dmitriy Beseda, JS developer and coach Binary Studio Academy)

Questions?