MongoDB Read.

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.
Week 10 Recap CSE 115 Spring For-each loop When we have a collection and want to do something to all elements of that collection we use the for-each.
Kirkwood Center for Continuing Education Introduction to PHP and MySQL By Fred McClurg, Copyright © 2010 All Rights Reserved. 1.
Introduction to ColdFusion By Tom Dubeck. Overview What is ColdFusion? How does it compare to other scripts? Some example code. Why you might want to.
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.
Objectives After completing this lesson, you should be able to do the following: Define subqueries Describe the types of problems that the subqueries.
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.
Xin  Syntax ◦ SELECT field1 AS title1, field2 AS title2,... ◦ FROM table1, table2 ◦ WHERE conditions  Make a query that returns all records.
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.
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.
 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.
Conditional Expression One of the most useful tools for processing information in an event procedure is a conditional expression. A conditional expression.
Advanced MongoDB & FireDAC
# 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.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
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:
IST 220 – Intro to DB Lab 2 Specifying Criteria in SELECT Statements.
Mongo Database (Intermediate)
Chapter 5 Introduction to SQL.
MySQL Subquery Source: Dev.MySql.com
Lecturer : Dr. Pavle Mogin
Writing Basic SQL SELECT Statements
CC Procesamiento Masivo de Datos Otoño 2017 Lecture 10: NoSQL II
University of Central Florida COP 3330 Object Oriented Programming
Sequence, Selection, Iteration The IF Statement
Lecturer : Dr. Pavle Mogin
University of Central Florida COP 3330 Object Oriented Programming
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,
Structured Query Language (SQL) William Klingelsmith
Restricting and Sorting Data
Subsetting Rows with the WHERE clause
Control Structures: for & while Loops
Object Oriented Programming in java
MongoDB Aggregations.
Write Operations.
MongoDB Aggregations.
MongoDB Read/Write.
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.
PowerShell Flow of Control Copyright © 2016 – Curt Hill.
Presented by, Mr. Satish Pise
INTRODUCTION TO MONgodb
MongoDB Aggregations.
Topic - DML - Select statement
MongoDB Read Operations
Restricting and Sorting Data
REPETITION Why Repetition?
Presentation transcript:

MongoDB Read

Agenda Query Interface Query Behavior Query Statements

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()

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