CS440 – Assignment 6

NoSQL March 2, 2017
The assignment is to be turned in before Midnight (by 11:59pm) on March 9th, 2017. You should turn in the solutions to this assignment as a PDF file through the TEACH website. The solutions should be produced using editing software programs, such as LaTeX or Word, otherwise they will not be graded.
Two Phase Commit (2 points)
Explain the actions taken in the two phase commit protocol after restart if the coordinator or subordinate nodes fail.
Eventual consistency and vector clocks(2 points)
Each row in the following table shows vector clocks of different copies of the same data on a system with three nodes SX, SY , and SZ. Explain if the following copies have a conflict.
Table 1: Vector clocks
Multi-version concurrency control (2 points)
Consider transactions T1, T2, T3 with timestamps 10, 20, and 30, respectively in a database system that follows multi-version concurrency control protocol. T1 is a reader and T2 and T3 are writer transactions. Provide a schedule in which the multi-version concurrency control method restarts T2.
MongoDB (6 points)
In this part, you will work with a MongoDB database. In order to have access to your database, you should be on campus, use OSU VPN or SSH to an engineering server. First you need to download and import the Restaurants database to your DBMS. You can download the database from here. Then, you should use the following command to import the data (username, password and db-name is cs440_):

Copy 1
Copy 2
([SX ,10],[SY ,50],[SZ ,10])
([SX ,10],[SY ,100])
1
mongoimport –db –collection restaurants –drop
–file

–host classmongo.engr.oregonstate.edu
-u -p Next connect to your MongoDB using the following command:
mongo -u -p classmongo.engr.oregonstate.edu/
It is recommended that you change your password the first time you connect to the database. You can use the following command to change it:
db.changeUserPassword(’cs440_’,’newpass’)
Next you should go over the tutorial of the commands that you will need in this assignment. For part a, you need to use the find command. You may find a tutorial for it here here. For part b & c you need to do text search explained here and for the last part go through this tutorial. After connecting to the database execute the findOne() command to see a sample document. This will help you to understand the structure of the documents.
a. Write a query that returns the cuisine type of the restaurant named ”The Dead Rabbit” (1 point).
b. Write a query to create an index on the name attribute of the restaurants (1.5 points).
c. Write a query that uses the index created in part b to return all the restaurants containing
the term “Rabbit” in their name(1.5 points).
d. Write an aggregate query to show total count of restaurants in each borough (2 points).

发表评论

电子邮件地址不会被公开。 必填项已用*标注