ORDBMS Flashcards
Set type
setof(varchar(20));
arrays
varchar(20) array[10]
Large object type
clob - character large object
blob - binary large object
creating types
create type [name] as (
[attributes]
)
the type ‘name’ ca now be the attribute for another type or table
Create table over type objects
Create table [table name] of [obj name];
define composite attribute in line
create type Book as ( ... row publisher ( name varchar(20), year int ), .... );
add methods to table/type
create type Book as ( ... method read(pages integer) )
create method body separately
insert complex values into relation
insert into books
values
(‘Compilers’ array[‘smith’, ‘jones’], Publisher(‘McGraw Hill’, ‘New york’), set(‘a’, ‘b’))
inheritance of types
create type [name] under [super class type]
(
[only need to define new attributes here]
)
multiple inheritance
create type TA under
under
Student with (attribute as a) Teacher with (attribute as b)
there is a collision of a similarly named attribute so we have to rename them to avoid the collision
Reference declaration
an attribute of our table can be a reference (or essentially a pointer) to an object in another table
- this prevents having to create duplicate objects
- it also prevents the user from create long cumbersome insert statements if the object is large and has say 100s of attributes
Reference declaration syntax
create type Department ( name varchar(20), head ref(Person) scope people )
head = name of attribute
ref(Person) = head is a reference to a Person type
scope people = the Person to which head will reference is from the people table
insert into table with reference attribute
insert into departments values (‘CS’, null)
update departments
set head = (select ref(p) from people as p where name = ‘John)
where name = ‘CS’;
self-referential attribute
to specify how objects are to be referenced
ex)
create table people of Person ref is oid system generated
oid = object identifier