SlideShare a Scribd company logo
1 of 42
Practical
experience of
using RavenDB
(NoSQL)
Alex Klaus
alex-klaus.com
+ = ?
Alex Klaus alex-klaus.com
When not to NoSQL?
When to NoSQL?
Why RavenDb?
Bright and dark sides of RavenDb
What is NoSQL?
non-relational
DB, that does
not require a
fixed schema
Alex Klaus alex-klaus.com
NoSQL types
Alex Klaus alex-klaus.com
Document store
Key-value store
Graph
Column Store
Multimodel database
Object database
Tabular
Tuple store
Triplestore
Main types Other types
NoSQL adoption curve
Alex Klaus alex-klaus.com
SQL vs NoSQL. Design stages
Alex Klaus alex-klaus.com
No soft adaption path for NoSQL
When not to NoSQL?
Alex Klaus alex-klaus.com
OLAP/OLTP
Small project / Simple DB structure
No need to scale
Ad hoc queries
Immediate consistency
Unclear requirements
Inexperienced developers
How to shoot yourself
with document NoSQL?
Normalised data storage
Excessive JOINs in queries
Overuse of immediate consistency
Reasons to NoSQL
Alex Klaus alex-klaus.com
CHEAPER TO SCALE CONVENIENCE OF
DEVELOPMENT
Reason to NoSQL #1: Cheaper to scale
Options:
1. Scale up – more powerful machine
2. Scale out – cluster of smaller ones
Alex Klaus alex-klaus.com
Scaling out SQL server
Alex Klaus alex-klaus.com
Shared-disk system Sharding
Single point of failure
Extra work to
• query data (e.g. joining data across shards)
• control data integrity across shards
• rebalance the sharding from time to time
MS SQL provides FCI (Failover Cluster Instance) running in
WSFC (Windows Server Failover Clustering), which leverages
Cluster Shared Volumes
Azure SQL offers Elastic queries and Elastic transactions
Node failure makes that shard’s data unavailable
Scale out NoSQL:
Better sharding
1. Natural unit of distribution
2. Avoid cross-node JOINs
3. Avoid cross-node
transactions
Alex Klaus alex-klaus.com
Sharding in MongoDB
Aggregate orientation
NoSQL cluster. Replication
Types:
•Master-Slave
•Peer-to-Peer
•Hybrid
Alex Klaus alex-klaus.com
Each NoSQL node is self-sufficient
Alex Klaus alex-klaus.com
SQL databases are optimising storage
usage, when NoSQL — CPU
CPU is the most expensive resource in
data centres, storage is the cheapest
The most often operation against the DB
is querying data
JOINs and GROUP BYs on a normalised DB
are hammering the CPU
Alex Klaus alex-klaus.com
NoSQL
hosting:
costs
Reason to NoSQL #2: Convenience of development
Alex Klaus alex-klaus.com
Integration database
• Used in multiple applications,
developed by separate teams
• Complex structure
• Poor coordination between
teams
Application database
• Used in single application
• Tailored to the app’s
requirements
• One team maintains the app
and the DB
New way of thinkingOld way of thinking
Impedance Mismatch
Alex Klaus alex-klaus.com
Normalised database
Translate objects for
reading & writing
Use of ORM
Impedance Mismatch
difference between the relational
model (structure of tables and
rows) and the in-memory data
structures (rich objects)
What’s wrong
with ORM?
Alex Klaus alex-klaus.com
Complex data mapping leads
to expensive maintenance
One extra learning curve
Poor performance
OrmHate by Martin Fowler
Reason to NoSQL: No Impedance Mismatch
Alex Klaus alex-klaus.com
NoSQL data model uses aggregates or
graphs
No need in ORM
The same structures in memory as they
are stored on disk
Reason to NoSQL: Better integration with tech stack
Alex Klaus alex-klaus.com
Tech stacks
for NoSQL
Alex Klaus alex-klaus.com
MongoDb + NodeJs
(MEAN stack)
CosmosDb + EF Core 3
RavenDb
(client library comes
out-of-the-box)
SQL vs NoSQL
Alex Klaus alex-klaus.com
Run at scale
Convenience of
development
OLAP/OLTP
Small project / Simple DB structure
No need to scale
Ad hoc queries
Immediate consistency
Unclear requirements
Inexperienced developers
Alex Klaus alex-klaus.com
Why RavenDb?
Alex Klaus alex-klaus.com
Oren Eini
aka
Ayende Rahien
Why RavenDb?
Well established DB
Support of all OS, containers and
cloud providers
Good integration with .NET Core
9 years since
release of v1
Written in .NET Core with a
focus on the .NET infrastructure
RavenDb. Supported Platforms
Alex Klaus alex-klaus.com
Windows
Linux
Docker
MacOS
Raspberry Pi
Azure
AWS
Google Cloud
RavenDb: .NET integration
Alex Klaus alex-klaus.com
public class Contact
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
using (var store = new DocumentStore
{
Urls = new[] { "http://live-test.ravendb.net" },
Database = "Test"
})
{
store.Initialize();
var contact = new Contact
{ FirstName = "Alex", LastName = "Klaus" };
using (var session = store.OpenSession())
{
session.Store(contact);
session.SaveChanges();
}
}
RavenDb: .NET integration
Alex Klaus alex-klaus.com
using (var session = store.OpenSession())
{
var query = from c in session.Query<Contact>()
where c.FirstName == "Alex"
select c;
List<Contact> alexContacts = query.ToList();
Console.WriteLine(alexContacts.FirstOrDefault()?.LastName);
}
public class Contact
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
using (var session = store.OpenSession())
{
var query = from c in session.Query<Contact>()
where c.FirstName == "Alex"
select c.LastName;
List<string> alexContacts = query.ToList();
Console.WriteLine(alexContacts.FirstOrDefault());
}
Alex Klaus alex-klaus.com
.NET integration comparison
Alex Klaus alex-klaus.com
+ .NET Driver
+ Cosmonaut SDK
+ AWS SDK for .NET
or Entity Framework Core 3
RavenDb: Indexes
Alex Klaus alex-klaus.com
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class People_ForList : AbstractIndexCreationTask<Person, PersonIndex>
{
public People_ForList()
{
Map = contacts => contacts.Select(contact => new
{
Search = new[] { contact.FirstName, contact.LastName },
FullNameSorted = contact.LastName + " " + contact.FirstName
});
Index(m => m.Search, FieldIndexing.Search);
Analyzers.Add(x => x.Search, "WhitespaceAnalyzer");
}
}
Alex Klaus alex-klaus.com
Documentation OK
Community Small
Tech support GREAT!
RavenDB
JavaScript
engine
Alex Klaus alex-klaus.com
“Features” in query language
Alex Klaus alex-klaus.com
undefined != null
“Features” in query language
Alex Klaus alex-klaus.com
“Features” in query language
Alex Klaus alex-klaus.com
Lack of high-level wrappers for Date manipulation (like SqlFunctions in .NET)
from c in session.Query<Client>()
where c.FirstName.StartsWith("A")
select c.LastName;
but string manipulations work:
RavenDb’s grades
against other NoSQL for .NET devs
+
Run at scale
Convenience of
development
A-
B
1st
Reading
ravendb.net
alex-klaus.com/tags/no-sql/
NoSQL Distilled
by Pramod Sadalage and Martin Fowler
Domain-Driven Design Distilled
by Vaughn Vernon
Alex Klaus alex-klaus.com
Alex Klaus
alex-klaus.com
@_AlexKlaus

More Related Content

What's hot

Elasticsearch in Production
Elasticsearch in ProductionElasticsearch in Production
Elasticsearch in Production
foundsearch
 

What's hot (20)

Log analytics with ELK stack
Log analytics with ELK stackLog analytics with ELK stack
Log analytics with ELK stack
 
Survey of the Microsoft Azure Data Landscape
Survey of the Microsoft Azure Data LandscapeSurvey of the Microsoft Azure Data Landscape
Survey of the Microsoft Azure Data Landscape
 
Managing a MongoDB Deployment
Managing a MongoDB DeploymentManaging a MongoDB Deployment
Managing a MongoDB Deployment
 
AHUG Presentation: Fun with Hadoop File Systems
AHUG Presentation: Fun with Hadoop File SystemsAHUG Presentation: Fun with Hadoop File Systems
AHUG Presentation: Fun with Hadoop File Systems
 
NoSQL for you
NoSQL for youNoSQL for you
NoSQL for you
 
Keeping the Lights On with MongoDB
Keeping the Lights On with MongoDBKeeping the Lights On with MongoDB
Keeping the Lights On with MongoDB
 
Tips & Tricks SQL in the City Seattle 2014
Tips & Tricks SQL in the City Seattle 2014Tips & Tricks SQL in the City Seattle 2014
Tips & Tricks SQL in the City Seattle 2014
 
Logs aggregation and analysis
Logs aggregation and analysisLogs aggregation and analysis
Logs aggregation and analysis
 
Lightning talk: elasticsearch at Cogenta
Lightning talk: elasticsearch at CogentaLightning talk: elasticsearch at Cogenta
Lightning talk: elasticsearch at Cogenta
 
ELK Ruminating on Logs (Zendcon 2016)
ELK Ruminating on Logs (Zendcon 2016)ELK Ruminating on Logs (Zendcon 2016)
ELK Ruminating on Logs (Zendcon 2016)
 
Amazon Athena Hands-On Workshop
Amazon Athena Hands-On WorkshopAmazon Athena Hands-On Workshop
Amazon Athena Hands-On Workshop
 
Elasticsearch 5.0
Elasticsearch 5.0Elasticsearch 5.0
Elasticsearch 5.0
 
Orms vs Micro-ORMs
Orms vs Micro-ORMsOrms vs Micro-ORMs
Orms vs Micro-ORMs
 
Elasticsearch in Netflix
Elasticsearch in NetflixElasticsearch in Netflix
Elasticsearch in Netflix
 
Elasticsearch in Production
Elasticsearch in ProductionElasticsearch in Production
Elasticsearch in Production
 
Scaling horizontally on AWS
Scaling horizontally on AWSScaling horizontally on AWS
Scaling horizontally on AWS
 
ELK, a real case study
ELK,  a real case studyELK,  a real case study
ELK, a real case study
 
Elasticsearch in production Boston Meetup October 2014
Elasticsearch in production Boston Meetup October 2014Elasticsearch in production Boston Meetup October 2014
Elasticsearch in production Boston Meetup October 2014
 
Introduction to SQL Server Internals: How to Think Like the Engine
Introduction to SQL Server Internals: How to Think Like the EngineIntroduction to SQL Server Internals: How to Think Like the Engine
Introduction to SQL Server Internals: How to Think Like the Engine
 
Elk
Elk Elk
Elk
 

Similar to Pragmatic approach to NoSQL: RavenDb + .NET Core

Data SLA in the public cloud
Data SLA in the public cloudData SLA in the public cloud
Data SLA in the public cloud
Liran Zelkha
 
Architectural Anti Patterns - Notes on Data Distribution and Handling Failures
Architectural Anti Patterns - Notes on Data Distribution and Handling FailuresArchitectural Anti Patterns - Notes on Data Distribution and Handling Failures
Architectural Anti Patterns - Notes on Data Distribution and Handling Failures
Gleicon Moraes
 
NoSQL: Why, When, and How
NoSQL: Why, When, and HowNoSQL: Why, When, and How
NoSQL: Why, When, and How
BigBlueHat
 

Similar to Pragmatic approach to NoSQL: RavenDb + .NET Core (20)

No sql
No sqlNo sql
No sql
 
Data SLA in the public cloud
Data SLA in the public cloudData SLA in the public cloud
Data SLA in the public cloud
 
Mongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorial
 
Using Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 FlowUsing Document Databases with TYPO3 Flow
Using Document Databases with TYPO3 Flow
 
Scaling the Platform for Your Startup
Scaling the Platform for Your StartupScaling the Platform for Your Startup
Scaling the Platform for Your Startup
 
NoSql Database
NoSql DatabaseNoSql Database
NoSql Database
 
Serverless Analytics with Amazon Redshift Spectrum, AWS Glue, and Amazon Quic...
Serverless Analytics with Amazon Redshift Spectrum, AWS Glue, and Amazon Quic...Serverless Analytics with Amazon Redshift Spectrum, AWS Glue, and Amazon Quic...
Serverless Analytics with Amazon Redshift Spectrum, AWS Glue, and Amazon Quic...
 
configuring+oracle+rds+with+glasfish+server
configuring+oracle+rds+with+glasfish+serverconfiguring+oracle+rds+with+glasfish+server
configuring+oracle+rds+with+glasfish+server
 
SQL or NoSQL, is this the question? - George Grammatikos
SQL or NoSQL, is this the question? - George GrammatikosSQL or NoSQL, is this the question? - George Grammatikos
SQL or NoSQL, is this the question? - George Grammatikos
 
Architectural Anti Patterns - Notes on Data Distribution and Handling Failures
Architectural Anti Patterns - Notes on Data Distribution and Handling FailuresArchitectural Anti Patterns - Notes on Data Distribution and Handling Failures
Architectural Anti Patterns - Notes on Data Distribution and Handling Failures
 
NoSql Data Management
NoSql Data ManagementNoSql Data Management
NoSql Data Management
 
Vskills Apache Cassandra sample material
Vskills Apache Cassandra sample materialVskills Apache Cassandra sample material
Vskills Apache Cassandra sample material
 
Nosql seminar
Nosql seminarNosql seminar
Nosql seminar
 
An Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBAn Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDB
 
NoSQL(NOT ONLY SQL)
NoSQL(NOT ONLY SQL)NoSQL(NOT ONLY SQL)
NoSQL(NOT ONLY SQL)
 
Design Considerations For Storing With Windows Azure
Design Considerations For Storing With Windows AzureDesign Considerations For Storing With Windows Azure
Design Considerations For Storing With Windows Azure
 
NoSQL Basics and MongDB
NoSQL Basics and  MongDBNoSQL Basics and  MongDB
NoSQL Basics and MongDB
 
Azure cosmos db, Azure no-SQL database,
Azure cosmos db, Azure no-SQL database, Azure cosmos db, Azure no-SQL database,
Azure cosmos db, Azure no-SQL database,
 
If NoSQL is your answer, you are probably asking the wrong question.
If NoSQL is your answer, you are probably asking the wrong question.If NoSQL is your answer, you are probably asking the wrong question.
If NoSQL is your answer, you are probably asking the wrong question.
 
NoSQL: Why, When, and How
NoSQL: Why, When, and HowNoSQL: Why, When, and How
NoSQL: Why, When, and How
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 

Pragmatic approach to NoSQL: RavenDb + .NET Core

  • 2. Alex Klaus alex-klaus.com When not to NoSQL? When to NoSQL? Why RavenDb? Bright and dark sides of RavenDb
  • 3. What is NoSQL? non-relational DB, that does not require a fixed schema Alex Klaus alex-klaus.com
  • 4. NoSQL types Alex Klaus alex-klaus.com Document store Key-value store Graph Column Store Multimodel database Object database Tabular Tuple store Triplestore Main types Other types
  • 5. NoSQL adoption curve Alex Klaus alex-klaus.com
  • 6. SQL vs NoSQL. Design stages Alex Klaus alex-klaus.com
  • 7. No soft adaption path for NoSQL
  • 8. When not to NoSQL? Alex Klaus alex-klaus.com OLAP/OLTP Small project / Simple DB structure No need to scale Ad hoc queries Immediate consistency Unclear requirements Inexperienced developers
  • 9. How to shoot yourself with document NoSQL? Normalised data storage Excessive JOINs in queries Overuse of immediate consistency
  • 10. Reasons to NoSQL Alex Klaus alex-klaus.com CHEAPER TO SCALE CONVENIENCE OF DEVELOPMENT
  • 11. Reason to NoSQL #1: Cheaper to scale Options: 1. Scale up – more powerful machine 2. Scale out – cluster of smaller ones Alex Klaus alex-klaus.com
  • 12. Scaling out SQL server Alex Klaus alex-klaus.com Shared-disk system Sharding Single point of failure Extra work to • query data (e.g. joining data across shards) • control data integrity across shards • rebalance the sharding from time to time MS SQL provides FCI (Failover Cluster Instance) running in WSFC (Windows Server Failover Clustering), which leverages Cluster Shared Volumes Azure SQL offers Elastic queries and Elastic transactions Node failure makes that shard’s data unavailable
  • 13. Scale out NoSQL: Better sharding 1. Natural unit of distribution 2. Avoid cross-node JOINs 3. Avoid cross-node transactions Alex Klaus alex-klaus.com Sharding in MongoDB Aggregate orientation
  • 14. NoSQL cluster. Replication Types: •Master-Slave •Peer-to-Peer •Hybrid Alex Klaus alex-klaus.com Each NoSQL node is self-sufficient
  • 16. SQL databases are optimising storage usage, when NoSQL — CPU CPU is the most expensive resource in data centres, storage is the cheapest The most often operation against the DB is querying data JOINs and GROUP BYs on a normalised DB are hammering the CPU Alex Klaus alex-klaus.com NoSQL hosting: costs
  • 17. Reason to NoSQL #2: Convenience of development Alex Klaus alex-klaus.com Integration database • Used in multiple applications, developed by separate teams • Complex structure • Poor coordination between teams Application database • Used in single application • Tailored to the app’s requirements • One team maintains the app and the DB New way of thinkingOld way of thinking
  • 18. Impedance Mismatch Alex Klaus alex-klaus.com Normalised database Translate objects for reading & writing Use of ORM Impedance Mismatch difference between the relational model (structure of tables and rows) and the in-memory data structures (rich objects)
  • 19. What’s wrong with ORM? Alex Klaus alex-klaus.com Complex data mapping leads to expensive maintenance One extra learning curve Poor performance OrmHate by Martin Fowler
  • 20. Reason to NoSQL: No Impedance Mismatch Alex Klaus alex-klaus.com NoSQL data model uses aggregates or graphs No need in ORM The same structures in memory as they are stored on disk
  • 21. Reason to NoSQL: Better integration with tech stack Alex Klaus alex-klaus.com
  • 22. Tech stacks for NoSQL Alex Klaus alex-klaus.com MongoDb + NodeJs (MEAN stack) CosmosDb + EF Core 3 RavenDb (client library comes out-of-the-box)
  • 23. SQL vs NoSQL Alex Klaus alex-klaus.com Run at scale Convenience of development OLAP/OLTP Small project / Simple DB structure No need to scale Ad hoc queries Immediate consistency Unclear requirements Inexperienced developers
  • 25. Alex Klaus alex-klaus.com Oren Eini aka Ayende Rahien Why RavenDb? Well established DB Support of all OS, containers and cloud providers Good integration with .NET Core 9 years since release of v1 Written in .NET Core with a focus on the .NET infrastructure
  • 26. RavenDb. Supported Platforms Alex Klaus alex-klaus.com Windows Linux Docker MacOS Raspberry Pi Azure AWS Google Cloud
  • 27. RavenDb: .NET integration Alex Klaus alex-klaus.com public class Contact { public string FirstName { get; set; } public string LastName { get; set; } } using (var store = new DocumentStore { Urls = new[] { "http://live-test.ravendb.net" }, Database = "Test" }) { store.Initialize(); var contact = new Contact { FirstName = "Alex", LastName = "Klaus" }; using (var session = store.OpenSession()) { session.Store(contact); session.SaveChanges(); } }
  • 28. RavenDb: .NET integration Alex Klaus alex-klaus.com using (var session = store.OpenSession()) { var query = from c in session.Query<Contact>() where c.FirstName == "Alex" select c; List<Contact> alexContacts = query.ToList(); Console.WriteLine(alexContacts.FirstOrDefault()?.LastName); } public class Contact { public string FirstName { get; set; } public string LastName { get; set; } } using (var session = store.OpenSession()) { var query = from c in session.Query<Contact>() where c.FirstName == "Alex" select c.LastName; List<string> alexContacts = query.ToList(); Console.WriteLine(alexContacts.FirstOrDefault()); }
  • 29.
  • 30.
  • 32. .NET integration comparison Alex Klaus alex-klaus.com + .NET Driver + Cosmonaut SDK + AWS SDK for .NET or Entity Framework Core 3
  • 33. RavenDb: Indexes Alex Klaus alex-klaus.com public class Person { public string FirstName { get; set; } public string LastName { get; set; } } public class People_ForList : AbstractIndexCreationTask<Person, PersonIndex> { public People_ForList() { Map = contacts => contacts.Select(contact => new { Search = new[] { contact.FirstName, contact.LastName }, FullNameSorted = contact.LastName + " " + contact.FirstName }); Index(m => m.Search, FieldIndexing.Search); Analyzers.Add(x => x.Search, "WhitespaceAnalyzer"); } }
  • 34. Alex Klaus alex-klaus.com Documentation OK Community Small Tech support GREAT!
  • 35.
  • 37. “Features” in query language Alex Klaus alex-klaus.com undefined != null
  • 38. “Features” in query language Alex Klaus alex-klaus.com
  • 39. “Features” in query language Alex Klaus alex-klaus.com Lack of high-level wrappers for Date manipulation (like SqlFunctions in .NET) from c in session.Query<Client>() where c.FirstName.StartsWith("A") select c.LastName; but string manipulations work:
  • 40. RavenDb’s grades against other NoSQL for .NET devs + Run at scale Convenience of development A- B 1st
  • 41. Reading ravendb.net alex-klaus.com/tags/no-sql/ NoSQL Distilled by Pramod Sadalage and Martin Fowler Domain-Driven Design Distilled by Vaughn Vernon Alex Klaus alex-klaus.com

Editor's Notes

  1. NoSQL definition: No clear definition. No NoSQL foundation It’s ”non SQL” / “non relational” DB. Now “Not only SQL” 4 main types No clear border between key-value and document Many DB support different NoSQL types (every one does Document-oriented store)
  2. People affiliated with NoSQL databases aggressively advertising them as a solution for everything Early adopters swearing allegiance to the NoSQL and claiming of passing the point of no return to SQL Is NoSQL the silver bullet? SQL is not obsolete, it’s still a better tool in some cases
  3. Second Industrial Revolution
  4. On-Line Analytical Processing (OLAP) in MS SQL since 1998 and in Oracle since 1996. Columnar Databases like Apache Cassandra, that are well-suited for OLAP-like workloads. Simple DB structure. Means simple data-mapping. No need to scale. SQL databases are optimising storage usage, when NoSQL — CPU Ad hoc queries. Normalised data – easy querying. Need in indexes. 1 index per query is common (e.g. MongoDB, RavenDB, Amazon DynamoDB). CosmosDB creates indexes for all. RavenDB supports auto-indexes. MongoDb can scan without index. Immediate consistency. Denormalised data structure and use of Aggregates imply duplicated data in collections. Harder to do immediate consistency. Unclear requirements. Changing aggregates is expensive. Inexperienced developers. NoSQL demands knowledge of DDD, CQRS. Eric Evans coined the DDD in 2003.  CQRS, introduced by Greg Young in 2010 based on the CQS (Command–Query Separation) described by Bertrand Meyer in the 1980s.
  5. What’s left outside - ACID transactions ACID (Atomicity, Consistency, Isolation, Durability) is way less important (entities and aggregates). Heavy transaction use may flag. All main NoSQL vendors support full ACID compliant transactions. - Data Integrity Lack of validation can be mitigated by - correctly designed DDD aggregates, so number of references outside the aggregate boundaries is drastically reduced; - update the outside references in ACID transactions to enforce all-or-nothing execution.
  6. Shared-disk file system uses a SAN (Storage Area Network) to allow cluster nodes to gain direct disk access.  Sharding puts different data on separate nodes, each of which does its own reads and writes.
  7. Point of aggregates is to design data structures in a way to combine data that’s commonly accessed together.
  8. The implementation details differ from vendor to vendor. The application code will look exactly the same if the DB is running on one node or a big cluster. “Master-Slave” replace with “Parent-Child”
  9. Change level of redundancy – 3, 5, 7 nodes Easy scale up – one node at a time (2 min)
  10. CPU & RAM are heavily involved in building indexes for NoSQL data Combine costs of hosting a highly resilient database, plus maintenance and scaling, then NoSQL options can be very lucrative in the long run overcoming all the cons.
  11. Old way – separate DBA team New way – fits microservices. No need in normalised DB structure
  12. Normalised database forces devs to translate rich objects to relational representation to store on disk and translate back when reading.
  13. Complex data mapping leads to expensive maintenance (changes on either side need to be reflected properly in the mapping). One extra gruelling learning curve, as devs need to understand in depth how the ORM works on the top of how the DB works. Poor performance as the under-the-hood interactions with the database aren’t pretty
  14. Nowadays we rarely work with the database in isolation. Usually, the database is a part of a complex environment where a back-end or full-stack developer performs various operations leveraging tools and technologies at his/her disposal.
  15. The ability to communicate with the database using the tech stack of a dev’s preference and less thinking about DB topology, structure, etc. does make a difference. How much of a difference? It’s subjective, one gotta try first.
  16. MongoDb is 10 year old. CosmosDb is 9 y.o. 9-year time from v1 Microsoft released SQL Server 7,  Now at v4.2 Open source. Free community license and in AWS Oren works 24/7 – architect at Raven, blogs on Raven, does tech support, speaks at conferences and writing books. Cloud hosting – better price policy comparing to CosmosDb. Free on AWS
  17. Creating a new record: - Simple models. No data annotations like in EF. No boiler plate
  18. Querying records: - LINQ support (executed on DB) - No manual data mapping
  19. Raven Studio: Created record
  20. Querying in Raven Studio
  21. Store derived classes in one collection Query them together or indeoendently
  22. Cosmonaut SDK is close. CosmosDB + EF Core 3
  23. Auto-indexes and manual Map-reduce for grouping Text search (tokenizing words)
  24. Docs – Official website (Beginners, Samples). Worse than Angular. Comparable to PostgreSQL Community – Relatively small on Stackoverflow, not many articles. Old articles (new engine since 2018) Tech support – on Google Groups. Prompt response from devs. Bug fixes.
  25. Raven supports server-side JavaScript execution Executes the JavaScript in Jint (open source JavaScript Interpreter for .NET)