1 Part IV: Object-Relational Databases  Ch. 30: Types, Object Views, Methods  Ch. 31: Nested Tables and Varying Arrays  Ch. 32: Large Objects  Ch.

Slides:



Advertisements
Similar presentations
Advanced SQL (part 1) CS263 Lecture 7.
Advertisements

Oracle Object-Relational Model. - Structures : tables, views, indexes, etc. - Operations : actions that manipulate data stored in structures - Integrity.
9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
Data Definition Language (DDL)
Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.  Objects  Varray  Nested Table  Transaction Control Language(TCL)
Oracle 10g Database Administrator: Implementation and Administration Chapter 8 Advanced Table Management.
1 A GUIDE TO ORACLE8 CHAPTER 2: Creating and ModifyingDatabaseTables 2.
Oracle Objects Object Oriented Database Approach.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Database Management System LICT 3011 Eyad H. Elshami.
Introduction to PL/SQL Lecture 0 – Self Study Akhtar Ali.
Objectives Why PL-SQL ? Language features
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
ORACLE ONLINE TRAINING Contact our Support Team : SOFTNSOL India: Skype id : softnsoltrainings id:
1 © 2008 Julian Dyke LOB Internals Julian Dyke Independent Consultant juliandyke.com Web Version - December 2008.
CHAPTER 11 Large Objects. Need for Large Objects Data type to store objects that contain large amount of text, log, image, video, or audio data. Most.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Session 5: Working with MySQL iNET Academy Open Source Web Development.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 11 Introduction to Dynamic SQL and Object Technology.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
Database Technical Session By: Prof. Adarsh Patel.
1 Advanced Databases (CM036): Lecture # 5 ( Object-Relational and Nested-Relational Databases) Introduction to Object-Relational features of Oracle 9i.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
Chapter 6 1 © Prentice Hall, 2002 The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited) Project Identification and Selection Project Initiation.
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 7 Basic Table Management.
INTRODUCTION TO PL/SQL. Class Agenda Introduction Introduction to PL/SQL Declaring PL/SQL Variable Creating the Executable Section Interacting with the.
10 Copyright © 2009, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Sizing Basics  Why Size?  When to size  Sizing issues:  Bits and Bytes  Blocks (aka pages) of Data  Different Data types  Row Size  Table Sizing.
Overview · What is PL/SQL · Advantages of PL/SQL · Basic Structure of a PL/SQL Block · Procedure · Function · Anonymous Block · Types of Block · Declaring.
1 Creating and Modifying Database Objects. 2 An Oracle database consists of multiple user accounts Each user account owns database objects Tables Views.
1 Oracle 8. 2 New features 3 Oracle 8 New features  Abstract data types New features  Abstract data types.
PL / SQL By Mohammed Baihan. What is PL/SQL? PL/SQL stands for Procedural Language extension of SQL. PL/SQL is a combination of SQL along with the procedural.
8-1 Copyright  Oracle Corporation, All rights reserved. Objects in Oracle8 1.Object Types - object-relational database 2.Large Objects (LOB) types.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Oracle 8i PL/SQL Collections. Collections A Collection is a group of elements of the same kind There are three types of Collections that you can use in.
Oracle 8i Building PL/SQL Blocks. Creating PL/SQL Blocks CURSORS PROCEDURES FUNCTIONS PACKAGES TRIGGERS CURSORS PROCEDURES FUNCTIONS PACKAGES TRIGGERS.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Database Application Development using PL/SQL Programming.
SQL for the Non - Technician Jeffrey Walsh AnswerThink Consulting Group, Inc.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
Database structure and space Management. Segments The level of logical database storage above an extent is called a segment. A segment is a set of extents.
Database Management COP4540, SCS, FIU Physical Database Design (2) (ch. 16 & ch. 6)
Week 4 Lecture 2 Advanced Table Management. Learning Objectives  Create tables with large object (LOB) columns and tables that are index-organized 
Visual Programing SQL Overview Section 1.
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,
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide Introduction Object Oriented (OO) Data Models since mid-90’s Reasons for creation of.
9 Copyright © 2004, Oracle. All rights reserved. Manipulating Large Objects.
1 Chapter 2: Creating and Modifying Database Objects.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
© D. Wong Security and User Authorization in SQL 8.7 pp. 410  Authorization ID = user name  Special authorization ID: PUBLIC  Privileges for:
Chapter 5 : Integrity And Security  Domain Constraints  Referential Integrity  Security  Triggers  Authorization  Authorization in SQL  Views 
SQL Miscellaneous Topics. Views A database view is: – a virtual or logical table based on a query. – a stored query. CREATE VIEW viewname AS query; –CREATE.
Oracle & SQL. Oracle Data Types Character Data Types: Char(2) Varchar (20) Clob: large character string as long as 4GB Bolb and bfile: large amount of.
SLIDE 1IS 257 – Fall 2014 NoSQL Databases University of California, Berkeley School of Information IS 257: Database Management.
Oracle 10g Database Administrator: Implementation and Administration Chapter 10 Basic Data Management.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Introduction to Database Programming with Python Gary Stewart
Introduction To Oracle
Object-Relational DBMSs
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
DATABASE MANAGEMENT SYSTEM
Xerion Pharmaceuticals AG
The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited)
Object-Relational Features
Managing Tables.
PL/SQL Declaring Variables.
Presentation transcript:

1 Part IV: Object-Relational Databases  Ch. 30: Types, Object Views, Methods  Ch. 31: Nested Tables and Varying Arrays  Ch. 32: Large Objects  Ch. 33: Advanced OO Concepts

2 Ch. 30: Types  Abstract datatypes groups related columns/data. create type ADDRESS_TY as object ( Street VARCHAR2(50), City VARCHAR2(25), State CHAR(2), Zip NUMBER);  Abstract datatypes can be nested.  security – must have EXECUTE privilege to use a type.  set describe depth – see attributes within an object.

3 Ch. 30: Types: indexing, selecting, manipulating Create type PERSON_TY ( Name VARCHAR2(25), Address ADDRESS_TY); Create table CUSTOMER ( Cust_Id NUMBER, Person PERSON_TY );  Select: select c.Name, c.Person.Address.City from CUSTOMER c where c.Person.Address.City like ‘I%’;  Indexing: create index IDX_CUST on CUSTOMER (Person.Address.City);  Insert: insert into CUSTOMER values (1, PERSON_TY(‘xxxx’, ADDRESS_TY(‘aaaa’, ‘bbb’, ccc’)));

4 Ch. 30: Object Views. create table CUSTOMER (Cust_id NUMBER PRIMARY KEY, Name VARCHAR2(25), Street VARCHAR2(50), City VARCHAR2(25), State CHAR(2), Zip NUMBER); create type ADDRESS_TY as object ( Street VARCHAR2(50), City VARCHAR2(25), State CHAR(2), Zip NUMBER); create type PERSON_TY ( Name VARCHAR2(25), Address ADDRESS_TY); create or replace view CUSTOMER_OV (Cust_id, person) as select Cust_id, PERSON_TY (Name, ADDRESS_TY(street, city, state, zip)) from CUSTOMER;  Inserting into original table: insert into CUSTOMER values ( 123, ‘name’, ‘Street’, ‘City’, ‘ST’, );  Inserting into object view: insert into CUSTOMER_OV values ( 123, PERSON_TY(‘name’, ADDRESS_TY( ‘Street’, ‘City’, ‘ST’, )));

5 Ch. 30: INSTEAD OF Triggers  Views usually cannot use standard table-based PL/SQL Triggers, but they can use INSTEAD OF triggers. Works with either normal views or object views. create trigger AUTHOR_PUBLISHER_UPDATE instead of UPDATE on AUTHOR_PUBLISHER for each row begin … end;

6 Ch. 30: Methods  Methods allow types to have “behavior”.  Methods are declared inside CREATE TYPE, they are defined with CREATE TYPE BODY. create type PERSON_TY ( Name VARCHAR2(25), Address ADDRESS_TY, Birthday DATE, member function AGE (BirthDate IN DATE) return NUMBER); create or replace type body PERSON_TY as member function AGE (Birthdate DATE) return NUMBER is begin return ROUND(sysdate – Birthdate); end; end;

7 Ch. 31: Collector: Varying Arrays  Definition – a varying array is a set of objects, each of same type, seen as a column within a table. The size is limited when created.  Creating a Varying Array 1.Create type TOOL_TY as object (…); 2.Create type TOOLS_VA as varray(5) of VARCHAR2(25); 3.Create table TOOL_BORROWER (…, Tools TOOLS_VA);  Describing – requires queries on data dictionary to show varray structure.  Selecting – requires PL/SQL, see p  Inserting – insert into TOOL_BORROWER values (‘name’, TOOLS_VA(‘tool1’, ‘tool2’, ‘tool3’));  Storage – stored in-line, ie. within table data segment.

8 Ch. 31: Collector: Nested Tables  Definition – a nested table is a table within a table. Their size is not limited as with varying arrays.  Creating a Nested Table 1.Create type TOOL_TY as object (…); 2.Create type TOOLS_NT as table of TOOL_TY; 3.Create table TOOL_BORROWER (…, nested table Tools TOOLS_NT);  Describing – set describe depth will allow the describe command to show nested tables.  Selecting – requires the TABLE() function (previous to 9i use THE() function). This “flatten’s” or de-normalizes the nested table’s relationship. Select BreederName, N.Name, N.birthdate from BREEDER, TABLE(breeder.Animals) N  Inserting – insert into TABLE(select Animals from BREEDER where Breedername = ‘x’) values (ANIMAL_TY (‘x’,’y’,’z’));  Storage – Nested tables can be stored in or out-of-line. Recommend they be stored out-of-line with a storage clause to improves query performance.

9 Ch. 32: Large Object Datatypes  BLOB – binary field up to 4Gb.  CLOB – character field up to 4Gb.  NCLOB – CLOB that supports MBCS (multi-byte character set).  BFILE – read-only binary data stored in a file outside of the database.

10 Ch. 32: LOB Storage, Initialization  LOB Storage – BLOB and (N)CLOB columns are stored out-of-line. They require the CREATE TABLE statement include a LOB STORAGE clause to tell where the LOB segment is stored. BFILE columns are by their nature stored out-of-line.  LOBs use at least 1 entire data block per row in the LOB segment. Normal DATA segments store multiple rows per block (up to 100% - PCTFREE).  Initializing LOBs – use EMPTY_BLOB or EMPTY_CLOB instead of NULL to initialize a LOB. NULL will create a LOB with no data. EMPTY_BLOB/CLOB will create an empty “LOB locater” (pointer) without allocating the empty block.

11 Ch. 32: DBMS_LOB  LOB data is manipulated with the DBMS_LOB package.  For all LOBs: APPEND COMPARE COPY ERASE GETCHUNKSIZE GETLENGTH INSTR ISOPEN OPEN READ SUBSTR TRIM WRITE WRITEAPPEND  BFILE specific functions: FILEOPEN FILECLOSE FILECLOSEALL FILEEXISTS FILEGETNAME FILEISOPEN LOADFROM FILE  Temporary LOB functions: CREATETEMPORARY FREETEMPORARY ISTEMPORARY

12 Ch. 32: BFILE  Read-only binary data stored in a file outside of the database. CREATE DIRECTORY PROPOSAL_DIR AS ‘C:\My Documents’; Insert into thetable ( col1, bfilecol ) values ( ‘value1’, BFILENAME(‘proposal_dir’, ‘myfile.doc’);  Deleting LOBs – internal LOBs when deleted have both their data and LOB locater deleted. Deleting a BFILE only deletes the locater, the file is read only and thus not changed.

13 Ch. 33: row objects vs. column objects  Row objects  Column objects

14 Ch. 33: REF, DEREF, VALUE  REF  DEREF  VALUE