SlideShare una empresa de Scribd logo
1 de 26
{
    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
         }
    });
Š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

Más contenido relacionado

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - 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 Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
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
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
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...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - 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
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
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
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
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...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

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 } });
  • 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