Chapter 8 | Complex Data Types¶
约 267 个字 预计阅读时间 1 分钟
Object-based Databases¶
- Advanced Database Applications need Complex Data Types
-
Applications are often written in object-oriented programming languages(OOPL)
- Type system does not match relational type system
- Switching between imperative language and SQL is troublesome
-
Approaches for integrating object-orientation with databases
- Build an object-oriented database(OODB) that natively supports object-oriented data and direct access from programming language
- Build an object-relational database(ORDB), adding object-oriented features to a relational database
- Automatically convert data between programming language model and relational model; data conversion specified by object-relational mapping(ORM)
Object-Relational Mapping¶
-
Object-relational mapping (ORM) systems allow
- Specification of mapping between programming language objects and database tuples
- Automatic creation of database tuples upon creation of objects
- Automatic update/delete of database tuples when objects are update/deleted
- Interface to retrieve objects satisfying specified conditions
- Tuples in database are queried, and object created from the tuples
-
Details in Section 9.6.2
- Hibernate ORM for Java
- Django ORM for Python
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
-
XML and JSON are widely used semi-structured data models
- XML: Extensible Markup Language
- Earlier generation notation, still used extensively
- JSON: JavaScript Object Notation
- Widely used today
- XML: Extensible Markup Language