ORDBS1 Object Relational Database Systems: 1. Introduction 2. Objects in SQL3 3. Comparison of ODL/OQL and SQL3 Approaches CIS 671.

Slides:



Advertisements
Similar presentations
Object Oriented Database Group 4 Mathieu Metz Palani Kumaresan Napa Gavinlertvatana Kristine Pei Keow Lee Prabhu Ramachandran.
Advertisements

Why Object-Oriented DBMS? Abstract data types Interface with host programming language (the impedance mismatch). Object identity: (peter, 40, {(john, 15,
CSC 570 Notes for Chapter 10 Advanced Topics in Relational Databases.
Object Databases Baochuan Lu. outline Concepts for Object Databases Object Database Standards, Languages, and Design Object-Relational and Extended-Relational.
Fall 2005 ICS184/EECS116 – Notes 08 1 ICS 184/EECS116: Introduction to Data Management Lecture Note 8 SQL: Structured Query Language -- DDL.
Database Design -- Basic SQL
ODMG Standard: Object Model1 OBJECT-ORIENTED DATABASE SYSTEMS ODMG Standard: Object Model Susan D. Urban and Suzanne W. Dietrich Department of Computer.
Sanjay Goel, School of Business, University at Albany, SUNY 1 SQL- Data Definition Language ITM 692 Sanjay Goel.
Representing Data Elements Gayatri Gopalakrishnan.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 SQL: Data Definition, Constraints, and Basic Queries and Updates.
Winter 2002Arthur Keller – CS 18012–1 Schedule Today: Feb. 19 (T) u Object-Relational Systems. u Read Sections 4.5, Assignment 5 due. Feb. 21.
Object-Orientation in Query Languages By: Toan Nguyen Class: CS 157A.
Using Objects and Properties
Fall 2001Arthur Keller – CS 18014–1 Schedule Nov. 13 (T) Object-Relational, O-R Queries. u Read Sections 4.5, Assignment 6 due. (No office hours.)
Programs with SQL Host language + Embedded SQL Preprocessor Host Language + function calls Host language compiler Host language program Preprocessor Host.
Other Data Models. Text New edition (DBS the complete book): Chapter 4 Old edition (First course in DBS): –Section 2.1 –Section –Section 2.4.1,
SQL Overview Defining a Schema CPSC 315 – Programming Studio Spring 2008 Project 1, Lecture 3 Slides adapted from those used by Jeffrey Ullman, via Jennifer.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Object and Object- Relational Databases.
1 Announcements Research Paper due Monday November 22.
Databases Illuminated Chapter 7 The Object-Oriented Model.
RIZWAN REHMAN, CCS, DU. Advantages of ORDBMSs  The main advantages of extending the relational data model come from reuse and sharing.  Reuse comes.
1 Relational Data Model CS 157B Nidhi Patel. 2 What is a Data Model? A notation for describing data or information A notation for describing data or information.
Database Systems Lecture 5 Natasha Alechina
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Object and object-relational databases 1. Object databases vs. Object-relational databases Object databases Stores complex objects – Data + functions.
Advanced Database CS-426 Week 2 – Logic Query Languages, Object Model.
SQL Overview Defining a Schema CPSC 315 – Programming Studio Slides adapted from those used by Jeffrey Ullman, via Jennifer Welch Via Yoonsuck Choe.
Structured Query Language (SQL) A2 Teacher Up skilling LECTURE 2.
Programming Languages
PL / SQL P rocedural L anguage / S tructured Q uery L anguage Chapter 7 in Lab Reference.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Object Query Language (OQL) and Language Binding
DBMS Lecture 9  Object Database Management Group –12 Rules for an OODBMS –Components of the ODMG standard  OODBMS Object Model Schema  OO Data Model.
CSE314 Database Systems Lecture 4 Basic SQL Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Practical Session 13 Structured Data Bases Structured Query Language Exam Questions Factory Method Pattern Abstract Factory Pattern.
Why Object-Oriented DBMS? Abstract data types (relational data model is too simple). Interface with host programming language Managing large number of.
Chapter 5 Types. Topics in this Chapter Values vs. Variables Types vs. Representations Type Definition Operators Type Generators SQL Facilities.
1 Advanced Databases (CM036): Lecture # 5 ( Object-Relational and Nested-Relational Databases) Introduction to Object-Relational features of Oracle 9i.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 8 Part 1 SQL-99 Schema Definition, Constraints, Queries, and Views.
1 Object-Relational Databases User-Defined Types Nested Tables.
ADVANCED DATABASE SYSTEMS DR. FATEMEH AHMADI- ABKENARI SEPTEMBER Object Databases.
CSc-340 3b1 Intermediate SQL Chapter 4 [2 of 2] Phase 1 of Student Projects SQL Data Types & Schemas Authorization.
Object relational database managmement systems (ORDBMS) Adapted by Edel Sherratt from originals by Nigel Hardy.
1 Advanced Databases (CM036) – Lecture # 12: The ODMG Standard for Object Databases Object Query Language (OQL) & Language Binding Advanced Database Technologies.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Chapter 5 Types. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.5-2 Topics in this Chapter Values vs. Variables Types vs. Representations.
Object Relational Features
CS 338The Relational Model2-1 The Relational Model Lecture Topics Overview of SQL Underlying relational model Relational database structure SQL DDL and.
11-1 CHAPTER 11 Concepts for Object-Oriented Databases.
© D. Wong Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:
CMPT 258 Database Systems The Relationship Model (Chapter 3)
Object-Relational Model. Review: Data Models Hierarchical Network ER (Pure) Relational (Pure) Object-oriented (ODMG) Object-relational (since SQL:1999)
Row Types in SQL-3 Row types define types for tuples, and they can be nested. CREATE ROW TYPE AddressType{ street CHAR(50), city CHAR(25), zipcode CHAR(10)
AND OBJECT-ORIENTED DATABASES OBJECT-RELATIONAL DATABASES.
Week 8-9 SQL-1. SQL Components: DDL, DCL, & DML SQL is a very large and powerful language, but every type of SQL statement falls within one of three main.
©Silberschatz, Korth and Sudarshan1 Structured Query Language (SQL) Data Definition Language Domains Integrity Constraints.
The ODMG Standard for Object Databases
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
The Relational Model of Data Prof. Yin-Fu Huang CSIE, NYUST Chapter 2.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 8 Object-Relational Database.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Chapter 12 Outline Overview of Object Database Concepts Object-Relational Features Object Database.
IST 210 Object Oriented Database. IST 210 Object-Oriented Concepts  Abstract Data Types  Class definition, provides extension to complex attribute types.
1 Chapter 8 Object-oriented Query Languages. 2 Object-oriented query language OQL (Object Query Language) –ODMG (Object Database Management Group) –ODMG-93.
Why Object-Oriented DBMS?
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Chapter 12 Outline Overview of Object Database Concepts
Chapter 3 Introduction to Classes, Objects Methods and Strings
SQL OVERVIEW DEFINING A SCHEMA
SQL-1 Week 8-9.
Presentation transcript:

ORDBS1 Object Relational Database Systems: 1. Introduction 2. Objects in SQL3 3. Comparison of ODL/OQL and SQL3 Approaches CIS 671

ORDBS2 Object Query Language (OQL) “Bring the best of SQL to the object world.” Syntax similar to SQL Plus additional features Works with programming languages where ODMG has defined bindings –Java, C++, Smalltalk –Returns object matching type system of that language –May implement class operations in these languages SQL3 – “Bring the best of the object-oriented world to the relational world.”

ORDBS3 Overview:Object Relational DB Systems SQL3 Interfacing SQL to a programming language. –Cursors Data Types –Built-in –User Defined Operations

ORDBS4 Data Types – Built-in smallint – 16-bit integer integer – 32-bit integer decimal(p,s) – decimal number, precision p, scale s float – 32-bit float double – 64-bit float date – year, month, day time – hour, minute, second timestamp - year, month, day, hour, minute, second, microsecond interval – year/month or day/time char(n) – fixed length, n ≤ 254 varchar(n) – varying length –n ≤ 254 –254 ≤ n ≤ 4000; no group by, etc. bit(n) varbit(n) boolean [SQL3] Large Objects [SQL3] –blob(binary large object) ≤ 2 31 –1 bytes –clob(character large object) ≤ 2 31 –1 bytes Domain e.g.,create domain SSN_TYPE as char(9) not used much.

ORDBS5 Objects in SQL3 Row objects, tuples or structs, and Abstract data types (ADT), general objects, used as components of tuples.

ORDBS6 Movies title year length /* in minutes */ filmType:{color, blackAndWhite} lengthInHours starNames otherMovies Movies Example: Movies, Stars, Studios ODL Version Stars name address street city Studios name starsstarredIn ownedByowns Set of stars of this movie. Other movies by star of this movie.

ORDBS7 Movies Example: Movies, Stars, Studios ER Version MovieMovieStar StarsIn NM

ORDBS8 Row Types [SQL3 or SQL:1999] Row-type Definition: create row type T ( ) Examples: create row type AddressType( streetchar(50), citychar(20)); create row type StarType( namechar(30), addressAddressType ); create table MovieStar of type StarType; selectMovieStar..name, MovieStar..address..street fromMovieStar WhereMovieStar..address..city = ‘Columbus’; Cannot directly represent set of movies starred-in. Double dot Path Exp.

ORDBS9 References SQL3’s way to represent “objects”. create row type StarType( namechar(30), addressAddressType ); create row type MovieType( titlechar(30), yearinteger ); create row type StarsInType( starref(StarType), movieref(MovieType) ); create table Movie of type MovieType; create table MovieStarof type StarType; create table StarsIn of type StarsInType; select movie -> title fromStarsIn wherestar->name = ‘Mel Gibson’ Dereferencing operator (->) MovieMovieStar StarsIn NM

ORDBS10 Object Identifiers May be explicitly declared and accessed. Can serve as both object ID and primary key. create row type MovieType( movie_idref(MovieType), titlechar(30), yearinteger ); create row type StarType( star_idref(StarType), namechar(30), addressAddressType ); create table Movie of type MovieType values for movie_id are system generated; create table MovieStarof type StarType values for star_id are system generated;

ORDBS11 Specifying Scope to Aid Performance create row type StarsInType( starref(StarType), movieref(MovieType) ); create table StarsIn of type StarsInType scope forstarisMovieStar, scope formovieisMovie; select movie -> title fromStarsIn wherestar->name = ‘Mel Gibson’ How to find movies? Examine every StarsIn tuple. Index on name attribute. Could have another relation with StarType.

ORDBS12 Objects in SQL3 Row objects, tuples or structs (REVIEW), and Abstract data types (ADT), general objects, used as components of tuples.

ORDBS13 Abstract data type (ADT) Used as components of tuples, –Not as tuples themselves. Have tuple structure.

ORDBS14 ADT - “Built-in” Functions Constructor functions returning new object of type. –All attributes initially null. –If T is name of ADT, then T() is constructor. Observer functions for each attribute. –If A is attribute name & X is variable whose value is an object of the ADT, then A(X) (or X.A ) is the value of attribute A of object X. Mutator functions for each attribute. –Sets the value of that attribute to a new value. –Normally used on left side of assignment

ORDBS15 Example: Address ADT create type AddressADT ( streetchar(50), citychar(20), equalsaddrEq, less thanaddrLT other functions could be declared here ); Addresses will be encapsulated Access to street & city allowed only if observer and mutator functions made public. Functions addrEQ and addrLT defined later.

ORDBS16 More interesting example: ADT for Mpegs create type Mpeg ( videoblob, lengthinteger, copyrightvarchar(255), equals default, /* i.e., identity */ less than none definitions of MPEG functions go here );

ORDBS17 Defining Methods for ADT’s Function types –Internal Written in SQL. –External Written in C++, Java, etc. Only signature appears in definition of the ADT. Function ( ) returns ;

ORDBS18 Extended SQL := used as assignment operator. Variable local to the function can be declared by giving its name, preceded by a colon and followed by its type. :schar(50)/* s will be a street */ Dot operator used to access components of a structure :a.street := :s /* a, an address */ Boolean values can be expressed as in where clauses. begin and end are used to collect several statements into the body of a function.

ORDBS19 Some Functions for the ADT AddressADT: 1. Constructor Function function AddressADT (:s char(50), :c char(20)) returns AddressADT; :a AddressADT; /* declare local variable */ begin :a := AddressADT(); /* use built-in constructor */ :a.street := :s; :a.city := :c; return :a; end; Note:We can use the same name, AddressADT, as the default constructor.

ORDBS20 More Functions for the ADT AddressADT: 2. equals (addrEq )and less than (addrLT) Functions function addrEq (:a1 AddressADT, :a2 AddressADT) returns boolean; return (:a1.street= :a2.street and :a1.city = :a2.city); function addrLT (:a1 AddressADT, :a2 AddressADT) returns boolean; return ((:a1.city < :a2.city) or (:a1.city = :a2.city and :a1.street < :a2.street));

ORDBS21 Another Function for the ADT AddressADT: function fullAddr (:a AddressADT) returns char(82); :z char(10); /* for the zip code nnnnn-nnnn*/ begin :z := findZip(:a.street, :a.city ); return (:a.street || ‘ ‘ || :a.city || ‘ ‘ || :z); end; 3. fullAddr, function returning the full address, including zip code, as a single character string findZip, an externally defined function which looks up the zip code for a given city and street.

ORDBS22 External Functions ADT Definition must include: –Signature. –Specification of programming language in which function is written. declare external findZip char(50), char(20) returns char(10) language Java; Arguments passed according to Java conventions.

ORDBS23 Comparison of ODL/OQL and SQL3 Approaches Similarities outweigh differences, even though origins different: –ODL/OQL: object-oriented programming languages. –SQL3: relational database languages. Have effectively adopted ideas from each other.

ORDBS24 Comparing ODL/OQL vs. SQL3 actually ODL/OQL vs. SQL3 row types vs. SQL3 ADT types 1.Programming environment. 2.Role of relations. 3.Encapsulation. 4.Extents of classes. 5.Mutability of objects. 6.Object identity.

ORDBS25 ODL/OQL vs. SQL3 row types vs. SQL3 ADT types 1. Programming environment OQL –Assumes statements embedded in OO programming language, C++, Java, … SQL3 –Objects not objects of surrounding programming language. –External functions in SQL3 ADT’s provide additional flexibility.

ORDBS26 ODL/OQL vs. SQL3 row types vs. SQL3 ADT types 2. Role of relations OQL –Sets and bags of objects or structures are central. SQL3 –Relations are central. –Row types describe relations. –ADT’s describe new types for attributes. Collections of structures in ODL/OQL similar to Relations in SQL3.

ORDBS27 SQL3 Row Types –Not encapsulated. –Querying & modifying relations, tuples, and components allowed. SQL3 ADT’s –Encapsulated in the usual sense. ODL Classes –Similar to SQL3 ADT’s in encapsulation ODL/OQL vs. SQL3 row types vs. SQL3 ADT types 3. Encapsulation

ORDBS28 ODL/OQL vs. SQL3 row types vs. SQL3 ADT types 4. Extents for Classes OQL –Single extent maintained for each class. –Thus references (relationships in OQL) always refer to some member or members of this extent. SQL3 –An extent for a row type allowed, but not required. If no extent for a row type, then may be problem finding relation containing referenced tuple.

ORDBS29 ODL/OQL vs. SQL3 row types vs. SQL3 ADT types 5. Mutability of Objects Immutable Object: once created, no part of its values can change. –Objects of elementary type, e.g., integers or strings, are immutable. Mutable Object: components may change, while object retains its identity. ODL Classes & SQL3 Row Types –Define classes of mutable objects. –ODL/OQL: modification occurs through surrounding programming language, not through OQL. SQL3 ADT’s –Mutator functions applied to their values result in new value, which may replace old one. Similar to SQL update statement on integer-valued attribute produces a new integer that might replace the old integer in the tuple.

ORDBS30 ODL/OQL vs. SQL3 row types vs. SQL3 ADT types 6. Object Identity OQL & SQL3 ADT’s –“Standard” OID: system generated, which cannot be stored or manipulated by user. SQL3 Row Type –User can create “primary key”. –Without this relations would usually have two “keys”: OID Surrogate value, e.g., Employee_ID.