JSON Textual representation widely used for data exchange Example of JSON data "ID":"22222", "name": "firstname:"Albert", "lastname:"Einstein" }, "deptname":"Physics", "children": {"firstname":"Hans","lastname":"Einstein"}, {"firstname":"Eduard","lastname":"Einstein"} ] } Types:integer,real,string,and Objects:are key-value maps,i.e.sets of (attribute name,value)pairs Arrays are also key-value maps(from offset to value) Database System Concepts-7th Edition 8.7 ©Silberschat乜,Korth and Sudarshan
Database System Concepts - 7 8.7 ©Silberschatz, Korth and Sudarshan th Edition JSON ▪ Textual representation widely used for data exchange ▪ Example of JSON data { "ID": "22222", "name": { "firstname: "Albert", "lastname: "Einstein" }, "deptname": "Physics", "children": [ {"firstname": "Hans", "lastname": "Einstein" }, {"firstname": "Eduard", "lastname": "Einstein" } ] } ▪ Types: integer, real, string, and • Objects: are key-value maps, i.e. sets of (attribute name, value) pairs • Arrays are also key-value maps (from offset to value)
JSON JSON is ubiquitous in data exchange today Widely used for web services Most modern applications are architected around on web services ■SQL extensions for JSON types for storing JSON data Extracting data from JSON objects using path expressions 。E.g.V->lD,orv.lD Generating JSON from relational data E.g.json.build_object('ID',12345,'name','Einstein') Creation of JSON collections using aggregation E.g.json_agg aggregate function in PostgreSQL Syntax varies greatly across databases ■JSON is verbose Compressed representations such as BSON(Binary JSON)used for efficient data storage Database System Concepts-7th Edition 8.8 @Silberschatz,Korth and Sudarshan
Database System Concepts - 7 8.8 ©Silberschatz, Korth and Sudarshan th Edition JSON ▪ JSON is ubiquitous in data exchange today • Widely used for web services • Most modern applications are architected around on web services ▪ SQL extensions for • JSON types for storing JSON data • Extracting data from JSON objects using path expressions ▪ E.g. V-> ID, or v.ID • Generating JSON from relational data ▪ E.g. json.build_object(‘ID’, 12345, ‘name’, ‘Einstein’) • Creation of JSON collections using aggregation ▪ E.g. json_agg aggregate function in PostgreSQL • Syntax varies greatly across databases ▪ JSON is verbose • Compressed representations such as BSON (Binary JSON) used for efficient data storage
XML XML uses tags to mark up text E.g. <course> <course id>CS-101 </course id> <title>Intro.to Computer Science </title> <dept name>Comp.Sci.</dept name> <credits>4 </credits> </course> Tags make the data self-documenting Tags can be hierarchical Database System Concepts-7th Edition 8.9 @Silberschatz,Korth and Sudarshan
Database System Concepts - 7 8.9 ©Silberschatz, Korth and Sudarshan th Edition XML ▪ XML uses tags to mark up text ▪ E.g. <course> <course id> CS-101 </course id> <title> Intro. to Computer Science </title> <dept name> Comp. Sci. </dept name> <credits> 4 </credits> </course> ▪ Tags make the data self-documenting ▪ Tags can be hierarchical
Example of Data in XML <purchase order> <identifier>P-101 </identifier> <purchaser> <name>Cray Z.Coyote </name> <address>Route 66,Mesa Flats,Arizona 86047,USA </address> </purchaser> <supplier> <name>Acme Supplies </name> <address>1 Broadway,New York,NY,USA </address> </supplier> <itemlist> <item> <identifier>RS1 </identifier> <description>Atom powered rocket sled </description> <quantity>2</quantity> <price>199.95 </price> </item> <item>...</item> </itemlist> <total cost>429.85 </total cost> </purchase order> Database System Concepts-7th Edition 8.10 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 8.10 ©Silberschatz, Korth and Sudarshan th Edition Example of Data in XML ▪ <purchase order> <identifier> P-101 </identifier> <purchaser> <name> Cray Z. Coyote </name> <address> Route 66, Mesa Flats, Arizona 86047, USA </address> </purchaser> <supplier> <name> Acme Supplies </name> <address> 1 Broadway, New York, NY, USA </address> </supplier> <itemlist> <item> <identifier> RS1 </identifier> <description> Atom powered rocket sled </description> <quantity> 2 </quantity> <price> 199.95 </price> </item> <item>…</item> </itemlist> <total cost> 429.85 </total cost> …. </purchase order>
XML Cont. XQuery language developed to query nested XML structures Not widely used currently SQL extensions to support XML ·Store XML data Generate XML data from relational data Extract data from XML data types Path expressions See Chapter 30(online)for more information Database System Concepts-7th Edition 8.11 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 8.11 ©Silberschatz, Korth and Sudarshan th Edition XML Cont. ▪ XQuery language developed to query nested XML structures • Not widely used currently ▪ SQL extensions to support XML • Store XML data • Generate XML data from relational data • Extract data from XML data types ▪ Path expressions ▪ See Chapter 30 (online) for more information