CS422 Principles of Database Systems Object-Oriented Features in DBMS Chengyu Sun California State University, Los Angeles.

Slides:



Advertisements
Similar presentations
Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.
Advertisements

Chapter 10: Designing Databases
1 © 2006 Julian Dyke Supplemental Logging Julian Dyke Independent Consultant juliandyke.com Web Version.
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.
Fall 2001Arthur Keller – CS 1808–1 Schedule Today Oct. 18 (TH) Schemas, Views. u Read Sections u Project Part 3 extended to Oct. 23 (T). Oct.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 11.
Winter 2002Arthur Keller – CS 1808–1 Schedule Today: Jan. 29 (T) u Modifications, Schemas, Views. u Read Sections Assignment 3 due. Jan. 31 (TH)
Oracle Objects Object Oriented Database Approach.
Object-Oriented Databases
Fundamentals, Design, and Implementation, 9/e Chapter 6 Introduction to Structured Query Language (SQL)
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.)
Fundamentals, Design, and Implementation, 9/e Chapter 16 Object-Oriented Database Processing.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
Introduction to Structured Query Language (SQL)
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 7 Structured Query Language.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
RIZWAN REHMAN, CCS, DU. Advantages of ORDBMSs  The main advantages of extending the relational data model come from reuse and sharing.  Reuse comes.
Database Systems Lecture 5 Natasha Alechina
Object and object-relational databases 1. Object databases vs. Object-relational databases Object databases Stores complex objects – Data + functions.
Agenda  TMA03  M877 Block 3 Databases with Objects.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
Data Access Patterns Some of the problems with data access from OO programs: 1.Data source and OO program use different data modelling concepts 2.Decoupling.
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 11 Introduction to Dynamic SQL and Object Technology.
2440: 141 Web Site Administration Database Management Using SQL Professor: Enoch E. Damson.
1 Advanced Databases (CM036): Lecture # 5 ( Object-Relational and Nested-Relational Databases) Introduction to Object-Relational features of Oracle 9i.
1 Object-Relational Databases User-Defined Types Nested Tables.
Optimize Your Object Model Paul Dayan – Sales Engineer.
DAY 12: DATABASE CONCEPT Tazin Afrin September 26,
Winter 2006Keller, Ullman, Cushing12–1 Object-Relational Systems Object-oriented ideas enter the relational world. u Keep relation as the fundamental abstraction.
Chapter 12: Designing Databases
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 18 Object- Oriented Database Processing.
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 6/1 Copyright © 2004 Please……. No Food Or Drink in the class.
SCUHolliday - coen 1788–1 Schedule Today u Modifications, Schemas, Views. u Read Sections (except and 6.6.6) Next u Constraints. u Read.
Object-Relational SQL CIS 4301 Lecture Notes 4/20/2006.
Chapter 9 Database Systems Introduction to CS 1 st Semester, 2014 Sanghyun Park.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 7 (Part a): Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
FEN NOEA/IT - Databases/ODB1 ODB – Object DataBases Object-Oriented – Fundamental Concepts UML and EE/R OO and Relational Databases Introduction.
Topic : Hibernate 3:Advanced ORM Kaster Nurmukan.
Constraints cis 407 Types of Constraints & Naming Key Constraints Unique Constraints Check Constraints Default Constraints Misc Rules and Defaults Triggers.
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
SQL Overview Structured Query Language. Description  When Codd first described the theory of relational databases, he asserted that there should be a.
© D. Wong Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Basic SQL*Plus edit and execute commands SQL*Plus buffer and built-in editor holds the last SQL statement Statements are created in free-flow style and.
Oracle and Object-Oriented SQL Oracle specific SQL commands.
1 10 Systems Analysis and Design in a Changing World, 2 nd Edition, Satzinger, Jackson, & Burd Chapter 10 Designing Databases.
Oracle 9i Collections. Composite types Several variables as single unit ◦ Records  Different datatype variables are combined here  Ex: All fields of.
CSC314 DAY 8 Introduction to SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL OVERVIEW  Structured Query Language  The.
CS422 Principles of Database Systems Object-Relational Mapping (ORM) Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Object-Relational Mapping with Hibernate and JPA Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Object-Relational Mapping with Hibernate and JPA (I) Chengyu Sun California State University, Los Angeles.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
CS320 Web and Internet Programming SQL and MySQL Chengyu Sun California State University, Los Angeles.
CS422 Principles of Database Systems Entity-Relationship Model Chengyu Sun California State University, Los Angeles.
CS422 Principles of Database Systems Stored Procedures and Triggers Chengyu Sun California State University, Los Angeles.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
CS422 Principles of Database Systems Entity-Relationship Model
CS320 Web and Internet Programming SQL and MySQL
Object-Relational Databases
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
Chengyu Sun California State University, Los Angeles
SQL DATA CONSTRAINTS.
CS2011 Introduction to Programming I Objects and Classes
Chengyu Sun California State University, Los Angeles
CS3220 Web and Internet Programming SQL and MySQL
Chengyu Sun California State University, Los Angeles
CS3220 Web and Internet Programming SQL and MySQL
Presentation transcript:

CS422 Principles of Database Systems Object-Oriented Features in DBMS Chengyu Sun California State University, Los Angeles

Bank Accounts Example Bank account account number balance interests rate creation date owned by one or more customers Customer id name address one or more phones Phone number type  office, home, mobile

The Object-Oriented Approach public class Account { intacctNum; doublebalance; doubleinterestsRate; DatecreatedOn; List owners; }; public class Customer { intcustomerId; Stringname; Stringaddress; List phones; }; public class Phone { Stringnumber; Stringtype; }

The Relational Approach Accounts acctNumbalanceinterestsRatecreatedOn Customers customerIdnameaddress Customers_Accounts customerIdacctNum Phones numbertype Customers_Phones customerIdphoneNum

OO vs. Relational Composite types Collection types References And more … Methods – operations that are associated with certain types Encapsulation, Inheritance and polymorphism

OO Features in DBMS Oracle OO features Objects Collections JDBC support for database objects

Object Type describe phone_t select * from user_types; create type phone_t as object ( phone_numberchar(7), phone_typechar(1) ); /

Object Column create table customers ( customer_idinteger, namevarchar(15), addressvarchar(15), phonephone_t );

Access Object Columns Constructor of phone_t Table alias is required insert into customers values (1,’Joe’,’123 Maple St.’, phone_t (‘ ’,’H’) ); select * from customers c where c.phone.phone_number = ‘ ’;

Object Table describe customers set describe depth {1|n|all} create type customer_t as object ( customer_idinteger, namevarchar(15), addressvarchar(15), phonephone_t ); / create table customers of customer_t;

Access Object Tables Object tables can be accessed as regular tables, or tables with a single column of an object type insert into customers values (1, 'Joe', '123 Maple St.', phone_t(' ','H')); insert into customers values ( customer_t (2,'Sue','234 Main St.', phone_t(' ','O')) ); select * from customers; select value(c) from customers c;

Object Reference create type account_t as object ( account_idinteger, balancenumber(10,2), interests_ratenumber(4,2), created_ondate, ownerref customer_t ); / create table accounts of account_t;

REF and DEREF Reference is implemented with an unique object id (OID) insert into accounts values (1,100.0,1.0,sysdate, (select ref(c) from customers c where customer_id = 1)); select owner from accounts where account_id = 1; select deref(owner) from accounts where account_id = 1;

Referential Integrity Constraint – OO Style A reference can be scoped or unscoped Scoped references are more efficient to use than unscoped ones Scoped references can still be dangling alter table accounts add (scope for (owner) is customers); alter table accounts add foreign key (owner) references customers;

Methods create type account_t as object (... member function interests return number ); / create type body account_t as member function interests return number as begin return balance * interests_rate; end; /

Constructors constructor function account_t ( p_account_id integer, p_balance number, p_interests_rate number, p_created_on date, p_owner_id integer ) return self as result is begin self.account_id := p_account_id; self.balance := p_balance; self.interests_rate := p_interests_rate; self.created_on := p_created_on; select ref(c) into self.owner from customers c where c.customer_id = p_owner_id; return; end;

Inheritance A type is FINAL by default create type account_t as object (... ) not final; create type cd_account_t under account_t ( terminteger );

Collection Types Varrays Nested tables

Varray Variable arrays, or varray Array is bounded by a maximum size All elements must be of the same type Elements can be accessed individually by index in a procedural language, but the array is treated as a whole in SQL. create type phone_list_t as varray(10) of phone_t;

Using Varrays Varray information as a type select * from user_types; Varray information in a table select * from user_varrays; insert into customers values ( 1,'Joe','123 Maple St.', phone_list_t(phone_t(' ','H'), phone_t(' ','O')) ); select phones from customers;

Nested Table A collection type in the form of a table with a single column Each element is a row in the table Any number of elements Elements are of the same type Each element can be accessed individually in SQL

A Nested Table Example Note that the nested table has a single column of a object type phone_t customer_idnameaddressphones 1Joe123 Maple St. 2Sue234 Main St. numbertype Home Office numbertype Home Office Mobile

Creating a Nested Table create type phone_list_t as table of phone_t; / create type customer_t as object ( customer_idinteger, namevarchar(15), addressvarchar(15), phonesphone_list_t ) / create table customers of customer_t nested table phones store as nested_phones;

Using Nested Tables Nested table information as a type select * from user_types; Nested table information in a table select * from user_nested_tables; insert into table (select phones from customers where customer_id = 1) values (' ','M'); select phone_number from table (select phones from customers where customer_id = 1) p where p.phone_type = 'O';

Varray vs. Nested Table Varray Ordered elements Max size Individual element accessible in PL Small varrays (<4k) are stored with parent table Nested table Unordered elements No max size Individual element accessible in SQL Always stored in separate tables

JDBC Support for Database Objects The Java class has to implement SQLData interface getSQLTypeName(); readSQL(SQLInput stream, String typeName); writeSQL(SQLOutput stream); Update the JDBC Type Map connection.getTypeMap().put( “FOO”, Class.forName(“Foo”)); Resultset.getObject() PreparedStatement.setObject()