www.cardiff.ac.uk/medic/irg-clinicalepidemiology
Object–relational databases
Copyright By PowCoder代写 加微信 powcoder
Information modelling
& database systems
in the previous lecture we learnt about advantages and disadvantages of object–oriented databases with respect to relational databases
in this lecture we will learn about a new type of databases – object–relational databases, which combine the features of relational databases with the best ideas of object–oriented databases
Object–relational DBMS
ORDBMSs combine the features of RDBMSs with the best ideas of OODBMSs
they reuse the relational model as SQL interprets it
… but new data types and functions can be implemented using programming languages such as Java
in other words, ORDBMSs allow developers to embed new classes of data objects into the relational data model
Enhanced table structure
an object–relational database consists of tables
tables are made up of rows
all rows in a table are structurally identical
a fixed number of values of specific data types stored in columns
the most important distinction between traditional tables and object-relational tables is the way that ORDBMS columns are not limited to a standardised set of data types
relational version
CREATE TABLE Employees
FirstName VARCHAR(32) NOT NULL,
Surname VARCHAR(64) NOT NULL,
DOB DATE NOT NULL,
Salary DECIMAL(10,2) NOT NULL
CHECK (Salary > 0.0),
Address_1 VARCHAR(64) NOT NULL,
Address_2 VARCHAR(64) NOT NULL,
City VARCHAR(48) NOT NULL,
PostCode VARCHAR(8) NOT NULL,
PRIMARY KEY (Surname, FirstName, DOB)
object–relational version
CREATE TABLE Employees
Name PersonName NOT NULL,
DOB DATE NOT NULL,
Salary Currency NOT NULL,
Address StreetAddress NOT NULL,
PRIMARY KEY (Name, DOB)
these types correspond to class names, which are software modules
they encapsulate state as well as behaviour
Object–relational data model
object–relational data model amounts to objects in a relational framework
object types can be defined using CREATE TYPE … AS OBJECT statement
a flexible framework for organising and manipulating software objects corresponding to real–world phenomena
… but ORDBMSs offer more than just object data types
ORDB schema has additional features not present in relational schema
e.g. inheritance and polymorphism are part of the object–relational data model
Polymorphism is the provision of a single interface to entities of different types or the use of a single symbol to represent multiple different types.
Object–relational data model
an object–relational table can contain exotic data types
in addition, object–relational tables can be organised into new kinds of relationships
tables can be typed, developers can create a table with a record structure that corresponds to the definition of a data type
the type system includes a notion of inheritance in which data types can be organised into hierarchies
this naturally supplies a mechanism whereby tables can be arranged into hierarchies too
Inheritance
in most OO models, the concept of inheritance is limited to the structure & behaviour of classes
in an object-relational database, queries can address data values throughout the hierarchy
an object–relational SQL statement that addresses a table can address the records in all subtables
Collections
in relational databases, columns can contain at most one data value
this is called the first normal form constraint
when a group of values need to be combined into a single data object, a separate table needs to be created to store the group
in an object–relational databases such groups can be stored in rows using collections, which can contain multiple data values
to define a collection type, use the CREATE TYPE . . . AS TABLE OF statement
Query language
data stored in an ORDBMS can be manipulated using an extended version of the SQL, which is a declarative language
SQL:1999 (SQL 3) started supporting object–relational features
SQL:2003 subsequently clarified these features
SQL:2019 is the latest revision of the standard
SQL is still a declarative relational language
declarative: SQL statements describe what it is wanted, rather than a procedural, step-by-step algorithm defining how to accomplish the task
relational: SQL expresses operations over relational schema elements such as tables & views
Advantages
performance – higher levels of data throughput, i.e. better response times than RDBMSs
flexibility – integrating functional aspects with the structural ones improves the of the overall system
maintainability – flexibility reduces the costs associated with system development and ongoing maintenance
all major database vendors have upgraded their relational database products to object–relational database management systems to reflect the new SQL standards
https://docs.oracle.com/cd/B28359_01/appdev.111/b28371/adobjint.htm#CHDIBIIA
/docProps/thumbnail.jpeg
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com