程序代写案例-CSCU9YQ

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top





Computing Science Examination
Autumn Semester 2016



CSCU9YQ: NoSQL Databases


Saturday 10 December 2016 14:00 – 15:30 hours


Attempt BOTH questions.


The distribution of marks among the parts of each question is
indicated.


IMPORTANT NOTE

Read the instructions on the front of each answer book
carefully.

It is essential that you write your student number on the front
of each answer book.

Also, when you have completed the examination, the number of
answer books that you have used must be prominently written
on the front of one book.


COMPUTING SCIENCE
& MATHEMATICS
2
CSCU9YQ
10th December 2016

Continued/

1.

(a) NoSQL databases such as MongoDB are said to be schemaless, unlike
relational databases. Explain what a database schema is in this context and
then describe what it means for a database to be schemaless. Illustrate your
answer with an example that applies to MongoDB.

(b) Replication and sharding are methods for distributing a database across a
cluster.
(i) Describe the difference between replication and sharding in terms of
how the data is spread and what is achieved by doing so.

(ii) Describe the use of a shard key in MongoDB and explain two of the
qualities you should ensure such a key possesses.

(iii) Describe the difference between a shard key based on a numeric field
and one based on a string. How does each produce a key and what is
the difference between them in terms of the relative location they
choose for two entries whose values in the key field are close
together.

(c) Describe some things you would need to consider when choosing suitable
indexes for a MongoDB database. Why wouldn’t you just index everything?

(d) Describe in principle how a Map-Reduce query works in MongoDB.
Describe the job performed by the map, reduce and finalize functions and
explain what qualities the reduce function must have, and why.

(e) A graph database looks superficially like a relational database in that it has
relationships between entities. Describe the difference between these two
types of database, commenting on the following:

(i) The nature of the relationships between entities and how those
relationships are represented in the database

(ii) The limitations on which entities may be connected in a given
database.





[6]




[2]


[3]





[4]


[3]



[3]






[2]


[2]

3
CSCU9YQ
10th December 2016


2.

(a) Imagine you need to design a data store for an online product review website
where users will be encouraged to describe the products they are reviewing
using a set of (descriptor: description) pairs. For example, Processor speed:
Fast.

(i) Explain why the use of a relational model would be unsuitable for
this level of user flexibility.

(ii) Using JSON notation, show how you would represent a review for a
laptop made by Lenovo where the reviewer thought the battery life
was too short, the screen quality very good and the list of things they
liked about it were the design, the colour and the weight (express
these as an array).

(iii) Describe one disadvantage of the design decision to allow users to
choose arbitrary field names like this.

(b) There are a number of different ways in which you might choose to organise
the data using document embedding or references to other documents.
Assuming you have a document for each user, discuss the relative merits of
embedding or linking to things the user has reviewed in the past. What
would be the best choice to make, and why?

(c) Write MongoDB commands to run the following queries on the database
described above. Assume sensible collection and field names.

(i) Add a user with user name bill1 and full name Bill Smith.

(ii) Edit bill1’s document to add the fact that his age is 25.

(iii) Edit bill1’s document to list two email addresses: [email protected] and
[email protected].

(iv) Add a third email address, [email protected] to bill1’s account.

(v) Find all the reviews for Apple products.

(vi) Assume every item reviewed has a rating from 1 to 5 and a category
that is either Electronics, Clothes or Cars. Write code that uses the
group() method to calculate the average rating for each category.








[2]





[3]


[2]





[4]




[1]

[1]


[2]

[2]

[2]



[6]


END OF EXAMINATION

欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468