MongoDB is a document DB whereas ArangoDB is a multi-model DB supporting documents, graphs and key/values within a single database. When it comes to data modeling and data querying, they pursue somewhat different approaches. In a Nutshell: In MongoDB, data modeling is “aggregate-oriented”, avoiding relations and joins. On the other side, everybody has probably used relational databases which organize the data in tables with relations and try to avoid as much redundancy as possible. Both approaches have their pros and cons. ArangoDB is somewhat in-between: You can both model and query your data in a “relational way” but also in an “aggregate-oriented way”, depending on your use case. ArangoDB offers joins, nesting of sub-documents and multi-collection graphs. Use Case Example: A Product Wish List Imagine you have a simple web shop application. There a products which have pictures, a price, a description and product specific attributes. Customer can order those products. Each order must be archived with both the ordered products and the customer data at that specific point in time. Additionally customers can put products on a wish list. The shop will contain products that are not yet released but can be pre-ordered. If a customer put one of those products on the wish list the system should inform the customer some time before the actual release date to allow her to place an order. Additionally the wish list should indicate price changes of the products, if the products are removed or have been updated. Modeling We will assume the modeling of the products and customers is already done. Both will benefit from the schema flexibility offered by MongoDB and ArangoDB. For this blog post we will focus on the modeling of the wish list feature. Each entry on a wish list will require at least the following information: The customer this wish list belongs to A list of products on the wish list For each product the price at the point it was put on the wish list In a relational database this will eventually result in a table similar as the following: [crayon-545cdca55a006600171564/] Again in MongoDB and ArangoDB we can take advantage of embedding the list of products in a wish list instead of defining a wish list based on the rows with the same customer id: [crayon-545cdca55a017528341035/] This allows us to even have multiple wish lists per customer without much additional effort (compared to the relationalaaa
Comments (0)
Sign in to post comments.