Chapt 1 odbms

91
DR. SUSHIL KULKARNI OBJECT DATABASE SYSTEM

description

This is the lecture given on Object Oriented database.

Transcript of Chapt 1 odbms

Page 1: Chapt 1 odbms

DR. SUSHIL KULKARNI

OBJECT DATABASE SYSTEM

Page 2: Chapt 1 odbms

2

Object Database System :

Objectives

� Problems with RDBMS

� What is ODBMS and ORDBMS ?

� Advantages and Disadvantages

� OO/ER model comparison and object

schema

� Object type : Attributes and Methods

� Collection types

Page 3: Chapt 1 odbms

3

PROBLEMS

Page 4: Chapt 1 odbms

4

ProblemsProblems

� Poor representation of ‘real world’ Entities.

- Relations are too dry, contains only state of a

relation.

- Relationships are not known.

� Example:

Page 5: Chapt 1 odbms

5

Problems !Problems !

killed

d_no

dok

p_no

treats

d_no

since

p_no

doctor

d_no

telno city

dname

paddress

patient

p_no pname

Page 6: Chapt 1 odbms

6

PROBLEMS !PROBLEMS !

�Homogeneous data structure

• All rows have the same number of attributes.

• All values in a column are of the same type.

• All attribute values are atomic.

�Fixed length of data type, Limited data types

• Can not store images, audio and video clips.

• Spatial, temporal data can not be added.

Page 7: Chapt 1 odbms

7

PROBLEMS !PROBLEMS !

� Reusability (inheritance) of a table is not possible.

Options are:

Object-oriented databases ?

Object-relational databases ?

Page 8: Chapt 1 odbms

8

Storing Objects in a Relational Database

For the purposes of discussion, consider the inheritance

hierarchy which has a super class:

Staff

and three subclasses:

Manager,

SalesPersonnel,

Secretary.

Begin with ExampleBegin with Example!!

Page 9: Chapt 1 odbms

9

Begin with ExampleBegin with Example!!

Page 10: Chapt 1 odbms

10

Map each class to a relation:

Staff(staffNo, fName, IName,

position, sex, DOB, salary)

Begin with ExampleBegin with Example!!

Page 11: Chapt 1 odbms

11

Map each subclass to a class and convert to relation

Manager (staffNo, fName, IName, position, sex, DOB, salary,

bonus, mgrStartDate)

SalesPersonnel (staffNo, fName, IName, position, sex, DOB, salary,

salesArea, carAllowance)

Secretary (staffNo, fName, IName, position, sex, DOB, salary,

typingSpeed)

Begin with ExampleBegin with Example!!

Page 12: Chapt 1 odbms

12

Map the hierarchy to a single relation

Staff (staffNo, fName, IName, position, sex, DOB, salary, bonus,

mgrStartDate, sales-Area, carAllowance, typingSpeed, typeFlag)

Begin with ExampleBegin with Example!!

Page 13: Chapt 1 odbms

13

� The best solution of all above problems is in

Object Relational Database Management System.

� For example: In Oracle ,we can create an object Staffin database and then we can create three different tables namely Manager, Salepersonnel and Secretary,each refer to object created Staff as one of its attribute.

� The whole process of designing the above database with syntax of Oracle 9i is explained here below:

ORDBMS ApproachORDBMS Approach

Page 14: Chapt 1 odbms

14

Creation of an object staff:

CREATE TYPE staff AS OBJECT(

staffno number(4) primary key,

fname varchar(20),

lname varchar(20),

position varchar(10),

sex varchar(1),

DOB date,

salary number(8,2));

ExampleExample

Page 15: Chapt 1 odbms

15

The object staff can be referenced in table Manager as one

of its attribute as shown below:

CREATE TABLE manager(

staff_detail staff,

bonus number(5),

mgrstartdate date);

ExampleExample

Page 16: Chapt 1 odbms

16

Let us insert the values:

INSERT INTO manager VALUES

(staff(100,’ajay’,’arora’,’production

manager’,’m’,’25-feb 1976’,15000 ),

2000,’12-dec-2002’);

ExampleExample

Page 17: Chapt 1 odbms

17

Similarly we create other tables as shown below:

CREATE TABLE salepersonnel(

staff_detail staff,

salearea varchar(25),

carallowance number(7));

CREATE TABLE secretary(

staff_detail staff,

typingspeed number(3));

ExampleExample

Page 18: Chapt 1 odbms

18

In response to the increasing complexity of

database applications, two 'new' data models have

emerged:

Object-Oriented Data Model (OODM)

Object-Relational Data Model (ORDM)

New data ModelsNew data Models

Page 19: Chapt 1 odbms

19

OO AND ER MODEL OO AND ER MODEL

COMPARISIONCOMPARISION

N / AMethod

N / AOID

Primary KeyN / A

AttributesInstance Variable

Entity setClass

EntityObject

Entity definitionType

EE-- R MODELR MODELOO DATA MODELOO DATA MODEL

Page 20: Chapt 1 odbms

20

OODBMSDBMS

ODBMSODBMS

Object Oriented

Features

Conventional DBMS Conventional DBMS

FeaturesFeatures

++

OO Concepts

OO Data model

OOPL

Data accessibility

Persistence

Back up & recovery

Transaction

Concurrency

Security

Page 21: Chapt 1 odbms

21

OODBMSDBMS

ODBMS is the MS process methods applied for

DB data structure, which is complied with O

objects.

ODBMS = O * DB * MSODBMS = O * DB * MS

Page 22: Chapt 1 odbms

22

� Integrating database capabilities with object programming language capabilities, the result is an object-oriented database management system or ODBMS.

�An ODBMS makes database objects appear as programming language objects in one or more existing programming languages.

�Object database management systems extend the object programming language with transparently persistent data, concurrency control, data recovery, associative queries, and other database capabilities.

ODBMSODBMS

Page 23: Chapt 1 odbms

23

Following is the one of the approach for designing an

object-oriented database:

� The user will create classes, objects, inheritance and so on.

� Database system will store and manage these objects and classes.

� Translation layer is required to map the objects created by user into objects of the database system.

Object Database (ODBMS) for Java, written entirely in Java, and

compliant with the Java Data Objects (JDO) standard developed

By Sun.

ODBMSODBMS

Page 24: Chapt 1 odbms

24

� The object-oriented data model allows the 'real world' to be modeled more closely.

� ODBMSs allow new data types to be built from existing types.

� More expressive query language then SQL.

� Applicability to advanced database applications

There are many areas where traditional DBMSs have not been

particularly successful, such as, Computer-Aided Design (CAD),

CASE, Office Information Systems (OIS), and Multimedia

Systems. The enriched modeling capabilities of OODBMSs have

made them suitable for these applications.

AdvantagesAdvantages

Page 25: Chapt 1 odbms

25

� No universally agreed data model for an ODBMS, and most models lack a theoretical foundation.

�In comparison to RDBMSs, the use of ODBMS is still relatively limited.

�There is no standard object-oriented query language.`

�Lack of support for views.

�No adequate security mechanisms for accessing objects.

DisadvantagesDisadvantages

Page 26: Chapt 1 odbms

26

ORORDBMSDBMS

ORDBMS is the MS process methods applied for DB

data structure, which is complied with O object and R

Relational concepts.

ORDBMS = ODBMS + RDBMS

= (O + R) * DB * MS.

ORDBMS = ODBMS + RDBMS ORDBMS = ODBMS + RDBMS

= (O + R) * DB * MS.= (O + R) * DB * MS.

Page 27: Chapt 1 odbms

27

This system simply puts an object oriented front end on a

relational database (RDBMS). When applications interface

to this type of database, it will normally interface as

though the data is stored as objects.

The system will convert the object information into data

tables with rows and columns and handle the data the

same as a relational database.

ORDBMSORDBMS

Page 28: Chapt 1 odbms

28

� The object type can be reuse and share in different application.

� ORDBMS provides increased productivity both for the developer and for the end user.

� It is just an extension of existing relational approach.

AdvantagesAdvantages

Page 29: Chapt 1 odbms

29

� Complexity increases and associated costs.

� Simplicity and purity of the relational model are lost.

� Because the ORDBMS converts data between an object oriented format and RDBMS format, speed performance of the database is degraded substantially. This is due to the additional conversion work the database must do.

DisadvantagesDisadvantages

Page 30: Chapt 1 odbms

30

OBJECT

Page 31: Chapt 1 odbms

31

ObjectObject

� Uniquely identifiable entity that contains both the

attributes that describe the state of a real-world

entity and the actions associated with it.

Definition is similar to definition of an entity,

however, object encapsulates both state and

behavior; an entity only models state.

Page 32: Chapt 1 odbms

3221

Object Attribute

( Instance Variables)

Attributes - contains current state of an object.

- Known as instance variables in OO environment.

Page 33: Chapt 1 odbms

33

Object State

� Set of values that object’s attributes have at a

given time.

� Can vary, although its OID remains the same.

� To change the object’s state, change the values

of the object’s attributes.

Page 34: Chapt 1 odbms

3426

Object : PERSON

State: Attribute ValueAttribute Name

[email protected]

9967770659Cell no.

22345643Home Tel no.

17/3/1986DOB

AditiFirst name

ShekharMiddle name

TatkareLast name

E12345PAN

These are the simple or primitive attributes

Page 35: Chapt 1 odbms

35

OBJECT SCHEMA: GRAPHICAL OBJECT SCHEMA: GRAPHICAL

REPRESENTATIONREPRESENTATION

NAME s

ADDRESS s

DOB s

SEX s

AGE i

EMPLOYEE

Aditi S. Tatkare112, Malabar Hill ..17-March-1986F25

SHARED REPRESENTATION FOR ALL OBJECTS OF THE

CLASS EMPLOYEE

SHARED REPRESENTATION FOR ALL OBJECTS OF THE

CLASS EMPLOYEE

INSTANCE VARIABLESINSTANCE VARIABLES OBJECT INSTANCESOBJECT INSTANCES

Page 36: Chapt 1 odbms

36

Methods

� Code that performs a specific operation on object’s

data.

� Used to change the object’s attribute values or to

return the value of selected object attributes.

� Represent real-world actions.

Page 37: Chapt 1 odbms

37

Method Components

sum=0

Method=sum

Sum = sum +1/x

Return (sum) Return the sum

Page 38: Chapt 1 odbms

38

Depiction of an Object

Page 39: Chapt 1 odbms

39

DATA TYPES

FORATTRIBUTES

Page 40: Chapt 1 odbms

4021

Data types for attributes

Two types of attributes: Simple & Abstract

� Simple attribute are conventional attributes like

number, string ,which takes on literal values.

� They are also called primitive attributes.

Page 41: Chapt 1 odbms

4126

Object : PERSON ( cont’d)

Attribute ValueAttribute Name

HR, AccountsDept *

Street Address, House Number, City, State

Pin

Address *

*Represents an attribute represent one or more attributes.

Let us consider few attributes for Person object:Let us consider few attributes for Person object:

Page 42: Chapt 1 odbms

4221

Abstract Data Type

�To add address information for a person , we have to

consider separate attributes: Street Address, House

Number, City , State and Pin using primitive data

types.

�With abstract data typing, we can create a new data

type and manipulate the data as if it were primitive

data type.

Page 43: Chapt 1 odbms

4321

Operations on ADT

�DBMS allows to store and retrieve images using

CLOB and BLOB like an object of any other type

such as number.

�One can define operations on an image data type

such as compress, rotate, shrink and crop.

� ADT is the combination of an atomic data type and

its associated methods.

Page 44: Chapt 1 odbms

44

STRUCTURED TYPE

USING ORACLE

Page 45: Chapt 1 odbms

45

Structured Type: Object Type

� Structured type are type constructor . For example the structured type for object person is given below using oracle:

� Creating Object

CREATE TYPE person AS OBJECT

( PIN number,

First_name varchar2(15),

Middle_name varchar2(15),

Last_name varchar2(15),

dob date,

Tel_no varchar2(10),

salary number,

MEMBER FUNCTION raise_sal RETURN NUMBER

);

/

Type created.

Page 46: Chapt 1 odbms

46

Create EMP Table

� Creating Table with ADT Object Datatype

Now we will create EMP table for employees.

CREATE TABLE EMP

( EMPID Number primary key,

EMPLOYEE PERSON);

Table created.

Page 47: Chapt 1 odbms

47

EMP Structure

�Use DESC command to see the table structure.

SQL> DESC EMP

Name Null? Type

----------------------- -------- ------------

EMPID NOT NULL NUMBER

EMPLOYEE PERSON

Page 48: Chapt 1 odbms

48

Insert into EMP

� We will now populate our table.

SQL> INSERT INTO EMP(empid, employee)

VALUES(1001,

person(122,'Sushil','Trymbak','Kulkarni',

'29-jun- 1984','24144386',10000));

1 row created.

SQL> INSERT INTO EMP1 (empid, employee)

VALUES(1002,

person(124,‘Aditi',‘Shekhar',‘Tatkare',

'17-may-1986','22345643',120000));

1 row created.

Page 49: Chapt 1 odbms

49

Select statement on EMP

We can select the records with simple SQL statement. E.g.

SELECT *

FROM EMP

/

EMPID

----------

EMPLOYEE(PIN, FIRST_NAME, MIDDLE_NAME, LAST_NAME, DOB, TEL_NO, SALARY)

-------------------------------------------------------

1001

person(122,'Sushil','Trymbak','Kulkarni',

'29-jun- 1984','24144386',10000)

1002

person(124,‘Aditi',‘Shekhar',‘Tatkare',

'17-march-1986','22345643',120000)

Page 50: Chapt 1 odbms

50

METHODS

Page 51: Chapt 1 odbms

5126

Modeling Object Behavior :

Methods

� Method - Defines behavior of an object, as a set of

encapsulated operations.

� We can store methods in TYPE objects. We use

MEMBER FUNCTION or MEMBER PROCEDURE in

CREATE TYPE statement. Then we put the

definition of the method in CREATE TYPE BODY

statement.

Page 52: Chapt 1 odbms

52

Create Method Data type

CREATE TYPE BODY person AS

MEMBER FUNCTION raise_sal RETURN NUMBER IS

BEGIN

RETURN salary * 1.1;

END;

END;

/

Type body created.

THIS DEFINITION OF FUNCTION IS TO BE WRITTEN AFTHER PERSON TYPE IS CREATED.

Page 53: Chapt 1 odbms

53

OID

Page 54: Chapt 1 odbms

54

Object IdentityObject Identity

� Object identifier (OID) assigned to object when it is

created that is:

– System-generated.

– Unique to that object.

– Invariant.

– Independent of the values of its attributes (that is,

its state).

– Invisible to the user.

Page 55: Chapt 1 odbms

55

OBJECT SCHEMA: GRAPHICAL OBJECT SCHEMA: GRAPHICAL

REPRESENTATIONREPRESENTATION

NAME Aditi S. Tatkare

ADDRESS 112, Malabar Hill.

DOB 17-March-1986

SEX F

AGE 25

EMPLOYEE OID X 20

STATE OF EMPLOYEE OBJECT INSTANCESTATE OF EMPLOYEE OBJECT INSTANCE

INSTANCE

VARIABLE

VALUES

INSTANCE

VARIABLE

VALUES

SYSTEM

GENERATED

SYSTEM

GENERATED

Page 56: Chapt 1 odbms

56

OBJECT SCHEMA: GRAPHICAL OBJECT SCHEMA: GRAPHICAL

REPRESENTATIONREPRESENTATION

F_NAME s

M_NAME s

L_NAME s

NAME

DEFINING THREE ABSTRACT DATA TYPEDEFINING THREE ABSTRACT DATA TYPE

BLDG.NO i

STREET s

CITY s

STATE s

PIN i

ADDRESS

DAY i

MONTH i

YEAR i

DOB

Page 57: Chapt 1 odbms

57

OBJECT SCHEMA: GRAPHICAL OBJECT SCHEMA: GRAPHICAL

REPRESENTATIONREPRESENTATION

NAME

ADDRESS

DOB

SEX

AGE

EMPLOYEE

OBJECT REPRESENTATION FOR INSTANCES OF THE

CLASS EMPLOYEE WITH ADT’S

OBJECT REPRESENTATION FOR INSTANCES OF THE

CLASS EMPLOYEE WITH ADT’S

NAME

ADDRESS

DOB

SEX

AGE

Data Types

Page 58: Chapt 1 odbms

58

F_NAME Aditi

M_NAME S.

L_NAME Tatkare

NAME OID X 201

BLDG.NO 112

STREET Malabar Hill

CITY Mumbai

STATE MAHA.

PIN 400018

ADDRESS OID X 202

DAY 17

MONTH 3

YEAR 1987

DOB OID X 203

NAME X 201

ADDRESS X 202

DOB X 203

SEX F

AGE 25

EMPLOYEE OID X 20

OBJECT SCHEMA: GRAPHICAL REPRESENTATIONOBJECT SCHEMA: GRAPHICAL REPRESENTATION

Page 59: Chapt 1 odbms

59

Object Identity ≠≠≠≠ Object Equality

� 2 objects are identical if they have the same OID

(o1 == 02)

� 2 objects are equal if they have the same value

(o1 = 02)

(o1 == 02) ⇒⇒⇒⇒ (o1 = 02)

(o1 = 02) ⇒⇒⇒⇒ (o1 == 02) NON !

Page 60: Chapt 1 odbms

60

Object Identity - Implementation

� In RDBMS, object identity is value-based: primary

key is used to provide uniqueness.

� Primary keys do not provide type of object identity

required in OO systems:

– key only unique within a relation, not across

entire system.

– key generally chosen from attributes of relation,

making it dependent on object state.

Page 61: Chapt 1 odbms

6125

Advantages of OIDs

� They are efficient.

� They are fast.

� They cannot be modified by the user.

� They are independent of content.

Value + OID = object

Page 62: Chapt 1 odbms

62

INHERITANCE

Page 63: Chapt 1 odbms

63

Inheritance

Page 64: Chapt 1 odbms

64

Inheritance

� The definition of an object type determines whether

subtypes can be derived from that type.

� To permit subtypes, the object type must be defined

as not final. This is done by including the NOT

FINAL keyword in its type declaration.

� For example:

Page 65: Chapt 1 odbms

65

Inheritance

CREATE TYPE person_typ AS OBJECT (

pid NUMBER,

name VARCHAR2(30),

phone VARCHAR2(20))

NOT FINAL;

/

Type Created.

CREATE TYPE student_typ UNDER person_typ (

dept_id NUMBER,

major VARCHAR2(30))

NOT FINAL;

/

Type Created.

Page 66: Chapt 1 odbms

66

Inheritance

CREATE TYPE employee_typ UNDER person_typ (

emp_id NUMBER,

mgr VARCHAR2(30));

/

Type Created.

CREATE TYPE part_time_student_typ UNDER student_typ (

number_hours NUMBER);

/

Type Created.

Page 67: Chapt 1 odbms

67

Inheritance

CREATE TABLE contacts (

contact person_typ,

contact_date DATE );

INSERT INTO contacts

VALUES (person_typ (12, 'Hemant Agashe', '99765432414'),

'24 Jun 2003' );

1 row created.

INSERT INTO contacts

VALUES (student_typ(51, 'Sameer Bhende', '9967452317', 12,

'HISTORY'),'24 Jun 2003' );

1 row created.

INSERT INTO contacts

VALUES (part_time_student_typ(52, 'Uday Chitale',

'9978561234', 14,'PHYSICS', 20), '24 Jun 2003' );

1 row created.

Page 68: Chapt 1 odbms

68

Inheritance

� Attributes in general can be accessed using the

dot notation. Attributes of a subtype of a row or

column's declared type can be accessed with the

TREAT function.

� For example:

Page 69: Chapt 1 odbms

69

Inheritance

SELECT TREAT(contact AS student_typ).major FROM

contacts;

TREAT(CONTACTASSTUDENT_TYP).MA

------------------------------

HISTORY

PHYSICS

Page 70: Chapt 1 odbms

70

Inheritance

SQL> SELECT TREAT(contact AS student_typ).major , TREAT(contact AS person_typ).name FROM contacts;

TREAT(CONTACTASSTUDENT_TYP).MA TREAT(CONTACTASPERSON_TYP).NAME

------------------------------ ------------------------------

Hemant Agashe

HISTORY Sameer Bhende

PHYSICS Uday Chitale

Page 71: Chapt 1 odbms

71

COLLECTION

TYPE

Page 72: Chapt 1 odbms

72

Database Design For ORDBMS

� Database designer can get an opportunity to use rich variety of data types for ORDBMS.

� Creating Collection Data types:

• A varray is an ordered collection of elements.

• A nested table can have any number of elements.

Page 73: Chapt 1 odbms

73

Database Design For ORDBMS

If you need

• to store only a fixed number of items, or

• to loop through the elements in order, or

• to retrieve and manipulate the entire collection as a value,

then use a varray.

Page 74: Chapt 1 odbms

74

Database Design For ORDBMS

If you need

• to run efficient queries on a collection,

• handle arbitrary numbers of elements, or

• do mass insert/update/delete operations,

then use nested relations.

Page 75: Chapt 1 odbms

75

Nested Relations

� Motivation:

o Permit non-atomic domains (atomic ≡≡≡≡ indivisible)

o Example of non-atomic domain: set of integers,or set of

tuples

o Allows more intuitive modeling for applications with

complex data

� Intuitive definition:

o allow relations whenever we allow atomic (scalar) values

— relations within relations

o Retains mathematical foundation of relational model

o Violates first normal form.

Page 76: Chapt 1 odbms

76

Example of Nested Relations

� Example: library information system

� Each book has

o title,

o a set of authors,

o Publisher, and

o a set of keywords

� Non-1NF relation books

Page 77: Chapt 1 odbms

77

1NF Version of Nested Relation

1NF version of books

flat-books

Page 78: Chapt 1 odbms

78

4NF Decomposition of Nested Relation

� Remove awkwardness of flat-books by assuming that the following multivalued dependencies hold:

o title author

o title keyword

o title pub-name, pub-branch

� Decompose flat-doc into 4NF using the schemas:

o (title, author)

o (title, keyword)

o (title, pub-name, pub-branch)

Page 79: Chapt 1 odbms

79

4NF Decomposition of Nested Relation

Page 80: Chapt 1 odbms

80

Example: Nested Table Type

CREATE TYPE BeerType AS OBJECT (

name CHAR(20),

kind CHAR(10),

color CHAR(10)

);

/

CREATE TYPE BeerTableType AS

TABLE OF BeerType;

/

Page 81: Chapt 1 odbms

81

Example: Nested Table Type

� Use BeerTableType in a Manfs relation that

stores the set of beers by each manufacturer in

one tuple for that manufacturer.

CREATE TABLE Manfs (

name CHAR(30),

addr CHAR(50),

beers beerTableType

);

Page 82: Chapt 1 odbms

82

Storing Nested Relations

� Oracle doesn’t really store each nested table as a separate

relation --- it just makes it look that way.

� Rather, there is one relation R in which all the tuples of all

the nested tables for one attribute A are stored.

� Declare in CREATE TABLE by:

NESTED TABLE A STORE AS R

Page 83: Chapt 1 odbms

83

Example: Storing Nested Tables

CREATE TABLE Manfs (

name CHAR(30),

addr CHAR(50),

beers beerTableType

)

NESTED TABLE beers STORE AS BeerTable;

Page 84: Chapt 1 odbms

84

Another Example of Nested Relation

� Example:

dept = (dno, manager, employees, projects, locations)

employees = (ename, dependents)

projects = (pname, ploc)

locations = (dloc)

dependents = (dname, age)

Page 85: Chapt 1 odbms

85

Another Example of Nested Relation

Page 86: Chapt 1 odbms

86

ORDBMS Vs RDBMS

Comparison Between Object-Relational and Relational tables:

� Using ORDBMS:CREATE TABLE emp

(empid number,

employee person);

� Using RDBMS:

CREATE TABLE EMP

( empid number,...)

CREATE TABLE address

(addr_type varchar2(10),...)

CREATE TABLE phone

(ph_type varchar2(12),...)

Page 87: Chapt 1 odbms

87

� Represented using referenced attributes

implemented using OIDs

� Binary relations are represented using their

cardinalities:

(a) 1:1 relationships

(b) 1:M relationships

(c) M:N relationships

RELATIONSHIPS

Page 88: Chapt 1 odbms

88

1:1 RELATIONSHIPS

Bno: B3

Address: V.N. Road

Tel_no: 22040256

Staff: {OID4, OID 5,…}

Property:{OID2, OID 3,…}

Manager: OID 6

BRANCH: OID1

sno:SG5

Name: Aditi Govitrikar

Address: 77, Kambala Hill

Position: Manager

Tel_no: 2380 3336

Sex: F

DOB: 3-Jan-85

Bno: OID 1

MANAGER: OID6

Page 89: Chapt 1 odbms

89

1:M RELATIONSHIPS

Bno: B3

Address : V.N. Road

Tel_no: 22040256

Staff: {OID4, OID 5,…}

Property:{OID2, OID 3,…}

Manager: OID 6

BRANCH :OID1

pno:PG6

Address: 12,Cuff Parade

Type: Flat

Sno: OID4

Bno: OID 1

PROPERY_FOR RENT: OID2

pno:PG16

Address: 15,Cuff Parade

Type: Flat

Sno: OID4

Bno: OID 1

PROPERY_FOR RENT: OID3

Sno: SG14

Name: Amir Khan

Address 14, Hughes Road

Tel_no: 22214185

Bno: OID 1

Property:{OID2, OID 3,…}

SALES_STAFF: OID4

Page 90: Chapt 1 odbms

90

� Branch instance OID1 references a Manager

instance OID6

� If user deletes manager instance without

updating the branch instance accordingly,

referential integrity is lost

REFERENTIAL INTEGRITY

Techniques to handle referential integrity:

� Do not allow the user to explicit delete objects

� Allow user to delete/ modified objects when they are no longer required

Page 91: Chapt 1 odbms

91

Email: [email protected]

Community: http://tech.groups.yahoo.com/group/dbmsnotes/