Chapter 2 - OR Views and Composite Types Flashcards
What is the functionality and the advantages of views?
logical data independence , app-specific representation of DB, authorization (DB way of achieving abstraction)
What was added to SQL in order to support Object Views
*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
What are the rules for Object IDs in Object Views?
- 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 does the view type relate to the type of the base tables?
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 are the OR view restrictions handled in DB2?
- Only not needed n FROM
- View hierarchies over many tables
- Static disjointness checking for subviews
Is it possible to create a view hierarchy over a single base table? What are the implications?
Yes -> Exploit OR over legacy tables
- > Derive selfref from pk
- > fk: scoped ref
What are the supported composite types in SQL and how can they simulate other not supported collection types?
ROW (nullable types)-> —->(UNION -> Heterogeneous elems
ARRAY (not support) —–>(LIST) -> Homogeneous elems, ordered
MULTISET(elim. dup.) —>(SET) -> Homogeneous elems, unordered
Give an overview of ROW types in SQL.
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 do row types compare to structured types?
ROW types don’t have a name
-> compatibility by structure
What is the difference between row types and collections
Coll: all elements are of the same type (ARRAY+MULTISET)
How can collections be constructed and accessed?
Constructions: by enumeration (from expression). by query (from table data)
Access: UNNEST table function (index access for arrays)
(Also possible: comparison, assignment, cast)
Give an overview over arrays and their use in SQL
- > Characteristics: maximal instead of fixed length, any type
- > Operations: Access by index, cardinality, comparison, construction…
- > DDL: Array [n], dml: ARRAY[v1, v2, …]/Array(query)
Give an overview over multisets, their construction and basic operations.
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
What is the goal of the UNNEST operator?
Tranform collections into tables (access, iteration, query)
What are the different predicates supported for multiset comparison?
Comparison (equal, unequal)
DISTINCT, MEMBER, SUBMULTISET, IS A SET