Homework 9: Writing mongoDB queries
Database Systems
Spring, 2020
Due: April 28 (11:59 pm)
There are three versions of the 'moma' database on our mongoDB
server (mongodb.cs.oberlin.edu): moma, moma1, and
moma2. Each of these has two collections: Artists and
Artworks. The objective of the assigment is to gain some
experience in using mongoDB by writing queries on the moma
databases.
As you know, mongoDB databases don't have fixed schemas, but you
can see how each collection is structured by looking at a few
documents. For example. you can use the command
db.Artworks.find().limit(10)
to see the first 10 documents in the Artworks collection.
Write queries for the following on both the moma1 and moma2
versions of the database:
1. Display the name, gender, and bio of
all French artists who died between 1991 and 1995 (inclusive), in
alphabetical order.
2. Display the name and bio of all artists whose first name is
'Luis', in order by year of birth.
3. Display the name and bio of North American artists who died
while in their 20s (i.e., between the ages of 20 and 29).
4. Display the title, workdate, medium and dimensions of all
paintings with a height of at least 350 cm.
5. Display the artist's name, title, and workdate of all
bronze sculptures sculpted by French sculptors.
6. Who painted 'Introducing the Miracle'?
7. Who has collaborated with George Maciunas on a print or
sculpture? List the names of the collaborators and whether
they collaborated on a print or a sculpture; if they collaborated on
both, list them twice.
8. Display the title, classification, and medium of the self
portraits produced by Louise Bourgeois. (Look for the phrase
"self portrait" or "self-portrait" in the title.)
9. Display the objectid, title, workdate, classification, and
artist's name for those artworks whose title is the same as the
artist's name, in order by objectid.
10. Find the top 20 most productive artists; that is, the ones
with the largest number of artworks in the moma collection.
The output should contain the artist name, artist id, and number of
artworks, in descending order by the artwork count.
11. Find for each artist who has produced sculpture(s), the
maximum height of a sculpture. The output should contain the
artist name, artist id, and maximum height, and be listed in
descending order by max height. Only display the top 20
results.
12. a. For each artist, make a list of the different genres
that the artist has worked in. (Use "Classification" to
determine this.)
b. Find the top 20 most versatile artists; that is, the ones
who have worked in the largest number of genres.
In many cases, the same query will work on both of the
databases. In other cases, you'll need to write two different
versions of the query.
For each problem, try to use a single, one-line query using find()
or aggregate(). If you get stuck, you can write a script to
perform the query (but not for full credit).
Test your queries by running them on the mongoDB server.
Please write each of your queries in a separate .js file.
Use handin to submit a folder containing the .js files containing
your queries. The course number is 311 and the assignment
number is 9.