4-NoSQL _v1_
4-NoSQL _v1_
Databases (v1)
Juan Manuel Gimeno Illa
[email protected]
Bibliography
❖ Key-value
Aggregate ❖ Document
Schemaless orientation
orientation ❖ Wide-column
❖ Graph
• Normalized
• no duplication
• Referential integrity
db.inventory.insertMany([
{ item: "journal", qty: 25, size: { h: 14, w: 21, uom: "cm" }, status: "A" },
{ item: "notebook", qty: 50, size: { h: 8.5, w: 11, uom: "in" }, status: "A" },
{ item: "paper", qty: 100, size: { h: 8.5, w: 11, uom: "in" }, status: "D" },
{ item: "planner", qty: 75, size: { h: 22.85, w: 30, uom: "cm" }, status: "D" },
{ item: "postcard", qty: 45, size: { h: 10, w: 15.25, uom: "cm" }, status: "A" }
]);
db.inventory.replaceOne(
{ item: "paper" },
{ item: "paper", instock: [ { warehouse: "A", qty: 60 }, { warehouse: "B", qty: 40 } ] }
)
db.inventory.updateOne( db.inventory.updateMany(
{ item: "paper" }, { "qty": { $lt: 50 } },
{ $set: { $set:
{ "size.uom": "cm", status: "P" }, { "size.uom": "in", status: "P" },
$currentDate: $currentDate:
{ lastModified: true } { lastModified: true }
}) })
db.orders.aggregate( [
// Stage 1: Filter pizza order documents by pizza size
{ $match: { size: "medium" } },
// Stage 2: Group remaining documents by pizza name and calculate total quantity
{ $group: { _id: "$name", totalQuantity: { $sum: "$quantity" } } }
])
db.collection.createIndex( { name: -1 } )
db.people.find(
{ name: "John Doe", zipcode: { $gt: "63000" } }
).hint( { zipcode: 1 } ).explain("executionStats")
[Neo4j Documentation]
2024/2025 Ampliació de BBDD i EP 92
Neo4j
• Neo4j Graph Database
• Core product
• Neo4j Aura
• AuraDB database as a service
• Neo4j Sandbox
• Database in the cloud to do initial experiments
• Neo4j Developer Tools
• Desktop / Browser / Data Importer / Operations Manager / Bloom
• Neo4j Graph Examples
[Neo4j Documentation]
[Neo4j Documentation]