Chapter 2 - OR Views and Composite Types Flashcards

1
Q

What is the functionality and the advantages of views?

A

logical data independence , app-specific representation of DB, authorization (DB way of achieving abstraction)

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

What was added to SQL in order to support Object Views

A

*Typed views + hirearchies (referenceable views)
* Mapping of table refs to view refs
CREATE VIEW … AS -> ONE typed table or view with same ST of view

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

What are the rules for Object IDs in Object Views?

A
  • System generated not allowed, oid and refs must be cast to compatible ref types
  • 1 view hierarchy = 1 table hierarchy (1:1)
    FROM clause of views def. can only refer to one single table (if typed , must have ONLY)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does the view type relate to the type of the base tables?

A

View type is independent, but OID must follow the rules
* Subviews: Type must be direct subtype of superview type
Base table must be proper subtable of superview base table

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

How are the OR view restrictions handled in DB2?

A
  • Only not needed n FROM
  • View hierarchies over many tables
  • Static disjointness checking for subviews
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Is it possible to create a view hierarchy over a single base table? What are the implications?

A

Yes -> Exploit OR over legacy tables

  • > Derive selfref from pk
  • > fk: scoped ref
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the supported composite types in SQL and how can they simulate other not supported collection types?

A

ROW (nullable types)-> —->(UNION -> Heterogeneous elems
ARRAY (not support) —–>(LIST) -> Homogeneous elems, ordered
MULTISET(elim. dup.) —>(SET) -> Homogeneous elems, unordered

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

Give an overview of ROW types in SQL.

A
DDL type ROW (att-name, att type, ...)
DML constructor ROW (v1, v2, ...)
field access: col-name.att-name
comparison: same numeber of fields, pairwise compatible field types
     -> ordering consider field order
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do row types compare to structured types?

A

ROW types don’t have a name

-> compatibility by structure

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

What is the difference between row types and collections

A

Coll: all elements are of the same type (ARRAY+MULTISET)

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

How can collections be constructed and accessed?

A

Constructions: by enumeration (from expression). by query (from table data)
Access: UNNEST table function (index access for arrays)
(Also possible: comparison, assignment, cast)

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

Give an overview over arrays and their use in SQL

A
  • > Characteristics: maximal instead of fixed length, any type
  • > Operations: Access by index, cardinality, comparison, construction…
  • > DDL: Array [n], dml: ARRAY[v1, v2, …]/Array(query)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Give an overview over multisets, their construction and basic operations.

A

Characteristics: Varying-length, unordered
DDL: Att-name, att-type multiset, DML: MULTISET[v1, v2, …]/MULTISET(QUERY)
Operations: Element (m), SET (m), CARDINALITY(m), UNION, EXCEPT, INTERSECT

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

What is the goal of the UNNEST operator?

A

Tranform collections into tables (access, iteration, query)

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

What are the different predicates supported for multiset comparison?

A

Comparison (equal, unequal)

DISTINCT, MEMBER, SUBMULTISET, IS A SET

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

Give an overview over multiset aggregates.

A

COLLECT: Values in a group transformed in a MULTISET
FUSION: union of multiset in group (UNION ALL)
INTERSECT: Intersect of multisets in group