Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 20- 1 Introduction Object Oriented (OO) Data Models since mid-90’s Reasons for creation of.

Slides:



Advertisements
Similar presentations
Chapter 10: Designing Databases
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
Fundamentals of Database Systems Fourth Edition El Masri & Navathe
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Copyright © 2004 Ramez Elmasri and Shamkant Navathe Elmasri/Navathe, Fundamentals of Database Systems, Fourth Edition Chapter 15-1 Query Processing and.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Object Databases Baochuan Lu. outline Concepts for Object Databases Object Database Standards, Languages, and Design Object-Relational and Extended-Relational.
OUTLINE OF THE LECTURE PART I GOAL: Understand the Data Definition Statements in Fig 4.1 Step1: Columns of the Tables and Data types. Step2: Single column.
Overview Begin 6:00 Quiz15 mins6:15 Review Table Terms25 mins6:40 Short Break10 mins6:50 SQL: Creating Tables60 mins7:50 Break10 mins8:00 Lab – Creating.
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.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 28 Database Systems I The Relational Data Model.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
©Silberschatz, Korth and Sudarshan8.1Database System Concepts Chapter 8: Object-Oriented Databases Need for Complex Data Types The Object-Oriented Data.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 SQL: Data Definition, Constraints, and Basic Queries and Updates.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Oracle Objects Object Oriented Database Approach.
Chapter 20 Concepts for Object-Oriented Databases Copyright © 2004 Pearson Education, Inc.
CS 104 Introduction to Computer Science and Graphics Problems Introduction to Database (2) Basic SQL 12/05/2008 Yang Song.
Object Oriented Databases - Overview
July 13, 2015ADBS: OODB1 Concepts for Object-Oriented Databases Chapter 20.
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.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Exam 2 Review Dr. Bernard Chen Ph.D. University of Central Arkansas.
Advanced Database CS-426 Week 2 – Logic Query Languages, Object Model.
CS 380 Introduction to Database Systems (Chapter 5: The Relational Data Model and Relational Database Constraints)
11 1 Object oriented DB (not in book) Database Systems: Design, Implementation, & Management, 6 th Edition, Rob & Coronel Learning objectives: What.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Relational Data Model and Relational Database Constraints.
ORDBS1 Object Relational Database Systems: 1. Introduction 2. Objects in SQL3 3. Comparison of ODL/OQL and SQL3 Approaches CIS 671.
Chapter 21 A Object Data Model - Intro Copyright © 2004 Pearson Education, Inc.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Chapter 20 Concepts for Object-Oriented Databases Copyright © 2004 Pearson Education, Inc.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 5 The Relational Data Model and Relational Database Constraints.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
1 Oracle 8. 2 New features 3 Oracle 8 New features  Abstract data types New features  Abstract data types.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 1.
ITEC 3220A Using and Designing Database Systems Instructor: Prof Z. Yang Course Website: 3220a.htm
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture Presented & Modified.
Prince Sultan University Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
Object Relational Features
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
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:
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Object-Oriented Database.
The ODMG Standard for Object Databases
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
Chapter 20 Concepts for Object-Oriented Databases Copyright © 2004 Pearson Education, Inc.
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.
1 Part IV: Object-Relational Databases  Ch. 30: Types, Object Views, Methods  Ch. 31: Nested Tables and Varying Arrays  Ch. 32: Large Objects  Ch.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Basic SQL تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Relational Data Model and Relational Database Constraints تنبيه.
Concepts for Object Databases
Entity- Relationship (ER) Model
Object – Oriented Databases
Chapter 12 Outline Overview of Object Database Concepts
ISC321 Database Systems I Chapter 10: Object and Object-Relational Databases: Concepts, Models, Languages, and Standards Spring 2015 Dr. Abdullah Almutairi.
Object-Relational Features
Session - 6 Sequence - 1 SQL: The Structured Query Language:
ITEC 3220A Using and Designing Database Systems
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
4/27/2019.
Presentation transcript:

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Introduction Object Oriented (OO) Data Models since mid-90’s Reasons for creation of Object Oriented Databases Need for more complex applications Need for additional data modeling features Increased use of object-oriented programming languages Commercial OO Database products – Several in the 1990’s, but did not make much impact on mainstream data management

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Overview of Object-Oriented Concepts(1) Main Claim: OO databases try to maintain a direct correspondence between real-world and database objects so that objects do not lose their integrity and identity and can easily be identified and operated upon Object: Two components: state (value) and behavior (operations) Similar to program variable in programming language, except that it will typically have a complex data structure as well as specific operations defined by the programmer

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Overview of Object-Oriented Concepts (2) In OO databases, objects may have an object structure of arbitrary complexity in order to contain all of the necessary information that describes the object. In contrast, in traditional database systems, information about a complex object is often scattered over many relations or records, leading to loss of direct correspondence between a real- world object and its database representation.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Overview of Object-Oriented Concepts (3) The internal structure of an object in OOPLs includes the specification of instance variables, which hold the values that define the internal state of the object. An instance variable is similar to the concept of an attribute, except that instance variables may be encapsulated within the object and thus are not necessarily visible to external users

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Overview of Object-Oriented Concepts (4) Some OO models insist that all operations a user can apply to an object must be predefined. This forces a complete encapsulation of objects. To encourage encapsulation, an operation is defined in two parts: signature or interface of the operation, specifies the operation name and arguments (or parameters). method or body, specifies the implementation of the operation.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Overview of Object-Oriented Concepts (5) Operations can be invoked by passing a message to an object, which includes the operation name and the parameters. The object then executes the method for that operation. This encapsulation permits modification of the internal structure of an object, as well as the implementation of its operations, without the need to disturb the external programs that invoke these operations

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Objects Object: triple (i, c, v) i: a unique object identifier (oid). c: a constructor (how the object value is constructed). atom, set, tuple, list, array, bag v: the object value.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Defining Objects Abstract data type – Data type that consist of one or more data types create type ADDRESS_TY as object (Street VARCHAR2(50), City VARCHAR2(25), State CHAR(2), Zip NUMBER); create type PERSON_TY as object (Name VARCHAR2(25), Address ADDRESS_TY); create table CUSTOMER (Customer_ID NUMBER, Person PERSON_TY);

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Objects Basic values, such as integer, may not be represented as objects, avoiding too many OID. OID is different from key in the relational data model. A key is defined by the value of one or more attributes and can be modified. Example of OID: A19E8DE E D 6C1D48A19E8DE E D6C1D0 4000AE10000

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Object Identity, Object Structure, and Type Constructors (2) Type Constructors: In OO databases, the state (current value) of a complex object may be constructed from other objects (or other values) by using certain type constructors. The three most basic constructors are atom, tuple, and set. Other commonly used constructors include list, bag, and array. The atom constructor is used to represent all basic atomic values, such as integers, real numbers, character strings, Booleans, and any other basic data types that the system supports directly.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Object Identity, Object Structure, and Type Constructors (3) Example 1 One possible relational database state corresponding to COMPANY schema

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Object Identity, Object Structure, and Type Constructors (4) Example 1 (contd.):

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Object Identity, Object Structure, and Type Constructors (5) Example 1 (contd.)

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Object Identity, Object Structure, and Type Constructors (6) Example 1 (contd.) We use i 1, i 2, i 3,... to stand for unique system- generated object identifiers. Consider the following objects: o 1 = (i 1, atom, ‘Houston’) o 2 = (i 2, atom, ‘Bellaire’) o 3 = (i 3, atom, ‘Sugarland’) o 4 = (i 4, atom, 5) o 5 = (i 5, atom, ‘Research’) o 6 = (i 6, atom, ‘ ’) o 7 = (i 7, set, {i1, i2, i3})

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Object Identity, Object Structure, and Type Constructors (7) Example 1(contd.) o 8 = (i 8, tuple, ) o 9 = (i 9, tuple, ) o 10 = (i 10, set, {i 12, i 13, i 14 }) o 11 = (i 11, set {i 15, i 16, i 17 }) o 12 = (i 12, tuple, )...

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Object Identity, Object Structure, and Type Constructors (8) Example 1 (contd.) The first six objects listed in this example represent atomic values. Object seven is a set-valued object that represents the set of locations for department 5; the set refers to the atomic objects with values {‘Houston’, ‘Bellaire’, ‘Sugarland’}. Object 8 is a tuple-valued object that represents department 5 itself, and has the attributes DNAME, DNUMBER, MGR, LOCATIONS, and so on.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Object Identity, Object Structure, and Type Constructors (9) Example 2: This example illustrates the difference between the two definitions for comparing object states for equality. o 1 = (i 1, tuple, ) o 2 = (i 2, tuple, ) o 3 = (i 3, tuple, ) o 4 = (i 4, atom, 10) o 5 = (i 5, atom, 10) o 6 = (i 6, atom, 20)

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Object Identity, Object Structure, and Type Constructors (10) Example 2 (contd.): In this example, The objects o1 and o2 have equal states, since their states at the atomic level are the same but the values are reached through distinct objects o4 and o5. However, the states of objects o1 and o3 are identical, even though the objects themselves are not because they have distinct OIDs. Similarly, although the states of o4 and o5 are identical, the actual objects o4 and o5 are equal but not identical, because they have distinct OIDs.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Methods – must be named within the type declaratiom create type PERSON_TY as object ( Name NAME_TY, Address ADDRESS_TY, member function AGE(BirthDate IN DATE) return NUMBER, PRAGMA RESTRICT_REFERENCES(AGE,WNDS) ); / create or replace type body PERSON_TY as member function AGE(BirthDate DATE) return NUMBER is Begin RETURN(ROUND((SysDate - BirthDate) / 365)); end; /

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Collectors – Varying array, nested table Representing multivalued attributes using varying length arrays – a set of objects, each with the same datatype SQL> create type TOOL_TY as object 2 (ToolName VARCHAR2(25)); 3 / SQL> create or replace type TOOLS_VA as varray(5) of VARCHAR2(25); 2 /

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide SQL> create or replace type TOOLS_VA as varray(5) of TOOL_TY; 2 / SQL> create table BORROWER 2 (Name VARCHAR2(25) primary key, 3 Tools TOOLS_VA); SQL> insert into BORROWER values 2 ('JED HOPKINS', 3 TOOLS_VA('HAMMER', 'SLEDGE', 'AX'));

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Nested Table: a table within a table A nested table is a collection of rows, represented as a column within the main table. SQL> create or replace type ANIMAL2_TY as object 2 (Breed VARCHAR2(25), 3 Name VARCHAR2(25), 4 BirthDate Date); 5 / SQL> create type ANIMALS_NT as table of ANIMAL2_TY; 2 /

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide SQL> create table BREEDER1 2 (BreederName VARCHAR2(25), 3 Animals ANIMALS_NT) 4 nested table ANIMALS store as ANIMALS_NT_TAB; SQL> insert into BREEDER1 values 2 ('JANE JAMES', 3 ANIMALS_NT( 4 ANIMAL2_TY('DOG', 'BUTCH', '31-MAR-97'), 5 ANIMAL2_TY('DOG', 'ROVER', '05-JUN-97'), 6 ANIMAL2_TY('DOG', 'JULLO', '10-JUN-97') 7 ));

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Dealing with nested table Insert into table (select Animals from Breeder1 where BreederName = ‘James’) Values (Animal2_ty (‘Dog’,’Markus’,’01-Aug-01’)); Delete table (select Animals from Breeder1 where BreederName = ‘James’) N Where N.Name = ‘Julio’;

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Update update table (select Animals from Breeder1 where BreederName = ‘James’) N Set N.Birthdate = ’01-Sep-01’ Where N.Name = ‘Julio’;

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Object Table: each row is a row object SQL> create or replace type ANIMAL_TY as object 2 (Breed VARCHAR2(25), 3 Name VARCHAR2(25), 4 BirthDate Date); 5 / SQL> create table ANIMAL of ANIMAL_TY; SQL> insert into ANIMAL values (ANIMAL_TY('DOG', 'BENJI', '03-SEP-96')); SQL>update Animal set BirthDate = ’01-May-01’ where Name = ‘Lyle’;

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Difference from tuple table Each row within the object table has an oid – system assigned The rows of an object table can be referenced by other objects within the DB.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide View OID SQL> select REF(A) 2 from ANIMAL A 3 where Name = 'FRANCES'; REF(A) A19E8DE E D6C1D48A1 9E8DE E D6C1D04000AE10000 REF can be used to reference row objects. You cannot reference column objects. Column objects include abstract data types and collectors.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Reference single row objects SQL> create table KEEPER 2 (KeeperName VARCHAR2(25), 3 AnimalKept REF ANIMAL_TY); SQL> insert into KEEPER 2 select 'CATHERINE WEILZ', REF(A) 3 from ANIMAL A 4 where Name = 'BENJI'; SQL> select * from KEEPER; KEEPERNAME ANIMALKEPT CATHERINE WEILZ A19E8DE06A7291E D6C1D48A19E8DE E D6C1D

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide SQL> select DEREF(K.AnimalKept) 2 from KEEPER K 3 where KeeperName = 'CATHERINE WEILZ'; DEREF(K.ANIMALKEPT)(BREED, NAME, BIRTHDATE) ANIMAL_TY('DOG', 'BENJI', '03-SEP-96')

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide SQL> select VALUE(A) 2 from ANIMAL A; VALUE(A)(BREED, NAME, BIRTHDATE) ANIMAL_TY('MULE', 'FRANCES', '01-APR-97') ANIMAL_TY('DOG', 'BENJI', '03-SEP-96')

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide SQL> select * from ANIMAL; BREED NAME BIRTHDATE MULE FRANCES 01-APR-97 DOG BENJI 03-SEP-96

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Reference a group of row objects SQL> create type animals_NT as table of animal_ty; 2 / SQL> create table breeder 2 (breedername VARCHAR2(25), 3 Animals animals_NT) 4 nested table animals store as animals_NT_TAB; SQL> insert into breeder values 2 ('James', animals_NT(animal_ty('dog', 'butch', '31-MAR- 01'), 3 animal_ty('dog', 'ROVER', '05-JUN-01'), 4 animal_ty('dog', 'JULIO', '10-JUN-01')));

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Project schema create type DEPARTMENT_TY as object ( DName CHAR(5), DPhone CHAR(18), Office VARCHAR2(10) ); / create table DEPARTMENT_TB of DEPARTMENT_TY(PRIMARY KEY(DName)); create type DEPARTMENTS_NT as table of REF DEPARTMENT_TY; /

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide create type COURSE_TY as object ( CNumber CHAR(5), CName CHAR(10), CDesc VARCHAR2(30), Dept REF DEPARTMENT_TY ); / create table COURSE_TB of COURSE_TY(PRIMARY KEY(CNumber));

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide create type SECTION_TY as object ( SecNumber NUMBER, Year NUMBER, Qtr NUMBER, Course REF COURSE_TY ); / create table SECTION_TB of SECTION_TY(PRIMARY KEY(SecNumber));

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide create type ADDRESS_TY as object ( No NUMBER, Street CHAR(20), AprtNo CHAR(3), City VARCHAR2(30), State VARCHAR2(20), Zip CHAR(10) ); / create type NAME_TY as object ( FName VARCHAR2(15), MInit CHAR(1), LName VARCHAR2(20) ); /

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide create type PERSON_TY as object ( Name NAME_TY, Address ADDRESS_TY, SSN NUMBER, BirthDate DATE, Sex CHAR(1), member function AGE(BirthDate IN DATE) return NUMBER, PRAGMA RESTRICT_REFERENCES(AGE,WNDS) ); / create or replace type body PERSON_TY as member function AGE(BirthDate DATE) return NUMBER is Begin RETURN(ROUND((SysDate - BirthDate) / 365)); end; /

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide create type SECTIONS_NT as table of REF SECTION_TY; / create type FACULTY_TY as object ( Person PERSON_TY, FPhone CHAR(18), FOffice VARCHAR2(10), Rank NUMBER, Salary NUMBER, Dept DEPARTMENTS_NT, TeachSections SECTIONS_NT ); / create table FACULTY_TB of FACULTY_TY(PRIMARY KEY(Person.SSN)) nested table Dept store as DEPARTMENTS_NT_TAB1 nested table TeachSections store as SECTIONS_NT_TAB3;

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide create type TRANSCRIPT_TY as object ( SectionRef REF SECTION_TY, Grade CHAR(2) ); / create type TRANSCRIPT_NT as table of TRANSCRIPT_TY; /

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide create type STUDENT_TY as object ( Person PERSON_TY, Class NUMBER, MajorDept REF DEPARTMENT_TY, RegisteredSections SECTIONS_NT, TranscriptSections TRANSCRIPT_NT ); / create table STUDENT_TB of STUDENT_TY(PRIMARY KEY(Person.SSN)) nested table RegisteredSections store as SECTIONS_NT_TAB1 nested table TranscriptSections store as SECTIONS_NT_TAB2;