{"id":329,"date":"2015-10-20T07:58:19","date_gmt":"2015-10-20T07:58:19","guid":{"rendered":"http:\/\/vargas-solar.com\/cloud-data-management\/?p=329"},"modified":"2015-10-20T07:58:19","modified_gmt":"2015-10-20T07:58:19","slug":"couchdb-expressing-queries","status":"publish","type":"post","link":"http:\/\/vargas-solar.com\/cloud-data-management\/2015\/10\/20\/couchdb-expressing-queries\/","title":{"rendered":"CouchDB: Expressing queries"},"content":{"rendered":"<h2>Requirement<\/h2>\n<ul>\n<li><a href=\"http:\/\/couchdb.apache.org\/\">CouchDB<\/a><\/li>\n<li><a href=\"http:\/\/curl.haxx.se\/download.html\">cURL<\/a><\/li>\n<li><a href=\"http:\/\/espinosa-oviedo.com\/mobile-and-web-services-programming\/wp-content\/uploads\/sites\/6\/2015\/02\/Allocine.zip\">AlloCine files<\/a><\/li>\n<\/ul>\n<h2>To Hand In<\/h2>\n<p>This exercise will be handed in electronically:<\/p>\n<ul>\n<li>You will form groups of 2 or three<\/li>\n<li>A report with answers and explanations of the principle you adopted in PDF<\/li>\n<li>The report will state the JavaScript answers to the questions.<\/li>\n<\/ul>\n<h2>To Do<\/h2>\n<p>For this exercise you will use a set of file containing information about the films presented in Grenoble in 2011 (information retrieved from AlloCine API).\u00a0Each of these files contains the films presented in a cinema of Grenoble at that time (i.e. there is a file per cinema and a total number of 9).<\/p>\n<p>Start by creating and populating a new database in CouchDB using the data contained in the files named\u00a0<em>allocineGrenobleN.txt\u00a0<\/em>with\u00a0<em>N\u00a0<\/em>from\u00a0<em>1\u00a0<\/em>to\u00a0<em>9<\/em>. For this purpose execute the following commands:<\/p>\n<pre>curl -X PUT <a href=\"http:\/\/localhost:5984\/allocine\">http:\/\/localhost:5984\/allocine<\/a><\/pre>\n<pre>curl -T \"allocineGrenoble1.txt\" <a href=\"http:\/\/localhost:5984\/allocine\/allocineGrenoble1\">http:\/\/localhost:5984\/allocine\/allocineGrenoble1<\/a>\r\ncurl -T \"allocineGrenoble2.txt\" <a href=\"http:\/\/localhost:5984\/allocine\/allocineGrenoble2\">http:\/\/localhost:5984\/allocine\/allocineGrenoble2<\/a> \r\ncurl -T \"allocineGrenoble3.txt\" <a href=\"http:\/\/localhost:5984\/allocine\/allocineGrenoble3\">http:\/\/localhost:5984\/allocine\/allocineGrenoble3<\/a> \r\ncurl -T \"allocineGrenoble4.txt\" <a href=\"http:\/\/localhost:5984\/allocine\/allocineGrenoble4\">http:\/\/localhost:5984\/allocine\/allocineGrenoble4<\/a> \r\ncurl -T \"allocineGrenoble5.txt\" <a href=\"http:\/\/localhost:5984\/allocine\/allocineGrenoble5\">http:\/\/localhost:5984\/allocine\/allocineGrenoble5<\/a> \r\ncurl -T \"allocineGrenoble6.txt\" <a href=\"http:\/\/localhost:5984\/allocine\/allocineGrenoble6\">http:\/\/localhost:5984\/allocine\/allocineGrenoble6<\/a> \r\ncurl -T \"allocineGrenoble7.txt\" <a href=\"http:\/\/localhost:5984\/allocine\/allocineGrenoble7\">http:\/\/localhost:5984\/allocine\/allocineGrenoble7<\/a> \r\ncurl -T \"allocineGrenoble8.txt\" <a href=\"http:\/\/localhost:5984\/allocine\/allocineGrenoble8\">http:\/\/localhost:5984\/allocine\/allocineGrenoble8<\/a> \r\ncurl -T \"allocineGrenoble9.txt\" <a href=\"http:\/\/localhost:5984\/allocine\/allocineGrenoble9\">http:\/\/localhost:5984\/allocine\/allocineGrenoble9<\/a><strong><em>\u00a0<\/em><\/strong><\/pre>\n<p><strong><em>In your report give the code and a screen shot with the content on the database.<\/em><\/strong><\/p>\n<p>Using this database answer the following questions and do not forget to give:<\/p>\n<ul>\n<li>the code of the answer<\/li>\n<li>the screenshots with the content of the database<\/li>\n<\/ul>\n<p>Feel free to use the\u00a0<a href=\"http:\/\/guide.couchdb.org\/\">CouchDB book<\/a>\u00a0for getting some inspiration.<\/p>\n<h3>Question 1<\/h3>\n<p>Note that the data set is quite complete. Define a simplified view in MapReduce that contains for each theatre the films presented in it.\u00a0<strong>Hint<\/strong>: You do not need a \u201creduce\u201d here.<\/p>\n<h3>Question 2<\/h3>\n<p>Modify your answer to question 1 for filtering the theatres outside Grenoble downtown (e.g., do not include the theatres in Saint Martin d\u2019H\u00e8res).<\/p>\n<h3>Question 3<\/h3>\n<p>Give the number of films that each theatre is presenting.\u00a0<strong>Hint<\/strong>: You need a \u201creduce\u201d here.<\/p>\n<h3>Question 4<\/h3>\n<p>Give the list of films with a press rating higher than 4 stars.\u00a0<strong>Attention<\/strong>: filter duplicates.<\/p>\n<h3>Question 5<\/h3>\n<p>Give the list of films presented 2 years ago (10.12.2011), and for each film, the theatre where it was presented and its schedule.<\/p>\n<h3>Question 7 (BONUS)<\/h3>\n<p>Give the list of films and for every film the list of theatres that present it. This question is a challenge but we encourage you to try to solve it.<\/p>\n<p><strong>\u00a0Acknowledgment<\/strong><\/p>\n<p><a href=\"http:\/\/espinosa-oviedo.com\/mobile-and-web-services-programming\/hands-on\/couchdb-expressing-queries\/#_ftnref1\" name=\"_ftn1\"><\/a><\/p>\n<p>Dr. Alexandre Termier, University Joseph Fourier originally designed this exercise. It has been slightly modified for this course.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Requirement CouchDB cURL AlloCine files To Hand In This exercise will be handed in electronically: You will form groups of 2 or three A report with answers and explanations of the principle you adopted in PDF The report will state the JavaScript answers to the questions. To Do For this exercise you will use a [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-329","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/vargas-solar.com\/cloud-data-management\/wp-json\/wp\/v2\/posts\/329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/vargas-solar.com\/cloud-data-management\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/vargas-solar.com\/cloud-data-management\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/vargas-solar.com\/cloud-data-management\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"http:\/\/vargas-solar.com\/cloud-data-management\/wp-json\/wp\/v2\/comments?post=329"}],"version-history":[{"count":1,"href":"http:\/\/vargas-solar.com\/cloud-data-management\/wp-json\/wp\/v2\/posts\/329\/revisions"}],"predecessor-version":[{"id":330,"href":"http:\/\/vargas-solar.com\/cloud-data-management\/wp-json\/wp\/v2\/posts\/329\/revisions\/330"}],"wp:attachment":[{"href":"http:\/\/vargas-solar.com\/cloud-data-management\/wp-json\/wp\/v2\/media?parent=329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/vargas-solar.com\/cloud-data-management\/wp-json\/wp\/v2\/categories?post=329"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/vargas-solar.com\/cloud-data-management\/wp-json\/wp\/v2\/tags?post=329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}