Abstract

NoSQL databases are designed to allow data to be stored without a fixed schema. In this scenario, writing data access code (queries and associated code) is challenging for two main reasons: (i) the query developer needs to know all details regarding the logical/physical schema; (ii) whenever the schema needs to change, all queries need to be rewritten. The literature presents some solutions to mitigate these challenges by making queries independent from the schema, but they are either restricted to simple queries or depend on a prescribed schema. In this paper, we propose a solution based on conceptual data modeling and code generation to enable the writing of complex data retrieval queries in a document-oriented database, independent from the logical/physical schema. We created a language for a classic ER algebra, with a concrete syntax and generative operational semantics targeting MongoDB. Based on the ideas of model management, the generative semantics uses a model that establishes the mapping between entities, relationships and document collections. From a single ER-based data retrieval query, native query code is automatically generated for any logical/physical schema. Additionally, the resulting data structure produced by the generated code is always the same. Tests show that our implementation produces consistent results. Also, we show that our solution is able to obtain up to 500% gains in throughput and response time by simply changing the schema, without modifying the queries. Our solution requires a little extra effort from the database designer, to create the mapping, but makes the job of the query developer easier. It also results in more flexibility. Whenever the schema changes, only the mapping needs to be updated, not the queries.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call