Object relational database managmement systems (ORDBMS) Adapted by Edel Sherratt from originals by Nigel Hardy ORDBMS • Like a relational database management system • But with classes and inheritance Basic Idea • Extend the relational model – do not throw away that strength – recognise that OO has additional strengths – add OO features to existing systems Some examples • Postgres – Illustra, acquired by Informix, in turn acquired by IBM – PostgreSQL • Omniscience, Omniscience corporation, acquired by Oracle, became Oracle Lite • DB2, Oracle database, Microsoft SQL Server The Important extensions 1. 2. 3. 4. • structured types for attributes references to tuples methods IDs for tuples but relations (and queries on them) remain central Structured types for attributes • As well as atomic types: int, float, char, boolean . . . • Also allow structs, sets, bags, lists, arrays . • And more complex arrangements: bags of structs • i.e. relations User defined types (UDTs) as attribute types • CREATE TYPE addrType AS (street CHAR(50),city CHAR(20) ); • CREATE TYPE student AS (name CHAR (30),sid char(9), address addrType ); • CREATE TABLE company (name CHAR(20) PRIMARY KEY,address addrType ); • keys are declared as part of tables - not UDTs UDTs as table types • CREATE TABLE students OF student; • where student has three attributes 1. name 2. student_id 3. address • and where address is a struct of – street – city What about methods? • include declaration in the type • declare code separately CREATE TYPE student AS ( ... METHOD avgMark() RETURNS DECIMAL(5,2) ); CREATE METHOD avgMark() RETURNS DECIMAL(5,2) FOR student BEGIN ... END; What about Identity • Often hidden from user • But can be made visible • can be SYSTEM GENERATED – like an OID • can be DERIVED from the declared table key And what about data manipulation? • Essentially SQL, with programming language extensions • Some extras – for example to enable access to object identifiers Inheritance • UDTs can “extend” UDTs – all the attributes and methods of the parent – plus any that are added • tables can “extend” tables – all the attributes, keys and constraints of the parent – plus any that are added • Keywords vary Querying inheritance structures • by default, querying a parent searches all subtypes • the ONLY keyword limits it to the given table • assume Staff is UNDER Person SELECT p.name FROM Person p; SELECT p.name FROM ONLY(Person) p; SELECT s.name FROM Staff s; BLOBs and CLOBs • • • • Large OBjects Binary and Character stored and retrieved cannot take part in standard search comparisons – though CLOB can be searched for substrings • CLOBs for texts, code • BLOBs for images, sounds, video ORDBMS - conclusion • here and growing • builds on RDBMS expertise using other widely available expertise • introduces complexity and cost • it does let us handle some of the difficult applications much more easily – but how common are they – must the “traditional” applications pay the cost?