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

1 Introducing ASML Enumerations, Conditionals and Loops, Quantifiers Lecture 13 Software Engineering COMP201.
CSE 1561 A Brief MySQL Primer Stephen Scott. CSE 1562 Introduction Once you’ve designed and implemented your database, you obviously want to add data.
Instructor: Craig Duckett CASE, ORDER BY, GROUP BY, HAVING, Subqueries
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
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.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
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.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
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.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation MongoDB Aggregation.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Lesson 13 Databases Unit 2—Using the Computer. Computer Concepts BASICS - 22 Objectives Define the purpose and function of database software. Identify.
Module 3: Using XML. Overview Retrieving XML by Using FOR XML Shredding XML by Using OPENXML Introducing XQuery Using the xml Data Type.
# 1# 1 QueriesQueries How do we ask questions of the data? What is SELECT? What is FROM? What is WHERE? What is a calculated field? Spring 2010 CS105.
Introduction to MongoDB. Database compared.
IST 220 – Intro to DB Lab 2 Specifying Criteria in SELECT Statements.
1 CS 430 Database Theory Winter 2005 Lecture 13: SQL DML - Modifying Data.
Access Queries and Forms. Adding a New Field  To insert a field after you have saved your table, open Access, and open the table  It is easier to add.
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.
Select Complex Queries Database Management Fundamentals LESSON 3.1b.
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:
SQL SQL Ayshah I. Almugahwi Maryam J. Alkhalifa
Mongo Database (Intermediate)
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Chapter 5 Introduction to SQL.
MySQL Subquery Source: Dev.MySql.com
Lecturer : Dr. Pavle Mogin
CC Procesamiento Masivo de Datos Otoño 2017 Lecture 10: NoSQL II
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
Advanced select statement Join Other DML commands
Instructor: Craig Duckett Lecture 09: Tuesday, April 25th, 2017
ATS Application Programming: Java Programming
Sequence, Selection, Iteration The IF Statement
Lecturer : Dr. Pavle Mogin
Introduction To Codeigniter
Microsoft Office Illustrated Fundamentals
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,
Structured Query Language (SQL) William Klingelsmith
CIS16 Application Programming with Visual Basic
Subsetting Rows with the WHERE clause
Control Structures: for & while Loops
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
Chapter 8 Advanced SQL.
MongoDB Read.
PowerShell Flow of Control Copyright © 2016 – Curt Hill.
INTRODUCTION TO MONgodb
MongoDB Aggregations.
Database Systems: Design, Implementation, and Management Tenth Edition
MongoDB Read Operations
REPETITION Why Repetition?
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 (Comparisons) 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 (Comparisons) Name Description $eq db.restaurants.find({"address.building": {$eq: "195"}}).pretty() $gt db.restaurants.find({"address.zipcode": {$gt: "10020"}}).pretty() $gte db.restaurants.find({"address.zipcode": {$gte: "10020"}}).pretty() $lt db.restaurants.find({"address.zipcode": {$lt: "10045"}}).pretty() $lte db.restaurants.find({"address.zipcode": {$lte: "10020"}}).pretty() $ne db.restaurants.find({"borough": {$ne: "Manhattan"}}).pretty() $in db.restaurants.find({"address.zipcode": {$in: ["10020", "10021", "10022"]}}).pretty() $nin db.restaurants.find({"address.zipcode": {$nin: ["10020", "10021", "10022"]}}).pretty()

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.

Query Selectors (Logical) Name Description $or db.restaurants.find({ $or: [{"cuisine": "Italian"}, {"address.zipcode": "10075"}]}).pretty() $and db.restaurants.find({ $and: [{"cuisine": "Italian"}, {"address.zipcode": "10075"}]}).pretty() $not db.restaurants.find({"cuisine": {$not: {$eq: "Italian"}}}).pretty()

Nested Fields Use “dot notation” db.restaurants.find( { "address.zipcode": "10075" } ) db.restaurants.find( { "grades.score": { $gt: 30 } } )

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.restaurants.find({"cuisine": "Bakery"}, {"name": 1, "address": 1 }).pretty() {"address": 0, "grades": 0 {"name": 1, "address": 1, "_id": 0