Hui Hu Ph.D.
Department of Epidemiology
College of Public Health and Health Professions & College of Medicine
February 12, 2017
NoSQL Databases and Semi-structured Data Models
Introduction to MongoDB
body
h1
p
p
li
li
Extensive Markup Language
JavaScript Object Notation
[
{
_id: 1,
name: "john",
age: 21,
type: 1,
status: "A",
favorites: {artist:"Picasso",food:"pizza"},
finished: [17,3],
badges: ["blue","black"],
points: [
{points: 85, bonus: 10},
{points: 70, bonus: 5}
]
},
{
_id: 2,
name: "mike",
age: 20
}
]
One structure can be embedded in another structure
SELECT
db.collection.find(<query filter>,<projection>).<cursor modifier>
Similar to FROM, specifies the collection to use
Similar to WHERE, specifies which documents to return
Projection variables in SELECT
How many results to return
{_id:1,
name:"John",
age:20,
courses: ["a","b","c"]}
{_id:1,
name:"John",
age:20,
courses: ["a","b","c"]}
_id:1,
points: [
{points: 90, bonus:10}
{points: 60, bonus:20}
]
_id:2,
points: [
{points: 53, bonus:20}
{points: 64, bonus:11}
]
_id:1,
points: [
{points: 99, bonus:17}
{points: 10, bonus:24}
]
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/