Outline Semi-Structured Data ■Object Orientation Textual Data ■Spatial Data Database System Concepts-7th Edition 8.2 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 8.2 ©Silberschatz, Korth and Sudarshan th Edition Outline ▪ Semi-Structured Data ▪ Object Orientation ▪ Textual Data ▪ Spatial Data
Semi-Structured Data Many applications require storage of complex data,whose schema changes often The relational model's requirement of atomic data types may be an overkill E.g.,storing set of interests as a set-valued attribute of a user profile may be simpler than normalizing it Data exchange can benefit greatly from semi-structured data Exchange can be between applications,or between back-end and front-end of an application Web-services are widely used today,with complex data fetched to the front-end and displayed using a mobile app or JavaScript JSON and XML are widely used semi-structured data models Database System Concepts-7th Edition 8.3 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 8.3 ©Silberschatz, Korth and Sudarshan th Edition Semi-Structured Data ▪ Many applications require storage of complex data, whose schema changes often ▪ The relational model’s requirement of atomic data types may be an overkill • E.g., storing set of interests as a set-valued attribute of a user profile may be simpler than normalizing it ▪ Data exchange can benefit greatly from semi-structured data • Exchange can be between applications, or between back-end and front-end of an application • Web-services are widely used today, with complex data fetched to the front-end and displayed using a mobile app or JavaScript ▪ JSON and XML are widely used semi-structured data models
Features of Semi-Structured Data Models ■Flexible schema Wide column representation:allow each tuple to have a different set of attributes,can add new attributes at any time 。} Sparse column representation:schema has a fixed but large set of attributes,by each tuple may store only a subset Multivalued data types ·Sets,multisets E.g.,:set of interests {'basketball,'La Liga','cooking','anime',jazz') Key-value map (or just map for short) Store a set of key-value pairs E.g.,{(brand,Apple),(ID,MacBook Air),(size,13),(color,silver)) Operations on maps:put(key,value),get(key),delete(key) ·,Arrays Widely used for scientific and monitoring applications Database System Concepts-7th Edition 8.4 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 8.4 ©Silberschatz, Korth and Sudarshan th Edition Features of Semi-Structured Data Models ▪ Flexible schema • Wide column representation: allow each tuple to have a different set of attributes, can add new attributes at any time • Sparse column representation: schema has a fixed but large set of attributes, by each tuple may store only a subset ▪ Multivalued data types • Sets, multisets ▪ E.g.,: set of interests {‘basketball, ‘La Liga’, ‘cooking’, ‘anime’, ‘jazz’} • Key-value map (or just map for short) ▪ Store a set of key-value pairs ▪ E.g., {(brand, Apple), (ID, MacBook Air), (size, 13), (color, silver)} ▪ Operations on maps: put(key, value), get(key), delete(key) • , Arrays ▪ Widely used for scientific and monitoring applications
Features of Semi-Structured Data Models ■Arrays Widely used for scientific and monitoring applications E.g.,readings taken at regular intervals can be represented as array of values instead of(time,value)pairs ■[5,8,9,11]instead of{(1,5),(2,8),(3,9),(4,11)} Multi-valued attribute types Modeled using non first-normal-form(NFNF)data model Supported by most database systems today Array database:a database that provides specialized support for arrays E.g.,compressed storage,query language extensions etc Oracle GeoRaster,PostGIS,SciDB,etc Database System Concepts-7th Edition 8.5 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 8.5 ©Silberschatz, Korth and Sudarshan th Edition Features of Semi-Structured Data Models ▪ Arrays • Widely used for scientific and monitoring applications • E.g., readings taken at regular intervals can be represented as array of values instead of (time, value) pairs ▪ [5, 8, 9, 11] instead of {(1,5), (2, 8), (3, 9), (4, 11)} ▪ Multi-valued attribute types • Modeled using non first-normal-form (NFNF) data model • Supported by most database systems today ▪ Array database: a database that provides specialized support for arrays • E.g., compressed storage, query language extensions etc • Oracle GeoRaster, PostGIS, SciDB, etc
Nested Data Types Hierarchical data is common in many applications JSON:JavaScript Object Notation ·Videly used today XML:Extensible Markup Language Earlier generation notation,still used extensively Database System Concepts-7th Edition 8.6 ©Silberscha乜,Korth and Sudarshan
Database System Concepts - 7 8.6 ©Silberschatz, Korth and Sudarshan th Edition Nested Data Types ▪ Hierarchical data is common in many applications ▪ JSON: JavaScript Object Notation • Widely used today ▪ XML: Extensible Markup Language • Earlier generation notation, still used extensively
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. CS-101 Intro.to Computer Science Comp.Sci. 4 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. CS-101 Intro. to Computer Science Comp. Sci. 4 ▪ Tags make the data self-documenting ▪ Tags can be hierarchical
Example of Data in XML P-101 Cray Z.Coyote Route 66,Mesa Flats,Arizona 86047,USA Acme Supplies 1 Broadway,New York,NY,USA RS1 Atom powered rocket sled 2 199.95 ... 429.85 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 ▪ P-101 Cray Z. Coyote Route 66, Mesa Flats, Arizona 86047, USA Acme Supplies 1 Broadway, New York, NY, USA RS1 Atom powered rocket sled 2 199.95 … 429.85 …
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