RMIT University
COSC2406/2407 Database Systems Tutorial Exercises
These questions relate MongoDB and also to the readings from: Pramod J. Sadalage and Martin Fowler, NoSQL: A Brief Guide to the Emerging World of Polygot Persistence, Addison-Wesley, 2013.
NoSQL databases: Week 2
1. Shown below is a data file consisting of records of the form (Student Name, Age, Student ID, Course ID, Course Name, Exam Mark).
Meier, 25, 0815A, COSC2406, “Database Systems”, 77
Meier, 25, 0815A, COSC1127, “Artificial Intelligence”, 33
Meier, 25, 0815A, COSC2110, “Data Mining”, 54
Bierhoff, 31, 5321A, COSC2406, “Database Systems”, 82
Bierhoff, 31, 5321A, COSC1127, “Artificial Intelligence”, 76
Hrubesch, 49, 6353L, COSC2406, “Database Systems”, 42
Beckenbauer, 52, 4113Y, COSC2406, “Database Systems”, 76
(a) How could this be designed using an aggregate data model for a NoSQL database such as MongoDB? Show how the data would be represented using JSON format.
(b) Are there alternative designs?
2. For each design from the previous question write MongoDB queries to find the following:
(a) Which courses was Bierhoff enrolled in?
(b) How many students are enrolled in COSC2406?
(c) What percentage of students passed COSC2406 exam (i.e. exam mark greater than or equal to 50)?
(d) Which students are only enrolled in COSC2406?
3. Discuss the circumstances concerning when it is more appropriate to use a NoSQL database (such as MongoDB) compared with when it is more appropriate to use a relational database?
COSC2406/2407 Tutorial Exercises 1