0% found this document useful (0 votes)
4 views3 pages

MongoDB Exam Review Guide

Uploaded by

nntnguyen1501iuh
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)
4 views3 pages

MongoDB Exam Review Guide

Uploaded by

nntnguyen1501iuh
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

De Cuong On Tap MongoDB Cuoi Ky

Cau 1: Import du lieu tu file JSON

1.1 Tao database theo MSSV:

use 20075751

1.2 Import cac file JSON vao dung collection:

mongoimport --drop -d 20075751 -c dangKyHP [Link]

mongoimport --drop -d 20075751 -c khoa [Link]

mongoimport --drop -d 20075751 -c lopHoc [Link]

mongoimport --drop -d 20075751 -c monHocPhan [Link]

mongoimport --drop -d 20075751 -c sinhVien [Link]

Cau 2: Truy van voi Aggregate

2.1 Danh sach sinh vien co diem trung tuyen >= 15:

[Link]([

{ $match: { diemTrungTuyen: { $gte: 15 } } },

{ $project: { _id: 1, hoTen: 1, gioiTinh: 1 } }

])

2.2 Thong ke so luong sinh vien theo tung lop:

[Link]([

{ $group: { _id: "$maLop", soLuong: { $sum: 1 } } }

])

2.3 Danh sach cac mon hoc lap trinh:

[Link]([

{ $match: { tenHP: /^Laptrinh/ } },

{ $project: { _id: 0, maHP: 1, tenHP: 1, soTC: 1 } }

])
De Cuong On Tap MongoDB Cuoi Ky

2.4 Khoa co chuyen nganh diemTT = 23 va tongTC > 140:

[Link]([

{ $unwind: "$chuyenNganh" },

{ $match: {

"[Link]": 23,

"[Link]": { $gt: 140 }

}}

])

2.5 Xuat thong tin sinh vien tu bang dang ky hoc phan:

[Link]([

{ $lookup: {

from: "sinhVien",

localField: "maSV",

foreignField: "maSV",

as: "sv"

}},

{ $unwind: "$sv" },

{ $project: {

_id: 0,

"sv._id": 1,

"[Link]": 1,

"[Link]": 1,

"[Link]": 1

}}

])

Cau 3: Thong ke luot dang ky hoc phan nam 2022

[Link]([

{ $unwind: "$dangKyHP" },
De Cuong On Tap MongoDB Cuoi Ky

{ $match: { "[Link]": "2022" } },

{ $group: {

_id: "$[Link]",

soluong: { $sum: 1 }

}}

])

Cau 4: Export du lieu

4.1 Export collection sinhVien sang BSON:

mongodump -d thi -c sinhVien -o ./[Link]

4.2 Export sinh vien co tong diem > 25 sang collection thongKeDiemThi:

[Link]([

{ $match: { tongDiem: { $gt: 25 } } },

{ $sort: { tongDiem: 1 } },

{ $out: { db: "thi", coll: "thongKeDiemThi" } }

])

You might also like