Chapter 1 - User-defined types and typed tables Flashcards
What are the basic OO features that must be supported in an ORDBMS?
Object identity classes or types inheritance encapsulation overriding + late binding complex objects completeness (for method implementation) extensibility
What are the key features and benefits of USER-defined types?
- extend DBS functionality + flexibility
- strong typing
- information hiding (no impl. details)
Benefits: - Reuse: overloading + inheritance
- change: isolation + low impact
In which sense do UDTs support strong typing?
- type checking can be enhanced with semantics -> not based just on primitive types.
Shoe size different of room area -> but both integers
How does the cast mechanism of distinct types work?
DT: Renamed type with different semantics (share interval representation)
Cast: allows comparison/ordering based os source type/ create DT values from literals, etc..
* cast functions automatically created (CAST (SOURCE AS DISCTINCT) WITH F)
How can we ensure the compatibility between source and distinct type without explicit casting?
Relaxed strong typing for assignments USING CAST FUNCTIONS:
CAST (SRC AS DST) WITH F AS ASSIGNMENT
* comparison requires explicit casts *
How to distinct types compare to domains in the relational model?
in rel. model -> domain = type
in SQL -> domain = type + constraint + default + collation (CREATE DOMAIN)
What are the intensional and extensional aspects of Structured Types?
- Intention = description = type/class -> UDTs
- > concerns interface and substitution inheritance (operations) - Extension = actual things = set of objects -> typed tables
- > Concerns instantiated objects and inclusion inheritance (structure/state)
what are the different ways in which objects (i.e. instances of structured types) may exist?
Object as values: Values of a ST (columns, attr. of other ST, domains, variables, expressions)
-> no identity, no state modifications
Objects as rows: in typed tables (oid column = identity, update statement = modification
What are two possible instantiation mechanism of structured types
- System-supplied constructor function type-name ->returns obj with default values
- NEW operator -> calls user-defined constructor
How can we access the attributes of an object in the query language?
- dot notation for objects as value (a.b.c.d)
- SELECT or UPDATE of columns for typed tables
- ”->” for referenced stored in tables = DEREF followed by dot
How are subtyping and inheritance realized with structured UDTs?
Just like OO languages
CREATE TYPE … UNDER … -> inherits attributes and methods
**substitutability implied
What are the equivalent of abstract and final classes in an ORDBMS?
- Abstract= NOT INSTATIABLE (no system-supplied constructor)
* final = not supported -> all DTs are final, all STs are not final.
What is the meaning of subtype substitutability and how is it realized in an ORDBMBS?
B < A -> B supports at least the operations defined in A and B can be used everywhere an A is expected.
**obs: invariant return , argument and attribute types
How can we test for the type of an object in SQL?
- Determination of dynamic type. IS OF (boolean = instance of)
- subtypes out: ONLY(type) (type == getClass( ))
What are typed tables and what characteristics do they provide to objects?
tables whose columns are attributes of an ST and rows are objects with an identity
-> provide identity + persistence + update capability