Document databases
A little-compromise No-SQL.
Say so long to duplicated schema (tables/code) and relational/object impedance.
Documents play better with objects but, remember, they are still not objects.
The Foundation
Distribution download.
Server, client and tools
Unix flavoured
The Server: mongod.exe
Develop from the command line.
Deploy it as a Windows service.
The Client mongo.exe
The mongo Shell is a bundle of Javascript and CLI love with tab completion.
The preferred way to interact with the server outside code.
MongoShell IS Javascript. It is easy to pass a .js
file with advanced commands for data migrations.
GUIs and grids
Sometimes CLI is too rough to explore data in a tabulated fashion.
GUIs that complement the Shell (for free/or not):
The bits
In order to use MongoDb from a program we need a driver for the language.
There are multiple for multiple languages.
The official driver for .NET is the one. Nuget it!
PM> Install-Package mongocsharpdriver
The Basics
- Connection management
- JSON... errrr BSON and
BsonDocument
CRUD
Spice it with application-oriented data modelling and simple CRUD (with BIG R) is what you do day in and day out.
Indexing. Boosting the R
Indexing is THE key for decent performance with decent-sized datasets.
You can index pretty much everything you need (arrays, objects, nested properties) to make your queries fast.
Capacity plan your machines memory for indexes (and working set) to reside in there.
Serialization
BsonDocument
is alright. But we are in .NET land.
And in .NET land, objects is spoken, not documents or pseudo-documents.
Such small impedance can be mitigated by using the serialization part of the driver.
LINQ
Knowing how to build IMongoQuery
is good. But we are in .NET land.
And in .NET land, LINQ is king in terms of querying.
The World is (apparently) not flat
And MongoDB knows it and wants to help us.
Let's scartch the surface...
Data squeezing
Sometimes, we need to answer difficult questions. We have two ways to answer:
- Map/Reduce (on its way out)
- Aggregation framework
In reality, these are nice extras: OLAP databases are for data analysis
Bonus Tracks
- Document projections
- “Dynamify”
BsonDocument
Code
All code (and slides) is located in Github
Use it (and abuse it) wisely
Tak