ORDBMS Flashcards

1
Q

Set type

A

setof(varchar(20));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

arrays

A

varchar(20) array[10]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Large object type

A

clob - character large object

blob - binary large object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

creating types

A

create type [name] as (
[attributes]
)

the type ‘name’ ca now be the attribute for another type or table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Create table over type objects

A

Create table [table name] of [obj name];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

define composite attribute in line

A
create type Book as (
      ...
      row publisher (
          name varchar(20),
           year int
      ),
      ....
);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

add methods to table/type

A
create type Book as (
      ...
      method read(pages 
       integer)
)

create method body separately

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how to write a method

A

create method method name for [type or table]

begin
[do stuff]
end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

insert complex values into relation

A

insert into books
values
(‘Compilers’ array[‘smith’, ‘jones’], Publisher(‘McGraw Hill’, ‘New york’), set(‘a’, ‘b’))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

inheritance of types

A

create type [name] under [super class type]
(
[only need to define new attributes here]
)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

multiple inheritance

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Reference declaration

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Reference declaration syntax

A
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

insert into table with reference attribute

A

insert into departments values (‘CS’, null)

update departments
set head = (select ref(p) from people as p where name = ‘John)
where name = ‘CS’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

self-referential attribute

A

to specify how objects are to be referenced

ex)
create table people of Person ref is oid system generated

oid = object identifier

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

User created object identifiers

A

create type Person as (

ref using varchar(20)
)

create table people of Person
ref is oid user generated

insert into departments values
(‘CS’, ‘023956203’)

17
Q

Derived object identifier

A

we can also have object identifiers use an existing PK as the identifier.

ex) create type Person(name varchar(20) primary key,address varchar(20))ref from(name)create table people of Person ref is oid derived

nsert into departments values(CS’,John’)

18
Q

path expressions

A

select head –> name, head –> address

head - a reference to a person.

name, address - The attribute on the other side of the arrow is the attribute from the referenced person that we want to retrieve.

19
Q

Why use path expressions

A

We can get attributes from a reference object without needing to use a join.

easier to express queries

20
Q

Querying structured types

A

use dot operator to get attribute of a composite type

select title, publisher.name
From …

21
Q

Querying data with collection attributes - Sets - in the where clause

A

select title
from books
where ‘database’ in( unnest([set name]))

the word ‘unnest’ puts the set in a form dbms can search through

22
Q

Querying data from arrays

A

select author-array[1], author-array[2]
from books
where title = ‘blah’

simply access elements by use of indices

23
Q

Nesting

A

can retrieve an unnested relation as a nested relation (one with multi valued attributes)

select title, set(author)
from flat-books

use the word ‘set’

24
Q

SQL 1999 functions

A
create function [function name]({arguments})
returns [return type]
begin
[declarations go here]
[rest of code goes here]
end
25
Q

SQL procedures

A

create procedure [name] ({[in/out] argument})
begin
[code here]
end