Couchbase Query Execution

 40 Minutes
 2 Questions


This assessment is designed to evaluate a candidate's proficiency in both crafting and executing queries in a Couchbase environment. As one of the leading NoSQL database solutions, Couchbase requires a unique approach to querying, and this test ensures a candidate's readiness to handle real-world data operations using this platform. Key Areas Covered: - Crafting precise and efficient N1QL queries. - Executing queries in a live Couchbase environment. - Analyzing query results and ensuring data accuracy. - Handling complex data structures and relationships. Candidates will be provided with a series of tasks and scenarios where they will need to write new queries and execute them to retrieve, modify, or analyze data. Accuracy, efficiency, and clarity of the queries will be key evaluation metrics.


Example Question:

Coding
Given a dataset within the blog_platform bucket, you are tasked with understanding the engagement each blog post received in the year 2021.
Your query should provide insights into how many comments each blog post received during that year.



Write a query to solve the task.



Your solution should return two fields for each post:
  1. title: The title of the blog post.
  2. comments_in_2021: The number of comments that particular blog post received in 2021.
Structure of the blog_platform bucket:



{
 "title": "Title of the Blog Post",
 "published_date": "YYYY-MM-DD",
 "tags": ["tag1", "tag2", ...],
 "comments": [
  {
   "comment": "Comment text",
   "date": "YYYY-MM-DD",
   "user": "Username"
  },
  ...
 ]
}



Input example:



[
 {
  "title": "Tech in 2022",
  "published_date": "2021-06-01",
  "tags": ["tech", "future"],
  "comments": [
   {"comment": "Nice update!", "date": "2021-06-15", "user": "charlie"},
   {"comment": "Looking forward.", "date": "2021-07-10", "user": "dave"},
   {"comment": "From the past.", "date": "2020-05-20", "user": "mike"}
  ]
 },
 {
  "title": "Cooking with Tech",
  "published_date": "2021-05-25",
  "tags": ["tech", "cooking"],
  "comments": [
   {"comment": "So cool!", "date": "2021-06-02", "user": "emma"},
   {"comment": "My kitchen is smart now.", "date": "2021-06-12", "user": "frank"},
   {"comment": "Old tech!", "date": "2019-03-12", "user": "grace"}
  ]
 }
]



Output example:



[
{
"title": "Tech in 2022",
"comments_in_2021": 2
},
{
"title": "Cooking with Tech",
"comments_in_2021": 2
}
]