5/11/2022 Chapter 1: Concepts for Object-Oriented Databases The following object-oriented concepts are typically associated with an (Object Database)ODB: 1.1. Overview of Object-Oriented Concepts 1.2. Object Identity, Object Structure, and Type Constructors 1.3. Encapsulation of Operations, Methods, and Persistence 1.4. Type Hierarchies and Inheritance What is object? Object consists of entity and attributes which can describe the state of realworld object and action associated with the object.eg car,boat class method and persistence encapsulation encapsulation complex objects extensibility object identity polymorphism object structure class hierarchies and inheritance object constructor overriding, overloading Cont…. Through object-based database system we are really incorporating the features of object-oriented programming like objects, class, and inheritance. Object-based database system Simply object-oriented database system should satisfy two criteria: In object-oriented database, information is represented (that is stored and a. It should be DBMS manipulated) is all in the form of object. Object oriented database are the same as object-oriented programming languages. b. It should be object-oriented system Note OODB implements OO concepts such as object identity, polymorphism, encapsulation, and inheritance to provides access to persistent objects using any object-oriented programming languages. 1 5/11/2022 Some important characteristics of an object are: 1. Object name: -the name is used to refer different object in the program 2. Object identifier: - this the system generated identifier which is assigned, RDBMS and OODBMS are database management systems. RDBMS uses tables to represent data and their relationships whereas OODBMS represents data in form of objects similar to Object Oriented Programming. Following are the important differences between RDBMS and OODBMS. Sr. when a new object is created. 4. Transient object: - in OOPL, object which are present only at the time of 1 execution are called transient object. 5. Persistent object: - an object which exists even after the program is completely executed or terminated, is called persistent object. Object database Data An entity refers to collection of similar An class refers to group of objects having items having same definition. common relationships, behaviors and RDBMS handles only data. Handling Definition RDBMS stands for Relational DataBase OODBMS stands for Object Oriented Management System. DataBase Management System. Data is stored as entities defined in tabular Data is stored as objects. Managemen format. Data properties. 5 OODBMS t 3 Term RDBMS Data 2 can store objects in secondary memory. 4 Key No. OODBMS handles both data and functions operating on that data. RDBMS handles simple data. OODBMS handles large and complex data. Complexity Features of OODBMS In OODBMS, every entity is considered as object and represented in a table. Similar object classified to classes and subclasses and relationship between two object is maintained using concept of inverse references. 1. Complexity: - OODBMS has the ability to represent the complex internal structure (of object) with multilevel complexity. 2. Inheritance: - creating new object from existing objects in such a way that new object inherits all characteristic of an existing objects. Objective To keep data independent from application To implement data encapsulation. program. 6 3. Encapsulation: - it is a data hiding concepts in OOPL which binds the data and function togethers which can manipulate data and not visible to the outside world. 4. User define abstract data types (ADT): - ADT allow new data types with structure suited to particular Key 7 A primary key identifies in object in a table Object Id, OID represents an object uniquely. uniquely in group of objects. application to be defined. 5. Persistency: - OODBMS allow to create persistent object (object remain in memory even after execution). This feature can solve the problem of recovery and concurrency. 6. Object Identity: - OID(Object identify digitally) are used to identify objects. 2 5/11/2022 Properties of OID Object Identity An object identity is an internal identifier of object that could not be changed. An object identity (iod) remains constant during object 1. Uniqueness: OID cannot be the same to every object in the system and its generated automatically by the system. lifetime. Every object has unique identity. In object-oriented system, 2. Invariant: OID cannot be changed throughout its entire lifetime. when object is created IOD is assigned to it. 3. Invisible: OID is not visible to user. In RDBMS OID is value based and primary key is used to provide Object Structure uniqueness of each table in relation. Primary key is chosen from the A class object contains information about the state described by attributes attributes of the relation which makes object independent on the object and the behavior allowed by methods. An attribute and a method that are for states. the instances of the class are called instance attribute and an instance method. For Example Student Instance Attribute Stid Fname LName Type Constructors Object Instance 001 Bekel Ayele Type Constructors Also called type generator, a type constructor is particular kind of method in a class. It is called to create an object of this class and initialize its attributes. The constructor has the same name as the class. Unlike to ordinary methods, the constructor has not explicit return type. The three most basic constructors are atom, tuple, and set. The atom constructor is used to represent all basic atomic values, such as integers, real numbers, character strings, Booleans, and any other basic data types that the system supports directly. 3 5/11/2022 Type constructor Used Atom the basic built-in data types of the object model Like integers, strings, floating point numbers, enumerated types, Booleans, and so on Struct (tuple) create standard structured types, such as the tuples (record types) in the basic relational model. Set(T) Create objects or literals that are a set of distinct elements all of the same type. Class A class essentially defines the type of the object where each object is viewed as an instance of the class. For example, Person is a class and Kebede is an instance or an object of this class. Eg: Class Definition : defining the class BRANCH BRANCH Attributes brabchNo street city postcode Methods Print() getPostCode() numberofStaff() Complex Objects Complex objects or nested relations are objects which are designed by combining simple objects. These objects used to be created by constructors. Encapsulation Encapsulation is the ability to group data and mechanisms into a single object to provide access protection. Through this process, pieces of information and details of how an object works are hidden, resulting in data and function security. Classes interact with each other through methods without the need to know how particular methods work. An airplane and a car are examples of complex objects because they can be viewed as a higher-level object that is constructed from lower-level objects, such as engine and body (for both), the airplane wings and tail. Each of these objects can be complex objects that are constructed from other simple or complex objects. As an example, a car has descriptive characteristics and actions. You can change the color of a car, yet the model or make are examples of properties that cannot change. A class encapsulates all the car information into one entity, where some elements are modifiable while some are not. 4 5/11/2022 Methods Persistence Storing permanently the values of properties of an object is called In object-oriented approach, the behavior of an object is described by a set of object persistence. In other words, persistence refers to the ability for operations that are called methods. A method has a signature that describes the name of objects to remain after stopping the process that created them. The properties of persistent object are created and stored in main memory. Object-oriented database systems are based on the concept of persistent objects. the method and the names and types of the method parameters. A method is a particular implementation of a method signature. They are defined in object class and allow to relate different others objects and manipulating them. Example: When an employee is fired, we need to delete the employee information from the employee file, delete the employee from the employee-project file, and insert the employee information into a history file, etc. One method called “Fire-employee” can be defined that incorporates this sequence of Class Hierarchy Type Hierarchies & Inheritance In object-oriented approach, there is the possible to define class hierarchies and to express the inheritance of state and behavior. Example:-Manger is a Employee A class hierarchy provides an inheritance mechanism which allows a class to inherit properties (attributes and methods) from its super classes. Example Person In single inheritance systems, a class can have at most one direct superclass and therefore can only inherit from that superclass. The class hierarchy forms a tree. Employee Student Teacher The ODB have advantages to completely support class hierarchies and inheritance. In multiple inheritance systems, a class can have more than one direct superclass. The Multiple class hierarchy is a lattice. Note: In multiple inheritance systems, a class may inherit properties and methods from different super classes and therefore may have inheritance conflicts. 5 5/11/2022 Reading Assignment: Some problems and proposed solutions in Object-Oriented Data Models. General disagreement on OO concepts Issues in Use of Methods Standard Declarative Query Language Access Methods and Data Type Extensibility Support for complex objects Object Identity Should attributes be directly accessible? Every thing as Objects? Formal Foundation for OO paradigm Conflicts in Class Hierarchy and Multiple Inheritance and etc. 6