Successfully reported this slideshow.
Your SlideShare is downloading. ×

MongoDB.pptx

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Mongo db
Mongo db
Loading in …3
×

Check these out next

1 of 57 Ad

More Related Content

Recently uploaded (20)

Advertisement

MongoDB.pptx

  1. 1. Sigit Kurniawan, M.Kom MongoDB
  2. 2. Contents • SQL vs NoSQL • NoSQL Features & Types • What is MongoDB? • MongoDB Features • MongoDB Data Types • Installation MongoDB on Windows • MongoDB CRUD Operations • Node.js with MongoDB
  3. 3. SQL vs NoSQL
  4. 4. SQL VS NoSQL • NoSQL (often interpreted as Not only SQL) database • It provides a mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used in relational databases. SQL NoSQL Relational Database Management System (RDBMS) Non-relational or distributed database system. These databases have fixed or static or predefined schema They have dynamic schema These databases are best suited for complex queries These databases are not so good for complex queries Vertically Scalable Horizontally scalable Follows ACID property Follows BASE property
  5. 5. SQL VS NoSQL • ACID Properties: 1. Atomicity; The entire transaction takes place at once or doesn't happen at all 2. Consistency; The database is consistent before and after the transaction 3. Isolation; Multiple transactions occur independently without interference 4. Durability; The changes of successful transaction occurs even if the systems failure occurs Relational Databases Durability Isolation Atomicity Consistency ACID
  6. 6. SQL VS NoSQL • CAP Properties: 1. Consistency; that the nodes will have the same copies of a replicated data item visible for various transactions 2. Availability; that each read or write request for a data item will either be processed successfully or will receive a message that the operation cannot be completed 3. Partition tolerance; the system can continue operating even if the network connecting the nodes has a fault that results in two or more partitions, where the nodes in each partition can only communicate among each other. NoSQL Databases Consistency Availability Partition tolerance CAP
  7. 7. NoSQL Features & Types
  8. 8. NoSQL Features & Types Fexible Schemas Horizotal scaling Fast queries due to the data model Ease of use for developers FEATURES
  9. 9. NoSQL Features & Types Fexible Schemas Horizotal scaling Fast queries due to the data model Ease of use for developers FEATURES Document databases Wide-column stores Key-value databases Graph databases TYPES
  10. 10. What is MongoDB?
  11. 11. What is MongoDB ? A database management system designed to rapidly develop web applications and internet infrastructure. A general-purpose document database designed for modern application development and for the cloud. A good NoSQL document database with a range of features that, in the open-source NoSQL world, are hard to beat.
  12. 12. What is MongoDB ? A database management system designed to rapidly develop web applications and internet infrastructure. A general-purpose document database designed for modern application development and for the cloud. A good NoSQL document database with a range of features that, in the open-source NoSQL world, are hard to beat. Document-Oriented, No Sequel (NoSQL)
  13. 13. What is MongoDB ? Database Collections MongoDB stores data as JSON/BSON (Binary JSON) documents In MongoDB, a collection is a group of documents
  14. 14. MongoDB Features
  15. 15. MongoDB Features High Performance Auto Replication Horizontal Scalability Load Balancing High Availability Indexing
  16. 16. MongoDB Data Types
  17. 17. MongoDB Data Types • String This is the most commonly used datatype to store the data. String in MongoDB must be UTF-8 valid. • Integer This type is used to store a numerical value. Integer can be 32 bit or 64 bit depending upon your server. • Double This type is used to store floating point values. • Date This datatype is used to store the current date or time in UNIX time format. You can specify your own date time by creating object of Date and passing day, month, year into it. • Boolean This type is used to store a boolean (true/ false) value.
  18. 18. MongoDB Data Types • Object ID This datatype is used to store the document’s ID. • Array This type is used to store arrays or list or multiple values into one key. • Timestamp ctimestamp. This can be handy for recording when a document has been modified or added. • Code This datatype is used to store JavaScript code into the document. • Regular Expression This datatype is used to store regular expression.
  19. 19. Installation MongoDB on Windows
  20. 20. Installation on Windows • Step 1: Go to MongoDB download Page and click download as shown in the screenshot. A .msi file like this mongodb-win32-x86_64-2008plus-ssl- 3.4.7-signed will be downloaded in your system. Double click on the file to run the installer.
  21. 21. Installation on Windows • Step 2: Click Run when the MongoDB installation windows pops up.
  22. 22. Installation on Windows • Step 3: Click Next when the MongoDB installation windows pops up.
  23. 23. Installation on Windows • Step 4: Accept the MongoDB user Agreement and click Next.
  24. 24. Installation on Windows • Step 5: When the setup asks you to choose the Setup type, choose Complete.
  25. 25. Installation on Windows • Step 6: Click Next when the MongoDB service configuration. MongoDB will be installed in the windows service
  26. 26. Installation on Windows • Step 7: Choose Install MongoDB Compass if you want to use the MongoDB User Interface, or ignore it and continue by clicking Next in the Install MongoDB Compass window
  27. 27. Installation on Windows • Step 8: Click Install to begin the installation.
  28. 28. MongoDB CRUD Operations
  29. 29. MongoDB CRUD RDBMS MongoDB Database Database Table Collection Tuple/Row Document column Field Table Join Embedded Documents Primary Key Primary Key (Default key _id provided by MongoDB itself)
  30. 30. MongoDB CRUD CREATE DATABASE MongoDB use DATABASE_NAME is used to create database. The command will create a new database if it doesn't exist, otherwise it will return the existing database.
  31. 31. SQL Create Database • SQL Server CREATE DATABASE databasename; Example: CREATE DATABASE testdb; • MySQL CREATE DATABASE databasename; Example: CREATE DATABASE testdb;
  32. 32. MongoDB CRUD INSERT DOCUMENT Single Insert Multiple Insert
  33. 33. SQL Insert Query • SQL Server  Single INSERT INTO tablename (c1,c2,...) VALUES (v11,v12,...);  Multiple INSERT INTO tablename (c1,c2,...) VALUES (v11,v12,...), (v21,v22,...), ….. , (vnn,vn2,...); • MySQL  Single INSERT INTO tablename (c1,c2,...) VALUES (v11,v12,...);  Multiple INSERT INTO tablename (c1,c2,...) VALUES (v11,v12,...), (v21,v22,...), ….. , (vnn,vn2,...);
  34. 34. MongoDB CRUD INSERT DOCUMENT - SINGLE
  35. 35. MongoDB CRUD INSERT DOCUMENT - MULTIPLE
  36. 36. MongoDB CRUD QUERY DOCUMENTS Select All Documents Specify Equality Specify Conditions Using Query Operators SELECT * FROM tablename; SELECT * FROM tablename WHERE column; SELECT * FROM tablename WHERE columnname IN ;
  37. 37. MongoDB CRUD SELECT ALL DOCUMENTS
  38. 38. MongoDB CRUD SPECIFY EQUALITY
  39. 39. MongoDB CRUD SPECIFY CONDITIONS USING QUERY OPERATORS
  40. 40. MongoDB CRUD QUERY DOCUMENTS Specify “AND” Conditions Specify “OR” Conditions Specify “AND” as well as “OR” Conditions
  41. 41. MongoDB CRUD SPECIFY “AND” CONDITIONS
  42. 42. MongoDB CRUD SPECIFY “OR” CONDITIONS
  43. 43. MongoDB CRUD SPECIFY “AND” AS WELL AS “OR” CONDITIONS
  44. 44. MongoDB CRUD UPDATES DOCUMENTS Single Update Updates a single document within the collection based on the filter.
  45. 45. SQL Update Query • SQL Server UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition; • MySQL UPDATE table_name SET column_name1 = expr1, column_name2 = expr2, ... WHERE condition;
  46. 46. MongoDB CRUD UPDATES DOCUMENTS
  47. 47. MongoDB CRUD UPDATES DOCUMENTS Multiple Update Updates all documents that match the specified filter for a collection.
  48. 48. MongoDB CRUD UPDATES DOCUMENTS
  49. 49. MongoDB CRUD UPDATES DOCUMENTS Replace One Replaces a single document within the collection based on the filter.
  50. 50. MongoDB CRUD UPDATES DOCUMENTS
  51. 51. MongoDB CRUD DELETE DOCUMENTS Single Delete
  52. 52. SQL Delete Query • SQL Server DELETE FROM table_name WHERE condition; • MySQL DELETE FROM table_name WHERE condition;
  53. 53. MongoDB CRUD DELETE DOCUMENTS
  54. 54. MongoDB CRUD DELETE DOCUMENTS Multiple Delete
  55. 55. MongoDB CRUD DELETE DOCUMENTS
  56. 56. Node.js with MongoDB

Editor's Notes

  • MongoDB memberikan kinerja tinggi (High Performance). Sebagian besar operasi di MongoDB lebih cepat dibandingkan dengan database relasional.
    MongoDB menyediakan fitur replikasi otomatis (Auto Replication) yang memungkinkan Anda memulihkan data dengan cepat jika terjadi kegagalan.
    Penskalaan horizontal (Horizontal Scalability) dimungkinkan di MongoDB karena berbagi. Sharding adalah mempartisi data dan menempatkannya di beberapa mesin sedemikian rupa sehingga urutan data dipertahankan. Penskalaan horizontal vs penskalaan vertikal: Penskalaan vertikal berarti menambahkan lebih banyak sumber daya ke mesin yang ada sementara penskalaan horizontal berarti menambahkan lebih banyak mesin untuk menangani data. Penskalaan vertikal tidak mudah diimplementasikan, di sisi lain penskalaan horizontal mudah diimplementasikan. Contoh basis data penskalaan horizontal: MongoDB, Cassandra dll.
    Penyeimbangan beban (Load Balancing): Penskalaan horizontal memungkinkan MongoDB untuk menyeimbangkan beban.
    Ketersediaan Tinggi (High Avalaibility): Replikasi Otomatis meningkatkan ketersediaan database MongoDB.
    Pengindeksan (Indexing): Indeks adalah bidang tunggal dalam dokumen. Indeks digunakan untuk menemukan data dengan cepat tanpa harus mencari setiap dokumen dalam database MongoDB. Ini meningkatkan kinerja operasi yang dilakukan pada database MongoDB.

×