Object-Relational Databases

download Object-Relational Databases

If you can't read please download the document

  • date post

    14-Jan-2016
  • Category

    Documents

  • view

    19
  • download

    0

Embed Size (px)

description

Object-Relational Databases. The Evolutionary Approach to Closing the Gap between Relational Tables and Object Models SQL3 – SQL:99. ORDB?. Or in a picture…. Stonebraker’s Matrix. The Problem. 1NF: All data as simple values in tables This means: No structure allowed. Approachs. - PowerPoint PPT Presentation

Transcript of Object-Relational Databases

  • Object-Relational DatabasesThe Evolutionary Approach to Closing the Gap between Relational Tables and Object Models

    SQL3 SQL:99

    NOEA/IT - Databases/ORDB

  • Or in a picture

    NOEA/IT - Databases/ORDB

  • Stonebrakers Matrix

    NOEA/IT - Databases/ORDB

  • The Problem1NF:All data as simple values in tables

    This means:No structure allowed

    NOEA/IT - Databases/ORDB

  • ApproachsNot First Normal Form Databases (NFNF == NF2 databases):Fields in tables may be tablesNot implemented in commercial DBMSsSQL:99:The concept of domains is enhanced allowing attributes to be defined over user defined domains (UDT: User Defined Data Type)

    NOEA/IT - Databases/ORDB

  • SQL/Object (part of SQL:99)Additions to SQL-92:Type constructors (User Defined Types: UDT) :ROW type (a tuple or a record)Array type (fixed size, 1 dimensional)REF type (like OIDs)Encapsulation (adding operations or methods to types)Inheritance

    NOEA/IT - Databases/ORDB

  • Type ConstructorsRow type:CREATE TYPE AS [ ROW ] ();

    Ex:CREATE TYPE AddrType AS ( StreetVARCHAR(45), CityVARCHAR(25), ZipCHAR(5) );

    NOEA/IT - Databases/ORDB

  • Type ConstructorsArray type:Fixed size arrays:

    Ex:CREATE TYPE CompanyType AS ( CompNameVARCHAR(20), LocationsVARCHAR(20) ARRAY[10]);

    NOEA/IT - Databases/ORDB

  • Type ConstructorsA User Defined Type may be used to define new USDs:CREATE TYPE EmployeeType AS ( NameVARCHAR(35), Addr AddrType,AgeINT);or as type for attributes in definition of tables:CREATE TABLE COMPANY OF CompanyType (PRIMARY KEY(CompName));

    NOEA/IT - Databases/ORDB

  • OIDs and ReferencesOIDs are supported:

    CREATE TABLE COMPANY OF CompanyType (REF IS CompID SYSTEM GENERATED,PRIMARY KEY(CompName));CREATE TABLE EMPLOYEE OF EmployeeType REF IS EmpID SYSTEM GENERATED;

    Primary key could be usedinstead

    NOEA/IT - Databases/ORDB

  • OIDs and ReferencesReferences may used implementing relations (in the ER-sense of the word):

    CREATE TYPE EmploymentType AS (Employee REF(EmployeeeType) SCOPE(EMPLOYEE),Company REF(CompanyType) SCOPE(COMPANY),);CREATE TABLE EMPLOYMENT OF EmploymentType;SCOPE defines the table which may be referenced by the reference attribute

    NOEA/IT - Databases/ORDB

  • OIDs and ReferencesUsing references in path expressions:

    SELECTE.Employee -> NameFROMEMPLOYMENT EWHEREE.Company -> CompName = NOEAUsually SQL uses the dot notation to build path expressions:EMPLOYEE.AddrType.Street,but for reference types -> is usedActual, this is C++ notation

    NOEA/IT - Databases/ORDB

  • EncapsulationOne of three pillars of object-orientation is encapsulation, i.e.: hiding data behind operations or methodsEncapsulation is supported by SQL3:CREATE TYPE (,,,);What are the two others?USDs and references may be used

    NOEA/IT - Databases/ORDB

  • EncapsulationEx:CREATE TYPE AddrType AS ( StreetVARCHAR(45), CityVARCHAR(25), ZipCHAR(5), )METHOD apartmentNo() RETURNS CHAR(8);

    METHODCREATE FUNCTION apartmentNo() RETURNS CHAR(8) FOR AddrType ASEXTERNAL NAME /x/y/AppartmentNo.class LANGUAGE javaGiven some algorithm to retrieve apartment number from address Methods are implemented by FUNCTIONs

    NOEA/IT - Databases/ORDB

  • Inheritance and PolymorphismAre also supported:All attributes are inheritedAn instance of a subtype can be used wherever an instance of the supertype may be used.Methods may be redefined in subtypesDynamic linking is usedHere they are:The two other pillars of OO

    NOEA/IT - Databases/ORDB

  • Further StudiesSee for instance:Elmasri chapter 22.4 andhttp://www.oracle.com/technology/software/index.html

    NOEA/IT - Databases/ORDB

    NOEA/IT Datanomuddannelsen/FENDatabaser 2NOEA/IT Datanomuddannelsen/FENDatabaser 2NOEA/IT Datanomuddannelsen/FENDatabaser 2NOEA/IT Datanomuddannelsen/FENDatabaser 2NOEA/IT Datanomuddannelsen/FENDatabaser 2