Lect3 Object Based Dbs
Lect3 Object Based Dbs
Lecture 3
Subject: ADBMS
Prepared by: Nirali Nanavati
Type Inheritance
Create type PERSON_TY as object
(name varchar(20),
address varchar(25)) NOT FINAL;
Create type STUDENT_TY under PERSON_TY
(degree varchar(20),
dept varchar(20));
Create type TEACHER_TY under PERSON_TY
(salary number,
dept varchar(20));
Create table student (st student_ty);
Type Inheritance Contd…
>
Create type DEPT_TY as object
(name varchar(20),
Head ref Person scope is people);
>
Create table departments of DEPT_TY;
Types of Identifiers:
System Generated
Identifiers: System generated
Oracle assigns a unique system-generated
identifier of length 16 bytes as the OID. The OID
column of an object table is a hidden column.
Create type Person(name varchar(20), address
varchar(25));
Create table people of Person ref is person_id system
generated
Insert into departments values(‘CS’,null);
Update departments set head = (select p.person_id
from people as p where name = ‘john’) where name =
‘CS’;
User Generated Identifier
Identifier: User generated
Create type Person(name varchar(20),
address varchar(25),
ref using varchar(20));
Create table people of Person ref is
person_id user generated
Insert into people
values(‘0123432’,’John’,’xyzstreet’);
Insert into departments values (‘CS’,’
0123432’,);
Primary Key Identifier
E.g.
>
Create type DEPT_TY as object
(name varchar(20),
Head ref Person );
>
Update departments set head = (select REF(P) from
people P where name = ‘john’) where name = ‘CS’;
Select d1.Head.name from departments d1 where where
name = ‘CS’ ;
Invalid references