MongoDB Read/Write.

Slides:



Advertisements
Similar presentations
IF statement (i) Single statement. IF ( logical expression ) statement Example: read(*,*) a if (a. lt. 0) a = -a write(*,*) a Or read(*,*) a if (a < 0)
Advertisements

Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
Creating a Blank Database 1. Open up Microsoft Access 2. Click on Blank document button 3. On the right panel, Specify the location for saving your database.
Structured Query Language Part I Chapter Three CIS 218.
Microsoft Access 2010 Chapter 7 Using SQL.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Read Lecturer.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Write Lecturer.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
Chapter 10 Queries and Updating Part C. SQL Copyright 2005 Radian Publishing Co.
You can use a query to view a subset of your data or to answer questions about your data. For example, if you want to view a list of student names and.
MongoDB An introduction. What is MongoDB? The name Mongo is derived from Humongous To say that MongoDB can handle a humongous amount of data Document.
South Dakota Library Network MetaLib Management Basics Customizing QuickSets South Dakota Library Network 1200 University, Unit 9672 Spearfish, SD
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Aggregation.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Advanced MongoDB & FireDAC
PeopleSoft Financials Advanced Query Training Financial Information Systems and Reporting Controller’s Division
Introduction to MongoDB. Database compared.
1 CS 430 Database Theory Winter 2005 Lecture 13: SQL DML - Modifying Data.
CSC314 DAY 8 Introduction to SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL OVERVIEW  Structured Query Language  The.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
By: Eliav Menachi.  On Android, all application data (including files) are private to that application  Android provides a standard way for an application.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
Exam Friday April 11. MongoDB Specifics Find() to Query db.collection.find(, ) db.collection.find{{select conditions}, {project columns}) Selection conditions:
COMP 430 Intro. to Database Systems MongoDB. What is MongoDB? “Humongous” DB NoSQL, no schemas DB Lots of similarities with SQL RDBMs, but with more flexibility.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
Mongo Database (Intermediate)
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Chapter 5 Introduction to SQL.
Lecturer : Dr. Pavle Mogin
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
Advanced select statement Join Other DML commands
PL/SQL LANGUAGE MULITPLE CHOICE QUESTION SET-1
Sequence, Selection, Iteration The IF Statement
Lecturer : Dr. Pavle Mogin
Introduction To Codeigniter
MongoDB CRUD Operations
javascript for your data
Aggregation Aggregations operations process data records and return computed results. Aggregation operations group values from multiple documents together,
ISC440: Web Programming 2 Server-side Scripting PHP 3
Structured Query Language (SQL) William Klingelsmith
Chapter 5 Sequences.
CIS16 Application Programming with Visual Basic
Subsetting Rows with the WHERE clause
Object Oriented Programming in java
Access: SQL Participation Project
MongoDB Aggregations.
Write Operations.
MongoDB Aggregations.
MongoDB Read/Write.
Write Operations.
MongoDB Read/Write.
CC Procesamiento Masivo de Datos Otoño Lecture 9 NoSQL: MongoDB
Reporting Aggregated Data Using the Group Functions
CS5220 Advanced Topics in Web Programming Introduction to MongoDB
Chapter 8 Advanced SQL.
MongoDB Read.
PHP and MySQL.
INTRODUCTION TO MONgodb
MongoDB Aggregations.
Reporting Aggregated Data Using the Group Functions
Reporting Aggregated Data Using the Group Functions
MongoDB Read Operations
Shelly Cashman: Microsoft Access 2016
Advanced Topics: Indexes & Transactions
Presentation transcript:

MongoDB Read/Write

Agenda Query Interface Query Behavior Query Statements Insert Update Delete

Read operations Queries select documents from a single collection. db.collection.find() Find() accepts the query criteria (what to return) It returns a cursor to the document set Cursor points to the first 20 docs in the result set, is iterable. Limits can be applied. Projections return only wanted fields Limit will limit the number of documents returned

Read Operations MongoDB

Read Operations Mysql

Query Selectors (Comparasions) Name Description $eq Matches values that are equal to a specified value. $gt Matches values that are greater than a specified value. $gte Matches values that are greater than or equal to a specified value. $lt Matches values that are less than a specified value. $lte Matches values that are less than or equal to a specified value. $ne Matches all values that are not equal to a specified value. $in Matches any of the values specified in an array. $nin Matches none of the values specified in an array.

Query Selectors (Logical) Name Description $or Joins query clauses with a logical OR returns all documents that match the conditions of either clause. $and Joins query clauses with a logical AND returns all documents that match the conditions of both clauses. $not Inverts the effect of a query expression and returns documents that do not match the query expression. $nor Joins query clauses with a logical NOR returns all documents that fail to match both clauses.

Query Behavior All queries in MongoDB refer to a single collection (Ex. restaurants) Modify the results via: Limits, Skips, Sort Orders The order of the documents can be random unless you specify a sort() order. Updates also use the same syntax as Reads to select documents to update.

How Query Statements Work

Projections Queries will automatically return all fields in all matching docs by default. Limit the number of fields returned by each document with a projection Projections are the second argument in the find() method. Can specify a list of fields to return Can also specify a list of fields to exclude You cannot mix inclusive and exclusive projections together. Except for excluding the _id field in an inclusive projection.

Projections

Projection Examples db.records.find( { "user_id": { $lt: 42 } }, { "history": 0 } ) db.records.find( { "user_id": { $lt: 42 } }, { "name": 1, "email": 1 } ) db.records.find( { "user_id": { $lt: 42} }, { "_id": 0, "name": 1 , "email": 1 } )

Write Operations

Agenda Insert Update Remove

Insert MongoDB db.collection.insert() Inserts a new doc with the age, name, status, and _id fields

Insert Mysql

Insert Adding a doc without an _id field is ok. MongoDB will auto generate a unique id. If you specify the _id field, it must be unique to the current collection.

Update MongoDB Updates a document that matches the criteria Updates are atomic within a single document

Update Mysql

Update By default, update only applies to a single update Use the multi option to update multiple docs in a single query db.books.update( { stock: { $lte: 10 } }, { $set: { reorder: true } }, { multi: true } )

Upsert An update that, if the doc exists, it will do an update If the doc does not exist, it will do an insert db.people.update( { name: "Andy" }, { name: "Andy", rating: 1, score: 1 }, { upsert: true } )

Remove MongoDB Deletes doc from collection Accepts a query criteria to determine which docs to remove

Remove Mysql