JUpdate: A JSON Update Language
Abstract
:1. Introduction
- We propose JUpdate, an SQL-like update language for JSON. The objective of defining JUpdate similarly to the SQL language is to facilitate the use/acceptance of this new language to users who are familiar with SQL and developers who have been used to write SQL code for decades.
- JUpdate provides fourteen user-friendly high-level operations to satisfy the different update requirements, either simple or complex, of JSON data users and JSON-based application developers.
- The semantics of JUpdate is founded on a minimal and complete set of six primitives (i.e., low-level operations) for updating JSON documents.
- The JUpdate definition has been based on the IETF standard JSON data model. Therefore, it is DBMS-independent, on one hand, and it can be used for the maintenance of generic JSON documents, on the other hand.
2. High-Level Update Operations on JSON Documents: The JUpdate Language
2.1. CreateDocument
2.2. DropDocument
2.3. InsertValue
2.4. DeleteValue
2.5. UpdateValue
2.6. CopyValue
2.7. MoveValue
2.8. InsertMember
2.9. DeleteMember
2.10. RenameMember
2.11. ReplaceMember
2.12. CopyMember
2.13. MoveMember
2.14. UpdateObject
3. Illustrative Example
- To change the name of the array from “papers” to “publications”;
- To fix an error concerning the authors of the paper with ID “C-2019-001”. In fact, the user acknowledged that this paper has not been written by “Adnan Burhan”, but actually by “Anna Lorenzi” and “Ihsan Fakhri”. In order to apply the correction, the user wants to have the current wrong value of the “authors” array replaced by a new value including the two proper authors;
- To replace the “confChair” property of the conference having the acronym “NoSQL-DB-2019”, with the publisher “Zprinter” of the conference proceedings;
- To update from “C” to “B” the rank of the conference with acronym “NoSQL-DB-2019”;
- To add the missing page numbers “23–43” to the paper with ID “J-2019-001”;
- To add journal quartile information, with value “Q2”, to the paper with ID “J-2019-001”;
- To copy the publisher information from the paper with ID “C-2019-001” to the paper with ID “J-2019-001”, as the publisher is the same;
- To delete the issue property of the journal with name “Emerging Databases”, since it has no longer had issue numbers since its fifth volume;
- To move the paper with ID “J-2019-001” at the beginning of the list of papers.
4. Primitive Update Operations
4.1. CreaDoc
4.2. DropDoc
4.3. InsMemb
4.4. InsVal
4.5. DelVal
4.6. DelMemb
5. Completeness and Minimality
5.1. Completeness and Minimality of the Proposed Primitive Update Operations Set PO
- Use the applyPR procedure in order to derive from the production rule application set the sequence of creation primitives that could have been used to construct the doc.json instance;
- Scan the sequence of creation primitives in reverse order and replace each of them by its inverse destruction primitive.
5.2. Completeness of JUpdate
6. Definability of the HLOs Making up JUpdate
6.1. Basic HLOs: InsertValue and DeleteValue
6.2. Derived HLOs
7. Related Work Discussion
- N1QL, CQL, and AQL, similarly to JUpdate, are SQL-like. However, contrary to them, JUpdate is DBMS-independent. Moreover, such languages are based on predefined precise data models based on collections of homogeneous JSON objects (e.g., key-value/keyspaces for N1QL, tables for CQL, and ADM/dataspaces for AQL), to be used as relational tables (with objects playing the role of table rows). CQL also supports collections (i.e., lists/sets/maps) to store structured multiple values in a table. JUpdate is not based on any predefined data model and, thus, it best suits the JSON philosophy and can be used for the maintenance of generic JSON documents.
- N1QL and AQL support an UPSERT operation that behaves as an UPDATE if corresponding data (which are JSON object members) are found or as an INSERT if corresponding data are not found, such as the RECORD operation proposed in [29]. Such operations are based on the precise data models based on collections of JSON objects recalled above and cannot be used on generic JSON documents. On object members, the JUpdate UPDATE operation works as an UPSERT, since it behaves as INSERT if the value to be updated has a null value. On a JSON array, the JUpdate UPDATE operation still works as an UPSERT if used on the “[last]” component of the array (such component is replaced if present or a new component is inserted if the array is empty). Hence, JUpdate does not need an UPSERT, as the UPDATE operation can be used in a more general and powerful way (i.e., to make “upsertions” in both objects and arrays placed at any nesting level of the structure of a generic JSON document).
- Contrary to CQL, which supports a BATCH operation (i.e., a sequence of multiple INSERT, UPDATE, and DELETE operations that are grouped together in a single operation so that they can be executed together), JUpdate does not support it. In fact, JUpdate allows its users to specify any valid sequence of operations among the set of fourteen operations of JUpdate and not only among a set of three operations.
8. Conclusions
Author Contributions
Funding
Conflicts of Interest
Appendix A. JUpdate Syntax
Appendix B. Execution Traces of the applyPR Procedure
Appendix C. Implementation of a JSON Patch Processor
- “op” denotes the operation to be applied; JSON Patch supports six operations: “add”, “remove”, “replace”, “move”, “copy” and “test”;
- “path” denotes the target path of the operation, that is the path of the JSON component affected by the operation;
- “value” denotes the (new) value provided by the user, to be used by the “add” and “replace” operation;
- “from” denotes the source path to be used by the “move” and “copy” operations.
References
- Internet Engineering Task Force. The JavaScript Object Notation (JSON) Data Interchange Format, Internet Standards Track document, December 2017. Available online: https://tools.ietf.org/html/rfc8259 (accessed on 31 December 2021).
- Jackson, W. JSON Quick Syntax Reference; Apress: Berkeley, CA, USA, 2016. [Google Scholar]
- Pezoa, F.; Reutter, J.L.; Suarez, F.; Ugarte, M.; Vrgoč, D. Foundations of JSON Schema. In Proceedings of the 25th International Conference on World Wide Web (WWW 2016), Montreal, QC, Canada, 11–15 April 2016; pp. 263–273. [Google Scholar]
- Bourhis, P.; Reutter, J.L.; Suárez, F.; Vrgoč, D. JSON: Data model, query languages and schema specification. In Proceedings of the 36th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems (PODS 2017), Chicago, IL, USA, 14–19 May 2017; pp. 123–135. [Google Scholar]
- Hidders, J.; Paredaens, J.; van den Bussche, J. J-Logic: Logical foundations for JSON querying. In Proceedings of the 36th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems (PODS 2017), Chicago, IL, USA, 14–19 May 2017; pp. 137–149. [Google Scholar]
- Baazizi, M.-A.; Colazzo, D.; Ghelli, G.; Sartiani, C. Schemas and Types for JSON Data: From Theory to Practice. In Proceedings of the 2019 International Conference on Management of Data (SIGMOD’2019), Amsterdam, The Netherlands, 30 June–5 July 2019; pp. 2060–2063. [Google Scholar]
- Brahmia, S.; Brahmia, Z.; Grandi, F.; Bouaziz, R. A Disciplined Approach to Temporal Evolution and Versioning Support in JSON NoSQL Data Stores. In Emerging Technologies and Applications in Data Modeling and Processing; Ma, Z., Yan, L., Eds.; IGI Global: Hershey, PA, USA, 2019; pp. 114–133. [Google Scholar]
- Friesen, J. Extracting JSON Values with JsonPath. In Java XML and JSON—Document Processing for Java SE, 2nd ed.; Apress: Berkeley, CA, USA, 2019; pp. 299–322. [Google Scholar]
- Hu, Z.; Yan, L. Modeling Temporal Information With JSON. In Emerging Technologies and Applications in Data Modeling and Processing; Ma, Z., Yan, L., Eds.; IGI Global: Hershey, PA, USA, 2019; pp. 134–153. [Google Scholar]
- Irshad, L.; Ma, Z.; Yan, L. A Survey on JSON Data Stores. In Emerging Technologies and Applications in Data Modeling and Processing; Ma, Z., Yan, L., Eds.; IGI Global: Hershey, PA, USA, 2019; pp. 45–69. [Google Scholar]
- Liu, Z.H. JSON Data Management in RDBMS. In Emerging Technologies and Applications in Data Modeling and Processing; Ma, Z., Yan, L., Eds.; IGI Global: Hershey, PA, USA, 2019; pp. 20–44. [Google Scholar]
- Möller, M.L.; Berton, N.; Klettke, M.; Scherzinger, S.; Störl, U. jHound: Large-Scale Profiling of Open JSON Data. In Proceedings of the 18th Conference on Database systems for Business, Technology and Web (BTW’2019), Rostock, Germany, 4–8 March 2019; pp. 555–558. [Google Scholar]
- Beyer, K.S.; Ercegovac, V.; Gemulla, R.; Balmin, A.; Eltabakh, M.Y.; Kanne, C.-C.; Özcan, F.; Shekita, E.J. Jaql: A scripting language for large scale semistructured data analysi. PVLDB 2011, 4, 1272–1283. [Google Scholar] [CrossRef]
- Florescu, D.; Fourny, G. JSONiq: The History of a Query Language. IEEE Internet Computing 2013, 17, 86–90. [Google Scholar] [CrossRef]
- Li, X.; Liu, Z.; Liu, M.; Wu, X.; Zhu, S. Towards a Pattern-Based Query Language for Document Databases. In Proceedings of the 20th International Conference on Database Systems for Advanced Applications (DASFAA’2015), Hanoi, Vietnam, 20–23 April 2015; pp. 320–325. [Google Scholar]
- Ong, K.W.; Papakonstantinou, Y.; Vernoux, R. The SQL++ Query Language: Configurable, Unifying and Semi-structured. CoRR abs/1405.3631. 2015. Available online: https://arxiv.org/pdf/1405.3631.pdf (accessed on 31 December 2021).
- Chamberlin, D. SQL++ for SQL Users: A Tutorial; Couchbase Inc.: Santa Clara, CA, USA, 2018. [Google Scholar]
- Bourhis, P.; Reutter, J.L.; Vrgoč, D. JSON: Data model and query languages. Inf. Syst. 2020, 89, 101478. [Google Scholar] [CrossRef]
- Pokorný, J. JSON Functionally. In Proceedings of the 24th European Conference on Advances in Databases and Information Systems (ADBIS 2020), Lyon, France, 25–27 September 2020; LNCS 12245. pp. 139–153. [Google Scholar]
- Davoudian, A.; Chen, L.; Liu, M. A Survey on NoSQL Stores. ACM Computing Surv. 2018, 51, 40. [Google Scholar] [CrossRef]
- Melton, J.; Zemke, F.; Hammerschmidt, B.; Kulkarni, K.; Liu, Z.H.; Michels, J.-E.; McMahon, D.; Özcan, F.; Pirahesh, H. SQL/JSON Part 1, DM32.2-2014-00024R1, 6 March 2014. Available online: https://www.wiscorp.com/pub/DM32.2-2014-00024R1_JSON-SQL-Proposal-1.pdf (accessed on 31 December 2021).
- Zemke, F.; Hammerschmidt, B.; Kulkarni, K.; Liu, Z.H.; McMahon, D.; Melton, J.; Michels, J.-E.; Özcan, F.; Pirahesh, H. SQL/JSON Part 2—Querying JSON, ANSI INCITS DM32.2-2014-00025r1, 4 March 2014. Available online: https://www.wiscorp.com/pub/DM32.2-2014-00025r1-sql-json-part-2.pdf (accessed on 31 December 2021).
- ISO/IEC. Information Technology—Database Languages—SQL Technical Reports—Part 6: SQL Support for JavaScript Object Notation (JSON), 1st Edition, Technical Report ISO/IEC TR 19075-6:2017(E), March 2017. Available online: http://standards.iso.org/ittf/PubliclyAvailableStandards/c067367_ISO_IEC_TR_19075-6_2017.zip (accessed on 31 December 2021).
- Petković, D. SQL/JSON Standard: Properties and Deficiencies. Datenbank Spektrum 2017, 17, 277–287. [Google Scholar] [CrossRef]
- Gössner, S. JSONPath—Xpath for JSON, 21 February 2007. Available online: http://goessner.net/articles/JsonPath/ (accessed on 31 December 2021).
- Brahmia, S.; Brahmia, Z.; Grandi, F.; Bouaziz, R. Temporal JSON Schema Versioning in the τJSchema Framework. J. Digit. Inf. Manag. 2017, 15, 179–202. [Google Scholar]
- Brahmia, Z.; Brahmia, S.; Grandi, F.; Bouaziz, R. Implicit JSON Schema Versioning Driven by Big Data Evolution in the τJSchema Framework. In Big Data and Networks Technologies—BDNT 2019; Farhaoui, Y., Ed.; LNNS; Springer: Berlin/Heidelberg, Germany, 2020; Volume 81, pp. 22–35. [Google Scholar]
- Van Rossum, G.; Drake, F.L., Jr. Python Reference Manual; Centrum voor Wiskunde en Informatica: Amsterdam, The Netherlands, 1995. [Google Scholar]
- Grandi, F.; Scalas, M.R.; Tiberio, P. A History-oriented Temporal SQL Extension. In Proceedings of the 2nd International Workshop on Next Generation Information Technologies and Systems (NGITS’95), Naharia, Israel, 27–29 June 1995; pp. 42–48. [Google Scholar]
- Chasseur, C.; Li, Y.; Patel, J.M. Enabling JSON Document Stores in Relational Systems. In Proceedings of the 16th International Workshop on the Web and Databases (WebDB 2013), New York, NY, USA, 23 June 2013; pp. 1–6. [Google Scholar]
- Liu, Z.H.; Hammerschmidt, B.; McMahon, D. JSON data management: Supporting schema-less development in RDBMS. In Proceedings of the 2014 ACM SIGMOD International Conference on Management of Data (SIGMOD 2014), Snowbird, UT, USA, 22–27 June 2014; pp. 1247–1258. [Google Scholar]
- Liu, Z.H.; Hammerschmidt, B.; McMahon, D.; Liu, Y.; Chang, H.J. Closing the functional and Performance Gap between SQL and NoSQL. In Proceedings of the 2016 International Conference on Management of Data (SIGMOD 2016), San Francisco, CA, USA, 26 June–1 July 2016; pp. 227–238. [Google Scholar]
- Liu, Z.H.; Gawlick, D. Management of Flexible Schema Data in RDBMSs—Opportunities and Limitations for NoSQL. In Proceedings of the 7th Biennial Conference on Innovative Data Systems Research (CIDR’2015), Asilomar, CA, USA, 4–7 January 2015. Paper 5. [Google Scholar]
- Internet Engineering Task Force. JavaScript Object Notation (JSON) Patch, Internet Standards Track Document, April 2013. Available online: https://tools.ietf.org/html/rfc6902 (accessed on 31 December 2021).
- Brahmia, Z.; Grandi, F.; Oliboni, B.; Bouaziz, R. High-level Operations for Creation and Maintenance of Temporal and Conventional Schema in the τXSchema Framework. In Proceedings of the 21st International Symposium on Temporal Representation and Reasoning (TIME’2014), Verona, Italy, 8–10 September 2014; pp. 101–110. [Google Scholar]
- Snodgrass, R.T.; Dyreson, C.E.; Currim, F.; Currim, S.; Joshi, S. Validating Quicksand: Schema Versioning in τXSchema. Data Knowl. Eng. 2008, 65, 223–242. [Google Scholar] [CrossRef] [Green Version]
- Brahmia, Z.; Grandi, F.; Oliboni, B.; Bouaziz, R. Schema Change Operations for Full Support of Schema Versioning in the τXSchema Framework. Int. J. Inf. Technol. Web Eng. 2014, 9, 20–46. [Google Scholar] [CrossRef] [Green Version]
- Brahmia, Z.; Grandi, F.; Oliboni, B.; Bouaziz, R. Supporting Structural Evolution of Data in Web-Based Systems via Schema Versioning in the τXSchema Framework. In Handbook of Research on Contemporary Perspectives on Web-Based Systems; Elçi, A., Ed.; IGI Global: Hershey, PA, USA, 2018; pp. 271–307. [Google Scholar]
- W3C, Extensible Markup Language (XML) 1.0 (5th Edition), W3C Recommendation, 26 November 2008. Available online: http://www.w3.org/TR/2008/REC-xml-20081126/ (accessed on 31 December 2021).
- W3C, XQuery 1.0: An XML Query Language (2nd Edition), W3C Recommendation, 14 December 2010. Available online: http://www.w3.org/TR/2010/REC-xquery-20101214/ (accessed on 31 December 2021).
- W3C, XQuery Update Facility 1.0, W3C Recommendation, 17 March 2011. Available online: http://www.w3.org/TR/2011/REC-xquery-update-10-20110317/ (accessed on 31 December 2021).
- Laux, A.; Martin, L. XUpdate—XML Update Language, XML:DB Working Draft, 14 September 2000. Available online: http://xmldb-org.sourceforge.net/xupdate/xupdate-wd.html (accessed on 31 December 2021).
- Obasanjo, D.; Navathe, S.B. A Proposal for an XML Data Definition and Manipulation Language. In Proceedings of the 1st VLDB Workshop on Efficiency and Effectiveness of XML Tools, and Techniques (EEXTT’2002), Hong Kong, China, 19 August 2002; pp. 1–21. [Google Scholar]
- Sur, G.M.; Hammer, J.; Siméon, J. An XQuery-Based Language for Processing Updates in XML. In Proceedings of the 2nd Workshop on Programming Language Technologies for XML (PLAN-X’2004), Venice, Italy, 13 January 2004; pp. 40–53. Available online: http://www.brics.dk/NS/03/4/BRICS-NS-03-4.pdf (accessed on 31 December 2021).
- Wang, G.-R.; Zhang, X.-L. Declarative XML Update Language Based on a Higher Data Model. J. Comput. Sci. Technol. 2005, 20, 373–377. [Google Scholar] [CrossRef]
- Ni, W.; Ling, T.W. Update XML data by using graphical languages. In Proceedings of the Tutorials, Posters, Panels and Industrial Contributions at the 26th International Conference on Concep-tual Modeling (ER’2007), Auckland, New Zealand, 5–9 November 2007; pp. 209–214. [Google Scholar]
- Cheney, J. FLUX: Functional Updates for XML. In Proceedings of the 13th ACM SIGPLAN International Conference on Functional Programming (ICFP’08), Victoria, BC, Canada, 22–24 September 2008; pp. 3–14. [Google Scholar]
- W3C. XQuery Update Facility 3.0, W3C Working Group Note, 24 January 2017. Available online: https://www.w3.org/TR/2017/NOTE-xquery-update-30-20170124/ (accessed on 31 December 2021).
- Brahmia, Z.; Hamrouni, H.; Bouaziz, R. XML Data Manipulation in Conventional and Temporal XML Databases: A Survey. Comput. Sci. Rev. 2020, 36, 100231. [Google Scholar] [CrossRef]
- Brahmia, Z.; Grandi, F.; Bouaziz, R. τXUF: A Temporal Extension of the XQuery Update Facility Language for the τXSchema Framework. In Proceedings of the 23rd International Symposium on Temporal Representation and Reasoning (TIME’2016), Technical University of Denmark, Copenhagen, Denmark, 17–19 October 2016; pp. 140–148. [Google Scholar]
- Brahmia, Z.; Brahmia, S.; Grandi, F.; Bouaziz, R. Implementation of High-Level JSON Schema Change Operations Using JUpdate. In Marketing and Smart Technologies: Proceedings of ICMarkTech’2020 (SIST vol. 205); Rocha, Á., Reis, J.L., Peter, M.K., Cayolla, R., Loureiro, S., Bogdanović, Z., Eds.; Springer Nature: Singapore, 2021; pp. 255–265. [Google Scholar]
- Brahmia, Z.; Brahmia, S.; Grandi, F.; Bouaziz, R. Versioning schemas of JSON-based conventional and temporal big data through high-level operations in the τJSchema framework. Int. J. Cloud Comput. 2021, 10, 442–479. [Google Scholar] [CrossRef]
- Internet Engineering Task Force (IETF). JSON Schema: A Media Type for Describing JSON Documents. Internet-Draft, 8 December 2020. Available online: https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00 (accessed on 31 December 2021).
- Brahmia, S.; Brahmia, Z.; Grandi, F.; Bouaziz, R. τJSchema: A Framework for Managing Temporal JSON-Based NoSQL Databases. In Proceedings of the 27th International Conference on Database and Expert Systems Applications (DEXA’2016), Porto, Portugal, 5–8 September 2016; Part 2. pp. 167–181. [Google Scholar]
HLOs Subset | Objective |
---|---|
CreateDocument, DropDocument | They are used to manage JSON documents as a whole, with a syntax based on the SQLCREATE/DROPTABLE statements. |
InsertValue, DeleteValue, UpdateValue, CopyValue, MoveValue | They are used to manage (possibly complex) values in JSON documents, with a syntax based on the SQLINSERT/DELETE/UPDATE statements. |
InsertMember, DeleteMember, RenameMember, ReplaceMember, CopyMember, MoveMember | They are used to manage the structure of JSON objects, with a syntax based on the SQL ALTER TABLE statement. Notice that JSON objects have to be used to represent (nested) relational tables. |
UpdateObject | It is used to change at once the value of more than one members of a JSON object, with a syntax based on the SQL UPDATE statement using the SET clause. |
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |
© 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Brahmia, Z.; Brahmia, S.; Grandi, F.; Bouaziz, R. JUpdate: A JSON Update Language. Electronics 2022, 11, 508. https://doi.org/10.3390/electronics11040508
Brahmia Z, Brahmia S, Grandi F, Bouaziz R. JUpdate: A JSON Update Language. Electronics. 2022; 11(4):508. https://doi.org/10.3390/electronics11040508
Chicago/Turabian StyleBrahmia, Zouhaier, Safa Brahmia, Fabio Grandi, and Rafik Bouaziz. 2022. "JUpdate: A JSON Update Language" Electronics 11, no. 4: 508. https://doi.org/10.3390/electronics11040508