2020-03-17 11:05
Page 1

Databases

Lecture 8: Alternative data models

Page 2

Data models

Different kinds of databases

Page 3

Today

Semi-structured document formats

Page 4

XML or JSON

Page 5

HTML: HyperText Markup Language

Page 6

Documents are trees

Page 7

XML: Extensible Markup Language

Page 8

Attributes vs elements

Page 9

Well-formed XML documents

Page 10

Document Type Definition

Page 11

XPath queries

Since documents are trees…

Page 12

JSON: JavaScript Object Notation

Page 13

JSON

Syntax of JSON values

Page 14
JSON

Examples of JSON values

Page 15
JSON

Accessing parts of a JSON value

Page 16
JSON

Another example: a table as JSON value

Page 17

XML vs JSON

Page 18

JSON in PostgreSQL

Page 19
JSON in PostgreSQL

Example (by Jonas Duregård)

Database for some kind of social media applicaiton

Page 20
JSON in PostgreSQL → Example (by Jonas Duregård)

Inserting data

Page 21
JSON in PostgreSQL → Example (by Jonas Duregård)

Try it in PostgreSQL

Files

Page 22
JSON in PostgreSQL → Example (by Jonas Duregård)

Queries to try

Page 23
JSON in PostgreSQL → Example (by Jonas Duregård)

Building JSON objects in query results

Page 24

JSON Schema and JSON Path

Page 25

Further reading