MongoDB ve C# Driver'ı
-
Upload
serdar-buyuktemiz -
Category
Technology
-
view
1.064 -
download
2
description
Transcript of MongoDB ve C# Driver'ı
![Page 1: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/1.jpg)
MongoDB And C#
Serdar Büyüktemiz
@hserdarb / serdarb.com
altdotnetturkiye
Web Application Developer
![Page 2: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/2.jpg)
Program
• No-Sql
• MongoDB
• C# Driver
• Demo
![Page 3: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/3.jpg)
NO-SQL
![Page 4: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/4.jpg)
Dünyada Sadece OLTP Databaseler Yok
• Her problemin kendine has başka bir çözümü de olabilir. (NO – Not Only SQL)– Karşımıza çıkan işlerin %90’dan fazlası ilişkisel veri
tabanlarıyla rahatlıkla çözülebilir…
– Ama bunlar da var• Key-Value
• Column Oriented
• Document (MongoDB, CouchDB)
• Graph
• OLAP (No-Sql ler arasında anılmıyo…)
![Page 5: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/5.jpg)
http://jeeconf.com/archive/jeeconf-2011/materials/graph-db/
![Page 6: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/6.jpg)
Veri tabanı Boyut/Karmaşa Grafiği
http://jeeconf.com/archive/jeeconf-2011/materials/graph-db/
![Page 7: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/7.jpg)
NoSQL Problem Çözüm Örnekleri
• Key-Value• Uygulama State’ini Saklamak (Session)
• Column Oriented• Google :)• Data warehouse
• Document• Blog (Yazı Yorumları), • Eticaret (Ürün Özellikleri) • Hızlı insert
• Graph• Arkadaşımın, arkadaşlarının, arkadaşları…
• OLAP• Pek değişmeyen verilerde hızlı rapor gösterimi
![Page 8: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/8.jpg)
Genel Olarak Nasıl Bir DB Lazım?
• Kolayca kullanmaya başlayabileceğimiz (şemasız)
• İşler büyüdüğünde de bizi kaldırabilecek ama küçükken de yük olmayacak
• Bize veri kaybettirmeyecek
• Daima up olacak
• No-Sql veri tabanları genel olarak bu düşünce ile farklı iş sorunlarını çözmek üzere geliştirilmişlerdir.
![Page 9: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/9.jpg)
İdeal MongoDB Başlangıç Setup’ı
• Yazılımcı olarak kurmakla uğraşmayın bir bilen size kursun (spp42.com/mongodb/danismanlik)
![Page 10: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/10.jpg)
MONGODB
![Page 11: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/11.jpg)
RDBMS => MongoDB
RDBMS MongoDB
Table, View Collection
Row JSON Document
Index Index
Join Embeded Document
Partition Shard
Partition Key Shard Key
![Page 12: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/12.jpg)
Neden MongoDB?
• Popüler • Kolay• Şemasız• Web projeleri için ideal
• High performance (İlişkili bir yapı kurmazsak ve makul oranda «embeded döküman» kullanırsak)
• High availability (Replicated servers with automatic master failover)
• Easy scalability (Automatic sharding)
![Page 13: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/13.jpg)
İş Büyüdükçe Aradaki Fark Ortaya Çıkıyor
http://blog.michaelckennedy.net/2010/04/29/mongodb-vs-sql-server-2008-performance-showdown/
![Page 14: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/14.jpg)
Güzel bir web tutorial
http://tutorial.mongly.com/tutorialBy Karl Seguin
![Page 15: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/15.jpg)
C# DRIVER
![Page 16: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/16.jpg)
Official C# Driver
![Page 17: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/17.jpg)
BSON Nedir?
• BSON, MongoDB’nin «dökümanlar» için kullandığı veri saklama ve network transfer formatı.
• Binary JSON
• http://bsonspec.org/
• http://www.mongodb.org/display/DOCS/BSON
![Page 18: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/18.jpg)
POCO’larla Çalışmak
• İşleri kolaylaştıran kurallar…
– Parametresiz public constructor
– Serialize olmasını istediğiniz her Property için Public get ve set
![Page 19: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/19.jpg)
MongoDB’ye Bağlanmak
• GetDatabase methodu db yoksa sizin için oluşturuyor.
• http://www.mongodb.org/display/DOCS/CSharp+Driver+Tutorial#CSharpDriverTutorial-Connectionstrings
• mongodb://[username:password@]hostname[:port][/[database][?options]]
![Page 20: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/20.jpg)
MongoCollection
• GetCollection<MyType>
![Page 21: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/21.jpg)
Insert
![Page 22: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/22.jpg)
Find
![Page 23: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/23.jpg)
Map Reduce
• Mümkün olduğunca çabuk çok miktarda data üzerinde paralel olarak işlem yapmak için bir çözüm…
• CouchDB incremental Map Reduce Yapıyor…
![Page 24: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/24.jpg)
Map Reduce
![Page 25: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/25.jpg)
Demo
• https://bitbucket.org/serdarb/mongo-c-driver-poc
• https://github.com/serdarb/Mongo-C--Driver-POC
![Page 26: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/26.jpg)
Transaction
• Transaction desteği yok
– Çözümümümüz transaction gerektiriyorsa başka bir DB kullanmayı düşünebilirsiniz.
• Kendiniz geliştirmek isterseniz şu linkleri inceleyebilirsiniz
– http://docs.mongodb.org/manual/tutorial/perform-two-phase-commits/
– https://github.com/rystsov/mongodb-transaction-example
![Page 27: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/27.jpg)
Indexing
![Page 28: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/28.jpg)
İpucu
• Mongodb’yi notablescan parameteresiyleçalıştırarak sorgularımızın «full table scan» yapmamasına emin olabiliriz...
– Eğer bir sorgu fulltable scan yapıyorsa hata verecektir. Buda geliştirme anında indexbelirlememizde bize kılavuzluk edecektir
![Page 29: MongoDB ve C# Driver'ı](https://reader031.fdocument.pub/reader031/viewer/2022020110/54c31add4a7959225b8b45ad/html5/thumbnails/29.jpg)
Sources
• http://www.mongodb.org/display/DOCS/Introduction• http://mongly.com/Multiple-Collections-Versus-Embedded-Documents/• http://openmymind.net/mongodb.pdf• http://www.mongodb.org/display/DOCS/Padding+Factor• https://github.com/mongodb/mongo• http://www.codeproject.com/Articles/273145/Using-MongoDB-with-the-Official-Csharp-Driver• http://stackoverflow.com/questions/4067197/mongodb-and-joins• http://www.mongodb.org/display/DOCS/Schema+Design#SchemaDesign-EmbeddingandLinking• http://docs.mongodb.org/manual/applications/database-references/• http://www.10gen.com/presentations?programming_lang=46• https://speakerdeck.com/mongodb/whats-new-in-the-net-driver• http://learnmongo.com/• http://www.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/• http://spp42.com/mongodbde-dogru-index-kullanimi-nasil-kontrol-edilir-i/