0% found this document useful (0 votes)
81 views9 pages

Semistructured Data

The document contains an array of objects with fields like name, age, favorites, and badges, with one object having an embedded array of sub-objects with fields like points and bonus. It also contains an unnamed array of tuples with only name and age fields. The structures show examples of common MongoDB data types like dictionaries, arrays, embedded documents, and tuples.

Uploaded by

Sofia Varma Kola
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views9 pages

Semistructured Data

The document contains an array of objects with fields like name, age, favorites, and badges, with one object having an embedded array of sub-objects with fields like points and bonus. It also contains an unnamed array of tuples with only name and age fields. The structures show examples of common MongoDB data types like dictionaries, arrays, embedded documents, and tuples.

Uploaded by

Sofia Varma Kola
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

[

{
_id: 1,
Key-value pair
name: "sue",
(key à value)
age: 19,
type: 1,
status: "P", Named Tuple
favorites: { artist: "Picasso", food: "pizza" }, (Tuple-key à tuple)
finished: [ 17, 3 ], (Tuple-key, attrib-keyàattrib-value)
Named Array
badges: [ "blue", "black" ], (Array-keyàarray)
points: [ (Array-key, position à array-element)
{ points: 85, bonus: 20 }, (Array-key, value-list à matching-values)
{ points: 75, bonus: 10 }
]
},
{ Named Array of unnamed Tuples
_id: 2,
name: “john”,
age: 21
}
]
• How many
• results to
return etc.

db.collection.find( <query filter>, <projection> ).<cursor modifier>

Like FROM clause, Projection variables


specifies the Like WHERE clause, in SELECT clause
collection to use specifies which
documents to return











• { beer: 1, price: 1, _id: 0}










Symbol 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.
$or Joins query clauses with a logical OR.
$and Joins query clauses with a logical AND.
$not Inverts the effect of a query expression.
$nor Joins query clauses with a logical NOR.
URL For MongoDB operators
https://docs.mongodb.com/manual/reference/operator/query/






• { _id: 1,
• item: “bud",
qty: 10,
• not nor tags: [ “popular”, “summer”,
“Japanese”],
• rating: “good” }


Skip count Return how many





{ _id: 1,
item: “bud",
[ qty: 10,
tags: [ “popular”, “summer”,
{ $or : [ { price : 3.99 }, { price : 4.99 } ] }, “Japanese”],
rating: “good”,
{ $or : [ { rating : good }, { qty : { $lt : 20 } } ] } price: 3.99 }
{item: {$ne: “Coors”}}
]
SELECT * FROM inventory
WHERE ((price = 3.99) OR (price=4.99)) AND
((rating = “good”) OR (qty < 20)) AND
item != “Coors”
_id: 1, •
points: [
{ points: 96, bonus: 20 }, •
{ points: 35, bonus: 10 } • {
] }
_id: 2,
points: [ MongoDB does not have adequate support to
{ points: 53, bonus: 20 }, perform recursive queries over nested
{ points: 64, bonus: 12 } substructures
]
_id: 3,
points: [
{ points: 81, bonus: 8 },
{ points: 95, bonus: 20}
]

You might also like