Advanced Database ยท Unit 2 ยท 10 hrs
Object and Object Relational Databases
Exam-focused notes for Object and Object Relational Databases (Advanced Database, CSC475): what the TU syllabus asks and how it has actually been tested, with 6 solved past questions from this unit.
Object and Object Relational Databases in short
This unit covers object databases and the object-relational model: how object-oriented ideas were incorporated into database systems and into SQL itself, the ODMG standard and its object definition and query languages, and how object-relational engines handle nested and semi-structured data today.
What this unit covers
- Object Database Concepts
- Object Database Extensions to SQL
- The ODMG Object Model and the Object Definition Language ODL
- Object Database Conceptual Design
- Object Query Language OQL
- Language Binding in the ODMG Standard
Object Database Concepts
2081 ยท 10 marks
Explain different object database concepts in brief. What are type constructors?[10]
Show solved answerHide answer
Object Database Concepts and Type Constructors
Part 1: Object Database Concepts
Object databases (also called Object-Oriented Databases) combine the advantages of object-oriented technologies with traditional database systems. The main goal is to improve the modeling of real-world concepts in the database.
Key Object Database Concepts
1. Object Identity
Every object in an object database has a unique, system-generated identifier called an Object Identifier (OID). Unlike relational databases where identity is based on key values, OIDs are independent of the object's attribute values and remain stable even if the data changes.
2. Complex Objects
Object databases support complex (composite) objects that can contain other objects as attributes. This allows modeling of real-world entities more naturally. For example, an Employee object can contain an Address object as an attribute.
3. Encapsulation
Object databases support encapsulation, which means that both data (attributes) and behavior (methods/operations) are bundled together within an object. External users interact with objects only through defined interfaces. This is provided through the mechanism of user-defined types.
4. Classes and Type Hierarchy
Objects are grouped into classes based on shared attributes and methods. Classes can be organized into a type hierarchy using inheritance, allowing subclasses to inherit properties and methods from superclasses. In SQL-based object databases, this is supported using the keyword UNDER.
5. Inheritance
Inheritance allows a new class (subclass) to derive properties and behaviors from an existing class (superclass). This promotes reusability and reduces redundancy. For example:
Person (superclass)
โโโ Employee UNDER Person (subclass)
โโโ Student UNDER Person (subclass)
6. Object References
Objects can reference other objects using reference types. This replaces the concept of foreign keys in relational databases and allows direct navigation between related objects.
7. Polymorphism
The same operation can behave differently on different types of objects. This allows flexible and extensible database design.
8. Object Query Language (OQL)
Object databases are queried using OQL (Object Query Language), which is an SQL-like declarative language. It provides:
- High-level primitives for object sets and structures
- Support for object identity and complex objects
- Syntax similar to SQL but extended with object-oriented features
9. Persistence
Objects in an object database are persistent, meaning they continue to exist beyond the execution of the program that created them, unlike transient objects in memory.
Part 2: Type Constructors
Type constructors are mechanisms used in object-relational and object databases to define complex or structured data types beyond the basic primitive types (integer, string, etc.).
Definition
A type constructor is a mechanism that allows the creation of new, complex data types by combining or structuring existing types.
Two Main Categories of Type Constructors
1. Row Type (Tuple / Struct) Constructor
- Used to create a structured type that groups multiple attributes together, similar to a record or struct.
- Allows a single attribute to hold multiple sub-attributes.
- Example:
CREATE TYPE Address AS (
street VARCHAR(50),
city VARCHAR(30),
zipcode CHAR(10)
) NOT FINAL;
Here, Address is a row type that groups street, city, and zipcode into a single structured type.
2. Collection Type Constructor
Collection types allow an attribute to hold multiple values of the same type. There are three main collection type constructors:
| Constructor | Description |
|---|---|
| Set | An unordered collection of unique elements (no duplicates) |
| List | An ordered collection of elements (duplicates allowed) |
| Bag (Multiset) | An unordered collection where duplicates are allowed |
Example:
-- A SET of phone numbers for an employee
CREATE TYPE PhoneSet AS SET(VARCHAR(15));
-- Using it in a table
CREATE TABLE Employee (
emp_id INT,
name VARCHAR(50),
phones PhoneSet
);
Additional Mechanisms Related to Type Constructors
| Feature | Description |
|---|---|
| Reference Type | Specifies object identifiers to allow one object to reference another |
| Encapsulation | Operations are encapsulated within user-defined types |
| Inheritance (UNDER) | New types can be derived from existing types using the UNDER keyword |
Summary Table
| Concept | Description |
|---|---|
| Object Identity | Unique OID for every object |
| Encapsulation | Data + behavior bundled together |
| Inheritance | Subclass inherits from superclass using UNDER |
| Complex Objects | Objects containing other objects |
| OQL | SQL-like language for querying objects |
| Row Type Constructor | Groups multiple attributes into one structured type |
| Collection Type Constructor | Set, List, Bag for multi-valued attributes |
| Reference Type | Mechanism for object-to-object references |
Conclusion
Object database concepts extend traditional relational databases by incorporating object-oriented principles such as identity, encapsulation, inheritance, and complex types. Type constructors, specifically row type (tuple/struct) and collection type (set, list, bag) constructors, are fundamental tools that enable the definition of rich, complex data structures needed to model real-world entities accurately.
2079 ยท 10 marks
What are different concepts and features of object oriented databases? What is object relational model?[10]
The ODMG Object Model and the Object Definition Language ODL
2080 ยท 5 marks
What is ODMG object model? What is object definition language? [5]
Show solved answerHide answer
ODMG Object Model and Object Definition Language
ODMG Object Model
ODMG stands for Object Data Management Group. It is a standard data model upon which the Object Definition Language (ODL) and Object Query Language (OQL) are based. It is meant to provide a standard data model for object databases.
Main Parts of ODMG
The ODMG standard is made up of the following parts:
| Part | Description |
|---|---|
| Object Model | Core data model for object databases |
| Object Definition Language (ODL) | Language to define object schemas |
| Object Query Language (OQL) | SQL-like language to query objects |
| Language Bindings | Bindings to OOP languages (C++, Java, etc.) |
Key Concepts in the ODMG Object Model
The ODMG object model differentiates between Objects and Literals:
Objects:
- Have both an Object Identifier (OID) and a state (current data)
- Values can be modified
- May be transient or persistent
Literals:
- Have a value (state) but no Object Identifier
- Have a constant value
- May be atomic, structure, or collection
Advantages of ODMG-based Object Databases
- Speed: Data can be accessed faster because an object can be retrieved directly
- Improved performance: Best suited for object-oriented programming
- Extensibility: Any kind of data structure can be used to hold data
- Avoids impedance mismatch between the database and the programming language
Object Definition Language (ODL)
Object Definition Language (ODL) is a language used in the context of object-oriented databases to define the structure and characteristics of objects within a database. In ODL, data is organized and stored as objects rather than in traditional relational tables.
Common Elements of ODL
| Element | Description |
|---|---|
| Classes | Define the blueprint/template for objects |
| Attributes | Properties or data fields of a class |
| Relationships | Associations between classes/objects |
| Inheritance | Allows a class to derive properties from a parent class |
| Methods | Behaviors or operations defined on objects |
| Constraints | Rules that enforce data integrity |
Summary
ODL provides a powerful and expressive language for defining object-oriented database schemas. It enables the modeling and organization of data in a way that closely aligns with object-oriented programming concepts, making it natural to use alongside languages like C++ and Java through their respective ODMG language bindings.
2079 ยท 5 marks
Define ODMG Object model? What is Object Query Language(OQL)? [5]
Object Database Extensions to SQL
2080 ยท 10 marks
Compare object oriented database with object relational database. What are different object database features that have been included in SQL?[10]
Make Unit 2 stick
Practice CSC475 with flashcards & quizzes