Built-in Interfaces and Classes in the Object Model
11.3.3 Built-in Interfaces and Classes in the Object Model
Figure 11.5 shows the built-in interfaces and classes of the object model. All inter- faces, such as Collection , Date , and Time , inherit the basic Object interface. In the
object model, there is a distinction between collection objects, whose state contains multiple objects or literals, versus atomic (and structured) objects, whose state is an individual object or literal. Collection objects inherit the basic Collection interface
shown in Figure 11.5(c), which shows the operations for all collection objects. Given a collection object O, the O .cardinality () operation returns the number of ele- ments in the collection. The operation O .is_empty () returns true if the collection O is empty, and returns false otherwise. The operations O .insert_element (E) and O .remove_element (E) insert or remove an element E from the collection O. Finally, the operation O .contains_element (E) returns true if the collection O includes ele-
ment E, and returns false otherwise. The operation I = O .create_iterator () creates an
iterator object
I for the collection object O, which can iterate over each element in
the collection. The interface for iterator objects is also shown in Figure 11.5(c). The
I .reset () operation sets the iterator at the first element in a collection (for an unordered collection, this would be some arbitrary element), and I .next_position () sets the iterator to the next element. The I .get_element () retrieves the current ele- ment , which is the element at which the iterator is currently positioned.
The ODMG object model uses exceptions for reporting errors or particular condi- tions. For example, the ElementNotFound exception in the Collection interface would
30 The ODMG report also calls interface inheritance as type/subtype, is-a, and generalization/specializa- tion relationships, although, in the literature these terms have been used to describe inheritance of both
state and operations (see Chapter 8 and Section 11.1).
384 Chapter 11 Object and Object-Relational Databases
be raised by the O .remove_element (E) operation if E is not an element in the collec- tion O. The NoMoreElements exception in the iterator interface would be raised by the I .next_position () operation if the iterator is currently positioned at the last ele- ment in the collection, and hence no more elements exist for the iterator to point to.
Collection objects are further specialized into set , list , bag , array , and dictionary , which inherit the operations of the Collection interface. A set <T> type generator can be used to create objects such that the value of object O is a set whose elements are of type T. The Set interface includes the additional operation P = O .create_union (S) (see Figure 11.5(c)), which returns a new object P of type set <T> that is the union of the two sets O and S. Other operations similar to create_union (not shown in Figure 11.5(c)) are create_intersection (S) and create_difference (S). Operations for set com- parison include the O .is_subset_of (S) operation, which returns true if the set object O is a subset of some other set object S, and returns false otherwise. Similar opera- tions (not shown in Figure 11.5(c)) are is_proper_subset_of (S), is_superset_of (S), and is_proper_superset_of (S). The bag <T> type generator allows duplicate elements in the collection and also inherits the Collection interface. It has three operations—
create_union ( b ), create_intersection ( b ), and create_difference ( b )—that all return a new object of type bag <T>.
A list <T> object type inherits the Collection operations and can be used to create col- lections where the order of the elements is important. The value of each such object O is an ordered list whose elements are of type T. Hence, we can refer to the first, last, and ith element in the list. Also, when we add an element to the list, we must specify the position in the list where the element is inserted. Some of the list operations are shown in Figure 11.5(c). If O is an object of type list <T>, the operation O .insert_element_first (E) inserts the element E before the first element in the list O, so that E becomes the first element in the list. A similar operation (not shown) is O .insert_element_last (E). The operation O .insert_element_after (E, I) in Figure 11.5(c) inserts the element E after the ith element in the list O and will raise the exception InvalidIndex if no ith element exists in O. A similar operation (not shown) is O .insert_element_before (E, I). To remove elements from the list, the operations are E =O .remove_first_element (), E = O .remove_last_element (), and E = O .remove_element _at (I); these operations remove the indicated element from the list and return the element as the operation’s result. Other operations retrieve an element without removing it from the list. These are E = O .retrieve_first_element (), E = O .retrieve _last_element (), and E = O .retrieve_element_at (I). Also, two operations to manipulate lists are defined. They are P = O .concat (I), which creates a new list P that is the con- catenation of lists O and I (the elements in list O followed by those in list I), and O .append (I), which appends the elements of list I to the end of list O (without creat- ing a new list object).
The array <T> object type also inherits the Collection operations, and is similar to list. Specific operations for an array object O are O .replace_element_at (I, E), which replaces the array element at position I with element E; E = O .remove_element_at (I), which retrieves the ith element and replaces it with a NULL value; and
11.3 The ODMG Object Model and the Object Definition Language ODL 385
E=O .retrieve_element_at (I), which simply retrieves the ith element of the array. Any of these operations can raise the exception InvalidIndex if I is greater than the array’s
size. The operation O .resize (N) changes the number of array elements to N. The last type of collection objects are of type dictionary <K,V>. This allows the cre-
ation of a collection of association pairs <K,V>, where all K (key) values are unique. This allows for associative retrieval of a particular pair given its key value (similar to an index). If O is a collection object of type dictionary <K,V>, then O .bind (K,V) binds value V to the key K as an association <K,V> in the collection, whereas O .unbind (K)
removes the association with key K from O, and V = O .lookup (K) returns the value
V associated with key K in O. The latter two operations can raise the exception KeyNotFound . Finally, O .contains_key (K) returns true if key K exists in O, and returns false otherwise.
Figure 11.6 is a diagram that illustrates the inheritance hierarchy of the built-in con- structs of the object model. Operations are inherited from the supertype to the sub- type. The collection interfaces described above are not directly instantiable; that is, one cannot directly create objects based on these interfaces. Rather, the interfaces can be used to generate user-defined collection types—of type set , bag , list , array , or
dictionary —for a particular database application. If an attribute or class has a collec- tion type, say a set , then it will inherit the operations of the set interface. For exam- ple, in a UNIVERSITY database application, the user can specify a type for set < STUDENT >, whose state would be sets of STUDENT objects. The programmer can then use the operations for set <T> to manipulate an instance of type set < STUDENT >. Creating application classes is typically done by utilizing the object definition language ODL (see Section 11.3.6).
It is important to note that all objects in a particular collection must be of the same type. Hence, although the keyword any appears in the specifications of collection interfaces in Figure 11.5(c), this does not mean that objects of any type can be inter- mixed within the same collection. Rather, it means that any type can be used when specifying the type of elements for a particular collection (including other collec- tion types!).
Figure 11.6
Object
Inheritance hierarchy for the built-in interfaces of the object model.
set list
bag
array
dictionary
386 Chapter 11 Object and Object-Relational Databases
Parts
» Fundamentals_of_Database_Systems,_6th_Edition
» Characteristics of the Database Approach
» Advantages of Using the DBMS Approach
» A Brief History of Database Applications
» Schemas, Instances, and Database State
» The Three-Schema Architecture
» The Database System Environment
» Centralized and Client/Server Architectures for DBMSs
» Classification of Database Management Systems
» Domains, Attributes, Tuples, and Relations
» Key Constraints and Constraints on NULL Values
» Relational Databases and Relational Database Schemas
» Integrity, Referential Integrity, and Foreign Keys
» Update Operations, Transactions, and Dealing with Constraint Violations
» SQL Data Definition and Data Types
» Specifying Constraints in SQL
» The SELECT-FROM-WHERE Structure of Basic SQL Queries
» Ambiguous Attribute Names, Aliasing, Renaming, and Tuple Variables
» Substring Pattern Matching and Arithmetic Operators
» INSERT, DELETE, and UPDATE Statements in SQL
» Comparisons Involving NULL and Three-Valued Logic
» Nested Queries, Tuples, and Set/Multiset Comparisons
» The EXISTS and UNIQUE Functions in SQL
» Joined Tables in SQL and Outer Joins
» Grouping: The GROUP BY and HAVING Clauses
» Discussion and Summary of SQL Queries
» Specifying General Constraints as Assertions in SQL
» Introduction to Triggers in SQL
» Specification of Views in SQL
» View Implementation, View Update, and Inline Views
» Schema Change Statements in SQL
» Sequences of Operations and the RENAME Operation
» The UNION, INTERSECTION, and MINUS Operations
» The CARTESIAN PRODUCT (CROSS PRODUCT) Operation
» Variations of JOIN: The EQUIJOIN and NATURAL JOIN
» Additional Relational Operations
» Examples of Queries in Relational Algebra
» The Tuple Relational Calculus
» The Domain Relational Calculus
» Using High-Level Conceptual Data Models
» Entity Types, Entity Sets, Keys, and Value Sets
» Relationship Types, Relationship Sets, Roles, and Structural Constraints
» ER Diagrams, Naming Conventions, and Design Issues
» Example of Other Notation: UML Class Diagrams
» Relationship Types of Degree Higher than Two
» Subclasses, Superclasses, and Inheritance
» Constraints on Specialization and Generalization
» Specialization and Generalization Hierarchies
» Modeling of UNION Types Using Categories
» A Sample UNIVERSITY EER Schema, Design Choices, and Formal Definitions
» Data Abstraction, Knowledge Representation, and Ontology Concepts
» ER-to-Relational Mapping Algorithm
» Discussion and Summary of Mapping for ER Model Constructs
» Mapping EER Model Constructs
» The Role of Information Systems
» The Database Design and Implementation Process
» Use of UML Diagrams as an Aid to Database Design Specification 6
» Rational Rose: A UML-Based Design Tool
» Automated Database Design Tools
» Introduction to Object-Oriented Concepts and Features
» Object Identity, and Objects versus Literals
» Complex Type Structures for Objects and Literals
» Encapsulation of Operations and Persistence of Objects
» Type Hierarchies and Inheritance
» Other Object-Oriented Concepts
» Object-Relational Features: Object Database Extensions to SQL
» Overview of the Object Model of ODMG
» Built-in Interfaces and Classes in the Object Model
» Atomic (User-Defined) Objects
» Extents, Keys, and Factory Objects
» The Object Definition Language ODL
» Differences between Conceptual Design of ODB and RDB
» Mapping an EER Schema to an ODB Schema
» Query Results and Path Expressions
» Overview of the C++ Language Binding in the ODMG Standard
» Structured, Semistructured, and Unstructured Data
» XML Hierarchical (Tree) Data Model
» Well-Formed and Valid XML Documents and XML DTD
» XPath: Specifying Path Expressions in XML
» XQuery: Specifying Queries in XML
» Extracting XML Documents from
» Database Programming: Techniques
» Retrieving Single Tuples with Embedded SQL
» Retrieving Multiple Tuples with Embedded SQL Using Cursors
» Specifying Queries at Runtime Using Dynamic SQL
» SQLJ: Embedding SQL Commands in Java
» Retrieving Multiple Tuples in SQLJ Using Iterators
» Database Programming with SQL/CLI Using C
» JDBC: SQL Function Calls for Java Programming
» Database Stored Procedures and SQL/PSM
» PHP Variables, Data Types, and Programming Constructs
» Overview of PHP Database Programming
» Imparting Clear Semantics to Attributes in Relations
» Redundant Information in Tuples and Update Anomalies
» Normal Forms Based on Primary Keys
» General Definitions of Second and Third Normal Forms
» Multivalued Dependency and Fourth Normal Form
» Join Dependencies and Fifth Normal Form
» Inference Rules for Functional Dependencies
» Minimal Sets of Functional Dependencies
» Properties of Relational Decompositions
» Dependency-Preserving Decomposition
» Dependency-Preserving and Nonadditive (Lossless) Join Decomposition into 3NF Schemas
» Problems with NULL Values and Dangling Tuples
» Discussion of Normalization Algorithms and Alternative Relational Designs
» Further Discussion of Multivalued Dependencies and 4NF
» Other Dependencies and Normal Forms
» Memory Hierarchies and Storage Devices
» Hardware Description of Disk Devices
» Magnetic Tape Storage Devices
» Placing File Records on Disk
» Files of Unordered Records (Heap Files)
» Files of Ordered Records (Sorted Files)
» External Hashing for Disk Files
» Hashing Techniques That Allow Dynamic File Expansion
» Other Primary File Organizations
» Parallelizing Disk Access Using RAID Technology
» Types of Single-Level Ordered Indexes
» Some General Issues Concerning Indexing
» Algorithms for External Sorting
» Implementing the SELECT Operation
» Implementing the JOIN Operation
» Algorithms for PROJECT and Set
» Notation for Query Trees and Query Graphs
» Heuristic Optimization of Query Trees
» Catalog Information Used in Cost Functions
» Examples of Cost Functions for SELECT
» Examples of Cost Functions for JOIN
» Example to Illustrate Cost-Based Query Optimization
» Factors That Influence Physical Database Design
» Physical Database Design Decisions
» An Overview of Database Tuning in Relational Systems
» Transactions, Database Items, Read and Write Operations, and DBMS Buffers
» Why Concurrency Control Is Needed
» Transaction and System Concepts
» Desirable Properties of Transactions
» Serial, Nonserial, and Conflict-Serializable Schedules
» Testing for Conflict Serializability of a Schedule
» How Serializability Is Used for Concurrency Control
» View Equivalence and View Serializability
» Types of Locks and System Lock Tables
» Guaranteeing Serializability by Two-Phase Locking
» Dealing with Deadlock and Starvation
» Concurrency Control Based on Timestamp Ordering
» Multiversion Concurrency Control Techniques
» Validation (Optimistic) Concurrency
» Granularity of Data Items and Multiple Granularity Locking
» Using Locks for Concurrency Control in Indexes
» Other Concurrency Control Issues
» Recovery Outline and Categorization of Recovery Algorithms
» Caching (Buffering) of Disk Blocks
» Write-Ahead Logging, Steal/No-Steal, and Force/No-Force
» Transaction Rollback and Cascading Rollback
» NO-UNDO/REDO Recovery Based on Deferred Update
» Recovery Techniques Based on Immediate Update
» The ARIES Recovery Algorithm
» Recovery in Multidatabase Systems
» Introduction to Database Security Issues 1
» Discretionary Access Control Based on Granting and Revoking Privileges
» Mandatory Access Control and Role-Based Access Control for Multilevel Security
» Introduction to Statistical Database Security
» Introduction to Flow Control
» Encryption and Public Key Infrastructures
» Challenges of Database Security
» Distributed Database Concepts 1
» Types of Distributed Database Systems
» Distributed Database Architectures
» Data Replication and Allocation
» Example of Fragmentation, Allocation, and Replication
» Query Processing and Optimization in Distributed Databases
» Overview of Transaction Management in Distributed Databases
» Overview of Concurrency Control and Recovery in Distributed Databases
» Current Trends in Distributed Databases
» Distributed Databases in Oracle 13
» Generalized Model for Active Databases and Oracle Triggers
» Design and Implementation Issues for Active Databases
» Examples of Statement-Level Active Rules
» Time Representation, Calendars, and Time Dimensions
» Incorporating Time in Relational Databases Using Tuple Versioning
» Incorporating Time in Object-Oriented Databases Using Attribute Versioning
» Temporal Querying Constructs and the TSQL2 Language
» Spatial Database Concepts 24
» Multimedia Database Concepts
» Clausal Form and Horn Clauses
» Datalog Programs and Their Safety
» Evaluation of Nonrecursive Datalog Queries
» Introduction to Information Retrieval
» Types of Queries in IR Systems
» Evaluation Measures of Search Relevance
» Web Analysis and Its Relationship to Information Retrieval
» Analyzing the Link Structure of Web Pages
» Approaches to Web Content Analysis
» Trends in Information Retrieval
» Data Mining as a Part of the Knowledge
» Goals of Data Mining and Knowledge Discovery
» Types of Knowledge Discovered during Data Mining
» Market-Basket Model, Support, and Confidence
» Frequent-Pattern (FP) Tree and FP-Growth Algorithm
» Other Types of Association Rules
» Approaches to Other Data Mining Problems
» Commercial Data Mining Tools
» Data Modeling for Data Warehouses
» Difficulties of Implementing Data Warehouses
» Grouping, Aggregation, and Database Modification in QBE
Show more