Martin Strýček - Ako začať s MongoDB

W
{
    author:"Martin Strýček",
    twitter:"@martin_strycek",
    about:"Ako začať s MongoDB"
}
NoSQL a RDBMS pohľad
na svet.
“640kB of memory should be
enough for anybody.”




           -Bill Gates (1981)
byte
Kilobyte      1,024

Megabyte      1,048,576
   “640K of memory should be
Gigabyte      1,073,741,824

   enough for anybody.”
Terabyte      1,099,511,627,776


Petabyte      1,125,899,906,842,624


Exabyte       1,152,921,504,606,846,976



Zettabyte     1,180,591,620,717,411,303,425
RDBMS
NoSQL                Relácie
 Vnorené objekty    ACID (atomicity,
 Rýchlosť            consistency, isolation,
                      durability)




Základné rozdiely
Čo vlastne je mongoDB a
ako funguje?
MongoDB od slova "humongous“ je šk{lovateľn{,
 výkonná, open source NoSQL databáza.




strycek@webserverba:~$ mongo 192.168.122.20:27017
strycek@webserverba:~$ mongo
                          192.168.122.20:27017
                          MongoDB shell version: 1.4.4
   MongoDB je databáza   url: 192.168.122.20:27017
                          connecting to: 192.168.122.20:27017/test
                          type "help" for help
                          >




     > use harvester
strycek@webserverba:~$ mongo
                                    192.168.122.20:27017
                                    MongoDB shell version: 1.4.4
   MongoDB je databáza
                                    url: 192.168.122.20:27017
   obsahujúca kolekcie (tabuľka)   connecting to: 192.168.122.20:27017/test
                                    type "help" for help
                                    > use harvester
                                    switched to db harvester




      > db.pageviews
   MongoDB je databáza
             obsahujúca kolekcie (tabuľka)
             kolekcie obsahujú dokumenty (riadky)




> db.pageviews.insert({})
   MongoDB je databáza
             obsahujúca kolekcie (tabuľka)
             kolekcie obsahujú dokumenty (riadky)
             dokumenty obsahujú množinu polí (stĺpce)




> db.pageviews.insert({url : "http://webelement.sk" })
Dáta, veľa dát...
   BSON = binary-encoded serialization of JSON-like
    documents
   BSON = binary-encoded serialization of JSON-like
    documents

   maxim{lna veľkosť jedného dokumentu je 16MB

   pre väčšie d{ta máme GridFS
       Súbory
       Kúsky
{
    "_id" : ObjectId("4fcfd8db962e3f275a2847d6"),
    "url" : "http://webelement.sk",
    "visitor" : 1
}
{
    "_id" : ObjectId("4fcfd8db962e3f275a2847d7"),
    "date" : "Thu Jun 07 2012 00:00:00 GMT+0200 (CET)",
    "url" : "http://webelement.sk",
    "visitor" : 225,
    "logged-in" : 55225
}




db.pageviews.find();
{
      "_id" : ObjectId("4fcfd8db962e3f275a2847d6"),
      "url" : "http://webelement.sk",
 }
 {
      "_id" : ObjectId("4fcfd8db962e3f275a2847d7"),
      "url" : "http://webelement.sk",
 }


db.pageviews.find(
     {url:”http://webelement.sk”},
     {url:1}
);
Kedy je vhodný čas prejsť
na MongoDB?
{                              {
    "_id" : ...,                   "_id" : ...,
    "url" : ...,                   "url" : ...,
                                   "visitors" : [
    "visitors" : {
                                               {
       "pijani" : [                                "type" : "pijani",
              "pocet" : 20                        "pocet" : 20
       ],                                      },
       "nepijani" : [                          {
                                                   "type" : "nepijani"
              "pocet" : 70
                                                   "pocet" : 48
      ]                                        },
    }                               ],
}                              }


    db.pageviews.find({
         "visitors.type" : {
                "$gt" : 19
         }
    });
Martin Strýček - Ako začať s MongoDB
Šk{lovateľnosť a výkon




Funkcionalita
   Ak potrebujete datab{zu s veľa d{tami ale
    nechcete prísť o výkon.

   Ak si chcete sami definovať indexy.

   Ak potrebujete ľahko nastaviteľnú replik{ciu.

   Ak by ste miesto neho zvolili MySQL alebo
    PostgreSQL
Dačo z praxe.
{
    "_id" : ...,
    "url" : ...,
    "blog" : [
               {
                   "autor" : "ujovlado",
                   "msg" : "začal som robiť v Piano Media"
              },
              {
                   "autor" : "rootpd",
                   "msg" : " ja tam robím tiež"
              },
    ],
}



Nebojte sa duplikovať
dáta
{
    "_id" : ...,
    "url" : ...,
    "visits" : [
            "hours" : [
                     [0,0,0,0……0],
                     [0,0,0,0……0],
                     …
                     [0,0,0,0……0]
            ]
    ],
}




Nachystajte si miesto
   Podmienka A vráti 25 000 dokumentov
   Podmienka B vráti 8 000 dokumentov
   Podmienka C vráti 2 000 dokumentov




Keď píšete dotazy
rozmýšľajte
Martin Strýček - Ako začať s MongoDB
1 of 26

Recommended

CodeCon 2015 - Také slovenské startupovanie by
CodeCon 2015 - Také slovenské startupovanieCodeCon 2015 - Také slovenské startupovanie
CodeCon 2015 - Také slovenské startupovanieJozef Prídavok
544 views21 slides
An Introduction To Palomino by
An Introduction To PalominoAn Introduction To Palomino
An Introduction To PalominoLaine Campbell
1.9K views35 slides
C++ Interface Versioning by
C++ Interface VersioningC++ Interface Versioning
C++ Interface VersioningSkills Matter
3.1K views37 slides
WebElement #22: Peter Slivka - Úvod do AWS by
WebElement #22: Peter Slivka - Úvod do AWSWebElement #22: Peter Slivka - Úvod do AWS
WebElement #22: Peter Slivka - Úvod do AWSwebelement
1K views53 slides
WebElement #20: Ondrej Svitek - Hacking Life With Git by
WebElement #20: Ondrej Svitek - Hacking Life With GitWebElement #20: Ondrej Svitek - Hacking Life With Git
WebElement #20: Ondrej Svitek - Hacking Life With Gitwebelement
1.8K views21 slides
Ján Kmeťko - NoSQL a distribuované databázy – pohľad zhora na konzistentnosť ... by
Ján Kmeťko - NoSQL a distribuované databázy – pohľad zhora na konzistentnosť ...Ján Kmeťko - NoSQL a distribuované databázy – pohľad zhora na konzistentnosť ...
Ján Kmeťko - NoSQL a distribuované databázy – pohľad zhora na konzistentnosť ...webelement
1.7K views22 slides

More Related Content

Featured

ChatGPT and the Future of Work - Clark Boyd by
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
22K views69 slides
Getting into the tech field. what next by
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
5.3K views22 slides
Google's Just Not That Into You: Understanding Core Updates & Search Intent by
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
6.1K views99 slides
How to have difficult conversations by
How to have difficult conversations How to have difficult conversations
How to have difficult conversations Rajiv Jayarajah, MAppComm, ACC
4.6K views19 slides
Introduction to Data Science by
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data ScienceChristy Abraham Joy
82.2K views51 slides
Time Management & Productivity - Best Practices by
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
169.7K views42 slides

Featured(20)

ChatGPT and the Future of Work - Clark Boyd by Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd22K views
Getting into the tech field. what next by Tessa Mero
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero5.3K views
Google's Just Not That Into You: Understanding Core Updates & Search Intent by Lily Ray
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray6.1K views
Time Management & Productivity - Best Practices by Vit Horky
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky169.7K views
The six step guide to practical project management by MindGenius
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius36.6K views
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright... by RachelPearson36
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson3612.6K views
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present... by Applitools
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools55.4K views
12 Ways to Increase Your Influence at Work by GetSmarter
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter401.6K views
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G... by DevGAMM Conference
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference3.6K views
Barbie - Brand Strategy Presentation by Erica Santiago
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago25.1K views
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well by Saba Software
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software25.2K views
Introduction to C Programming Language by Simplilearn
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
Simplilearn8.4K views
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr... by Palo Alto Software
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
Palo Alto Software88.3K views
9 Tips for a Work-free Vacation by Weekdone.com
9 Tips for a Work-free Vacation9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation
Weekdone.com7.2K views
How to Map Your Future by SlideShop.com
How to Map Your FutureHow to Map Your Future
How to Map Your Future
SlideShop.com275.1K views

Martin Strýček - Ako začať s MongoDB

  • 1. { author:"Martin Strýček", twitter:"@martin_strycek", about:"Ako začať s MongoDB" }
  • 2. NoSQL a RDBMS pohľad na svet.
  • 3. “640kB of memory should be enough for anybody.” -Bill Gates (1981)
  • 4. byte Kilobyte 1,024 Megabyte 1,048,576 “640K of memory should be Gigabyte 1,073,741,824 enough for anybody.” Terabyte 1,099,511,627,776 Petabyte 1,125,899,906,842,624 Exabyte 1,152,921,504,606,846,976 Zettabyte 1,180,591,620,717,411,303,425
  • 5. RDBMS NoSQL  Relácie  Vnorené objekty  ACID (atomicity,  Rýchlosť consistency, isolation, durability) Základné rozdiely
  • 6. Čo vlastne je mongoDB a ako funguje?
  • 7. MongoDB od slova "humongous“ je šk{lovateľn{, výkonná, open source NoSQL databáza. strycek@webserverba:~$ mongo 192.168.122.20:27017
  • 8. strycek@webserverba:~$ mongo 192.168.122.20:27017 MongoDB shell version: 1.4.4  MongoDB je databáza url: 192.168.122.20:27017 connecting to: 192.168.122.20:27017/test type "help" for help > > use harvester
  • 9. strycek@webserverba:~$ mongo 192.168.122.20:27017 MongoDB shell version: 1.4.4  MongoDB je databáza url: 192.168.122.20:27017  obsahujúca kolekcie (tabuľka) connecting to: 192.168.122.20:27017/test type "help" for help > use harvester switched to db harvester > db.pageviews
  • 10. MongoDB je databáza  obsahujúca kolekcie (tabuľka)  kolekcie obsahujú dokumenty (riadky) > db.pageviews.insert({})
  • 11. MongoDB je databáza  obsahujúca kolekcie (tabuľka)  kolekcie obsahujú dokumenty (riadky)  dokumenty obsahujú množinu polí (stĺpce) > db.pageviews.insert({url : "http://webelement.sk" })
  • 13. BSON = binary-encoded serialization of JSON-like documents
  • 14. BSON = binary-encoded serialization of JSON-like documents  maxim{lna veľkosť jedného dokumentu je 16MB  pre väčšie d{ta máme GridFS  Súbory  Kúsky
  • 15. { "_id" : ObjectId("4fcfd8db962e3f275a2847d6"), "url" : "http://webelement.sk", "visitor" : 1 } { "_id" : ObjectId("4fcfd8db962e3f275a2847d7"), "date" : "Thu Jun 07 2012 00:00:00 GMT+0200 (CET)", "url" : "http://webelement.sk", "visitor" : 225, "logged-in" : 55225 } db.pageviews.find();
  • 16. { "_id" : ObjectId("4fcfd8db962e3f275a2847d6"), "url" : "http://webelement.sk", } { "_id" : ObjectId("4fcfd8db962e3f275a2847d7"), "url" : "http://webelement.sk", } db.pageviews.find( {url:”http://webelement.sk”}, {url:1} );
  • 17. Kedy je vhodný čas prejsť na MongoDB?
  • 18. { { "_id" : ..., "_id" : ..., "url" : ..., "url" : ..., "visitors" : [ "visitors" : { { "pijani" : [ "type" : "pijani", "pocet" : 20 "pocet" : 20 ], }, "nepijani" : [ { "type" : "nepijani" "pocet" : 70 "pocet" : 48 ] }, } ], } } db.pageviews.find({ "visitors.type" : { "$gt" : 19 } });
  • 21. Ak potrebujete datab{zu s veľa d{tami ale nechcete prísť o výkon.  Ak si chcete sami definovať indexy.  Ak potrebujete ľahko nastaviteľnú replik{ciu.  Ak by ste miesto neho zvolili MySQL alebo PostgreSQL
  • 23. { "_id" : ..., "url" : ..., "blog" : [ { "autor" : "ujovlado", "msg" : "začal som robiť v Piano Media" }, { "autor" : "rootpd", "msg" : " ja tam robím tiež" }, ], } Nebojte sa duplikovať dáta
  • 24. { "_id" : ..., "url" : ..., "visits" : [ "hours" : [ [0,0,0,0……0], [0,0,0,0……0], … [0,0,0,0……0] ] ], } Nachystajte si miesto
  • 25. Podmienka A vráti 25 000 dokumentov  Podmienka B vráti 8 000 dokumentov  Podmienka C vráti 2 000 dokumentov Keď píšete dotazy rozmýšľajte