- Section 1: Basics
- 2: User-friendly language
- 3: Documents, not rows
- 4: Pattern matching with LIKE
- 5: Matching elements in nested arrays with ANY
- 6: Combining multiple conditions with AND
- 7: Querying primary keys
- 8: Quick review
- 9: Pagination with LIMIT and OFFSET
- 10: Filtering grouped data with HAVING
- 11. Review
- 12. Section 2: Joins
- 13. Joins
- 14. Joins
- 15. Exercise
- 16. Exercise
- 17. NEST
- 18. Chaining JOINs
- 19. Example
- 20. Array Comprehensions
- 21. Section 3: DML Statements
- 22. Nest
- 23. Nest
- 24. UNNEST
- 25. Filtering on nested data
- 26. Subquery
- 27. Subquery
- 28. Window Functions
- 29. Window Functions
- 30. UPDATE
- 31. Case Study I. E-Commerce
- 32. Shopper - Browsing products from page to page
- 33. Shopper - Listing product categories
- 34. Shopper - Browsing and searching for a product
- 35. Shopper - Listing products in a category
- 36. Shopper - Finding the most popular products in a category
- 37. Shopper - Browsing products and sorting results
- 38. Shopper - Shopping at a one-day sale
- 39. Shopper - Listing the top 10 best selling products
- 40. Shopper - Listing the highest rated products
- 41. Merchant - Preparing a purchase order
- 42. Merchant - Finding the most valued shoppers
- 43. Merchant - Reporting customers by region
- 44. Merchant - Reporting the active monthly customers
- 45. Merchant - Identifying non-performing products
- 46. Merchant - Generating the month-over-month sales report
- 47. Merchant - Big ticket orders
- 48. Case Study II . Social Game
- 49. Assembling and loading user profiles
- 50. Listing messages sent by a user
- 51. Generating scoreboards
For this case study, imagine that you want to build dimestore, an
online store. You use Couchbase Server to store a variety of data –
everything from product details and customer information to purchase
and review histories.
Now, let's look at how N1QL can be used to solve some typical e-commerce scenarios. For this tutorial, our data is kept in 4 different buckets:
- product This bucket contains a list of products to be sold, the categories to which they belong, price of each product, and other product info.
- customers This bucket contains customer information such as the name, address, and the customers credit card details.
- purchases This bucket contains a list of purchases made by a customer - each document contains a list of items purchased and the quantity of each item purchased.
- reviews This bucket contains a list of reviews made by a customer or specific product. Each review is scored from 0 to 5.
There are 2 types of users of our application:
- Shopper The shopper is the consumer and uses the application to buy products online.
- Merchant An employee of dimestore.
Counting all the products
Don shops online at dimestore. When he visits the homepage, it
displays a count of all the products.
To run this example, click the button in the top right corner of the code editor.