Internet Engineering
NoSQL · Distribution · MongoDB · Documents · Operations
Fall 2026 ·
Amirkabir University of Technology
@1995parham
Originally presented by Ehsan Edalat and Parham Alvani. The original slides are also available as a PowerPoint file.
| RDBMS | MongoDB |
|---|---|
| Database | Database |
| Table, View | Collection |
| Row | Document (BSON) |
| Column | Field |
| Index | Index |
| Join | Embedding, or $lookup |
| Primary key | _id |
mongod: the database servermongos: the router in front of a sharded
clustermongosh: the shell, a full JavaScript
environment
{ "_id": 1, "name": "R2-D2", "race": "Droid", "affiliation": "rebels" }
{ "_id": 2, "name": "Han Solo", "ship": "Millennium Falcon" }
{
"name": "IE",
"teacher": "Parham Alvani",
"students": [{ "first_name": "Parham", "id": "9231058" }],
"capacity": 30
}
// create
db.students.insertOne({ name: "Parham", id: "9231058" });
db.students.insertMany([{ name: "Ali" }, { name: "Sara" }]);
// read
db.students.find({ name: "Parham" });
db.students.findOne({ id: "9231058" });
// update
db.students.updateOne({ id: "9231058" }, { $set: { name: "Parham Alvani" } });
// delete
db.students.deleteOne({ id: "9231058" });
Documents flow through stages, each one transforming the stream.
// keep the big courses, count them per teacher, busiest first
db.courses.aggregate([
{ $match: { capacity: { $gt: 20 } } },
{ $group: { _id: "$teacher", total: { $sum: 1 } } },
{ $sort: { total: -1 } },
]);
const studentSchema = new mongoose.Schema({
name: { type: String, required: true },
id: { type: String, unique: true },
});
const Student = mongoose.model("Student", studentSchema);
