You are on page 1of 5

Object Oriented Dbms - Presentation Transcript

1. Object Oriented DBMS


o Database that stores data elements as objects. Uses object-oriented conc
epts.
o The term object oriented is abbreviated by OO or O-O
2. Object
o The entity that contains both attributes as well as the actions associat
ed with it
o The object has two components
o State
o behavior
o Attributes can be classified into simple and complex
o An object is described by following characteristics
o Identifier: a system-wide unique id for an object
o Name: an object may also have a unique name in DB (optional)
o Lifetime: determines if the object is persistent or transient
3.
o A simple attribute can be an integer, string, real and so on. Which take
s on specific values.
o A complex attribute can contain collection and/or references.
o A reference attribute represent a relationship between objects and conta
in a value or values.
4. Example
o Object attributes for branch instance
o Attribute Values
o BranchNo B003 simple
o Street 163 main st
o City Islamabad
o Postcode 22010
o SalesStaff Ali khan; Atif khan c/r
o Manager Amjad khan
5.
o BranchNo is example of simple attribute with value B003
o The attribute Salesstaff is collection of staff objects.
o Salestaff is example of reference attribute.
o The reference attribute is similar to foreign key in the relational DBMS
.
6. Features of OO 1. Object Identity
o An OO database provides a unique identity to each independent object sto
red in the database.
o This unique identity is implemented via a unique system generated object
identifier OID.
o The value of OID is not visible to the user but it is used internally by
the system to identify each object uniquely.
7.
o The main property required of an OID is that it be immutable that is the
OID value of a particular object should not change.
o It is also desirable that each OID be used only once, that is even the o
bject is removed from the database its OID should not be assigned to another obj
ect.
o OID cannot be modified by the user.
8. 2.Abstraction
o Abstraction is the process of identifying the essential aspects of an en
tity and ignoring the unimportant properties.
o There are two fundamental aspects of abstraction
o Encapsulation
o Information hiding
9. Encapsulation
o The concept of encapsulation means that an object contains both data str
ucture and the set of operations that can be used to manipulate it.
o Example
o Define class Employee:
o type tuple( name: string;
o birthdate: date;
o salary: float; );
o operations create-emp: employee;
o destroy-emp: boolean;
o End employee;
10. Information hiding
o The concept of information hiding is that we separate the external aspec
ts of an object from its internal details.
o The internal details are hidden from the user.
o So that the internal details can be changed without affecting the applic
ation that use it, that is the external details remain the same.
o User only knows available methods and how to call them.
11. 3.Methods and Messages
o In object technology functions are usually called methods.
o Methods define the behavior of the object.
o They can be used to change the object’s state by modifying its attribute v
alues
o A method consist of a name and a body that perform the action associated
with method name
12. Example
o method void updatesalary(float increment)
o {
o Salary=salary+increment
o }
o It is a method use to update a member of staff’s salary.
o Messages
o Messages are the means by which objects
13.
o communicate. A message is simply a request from one object to another as
king the object to execute one of its methods.
o Example
o Staffobject.updatesalary(100)
o 4.Classes
o Classes are used to define a set of similar objects.
o Objects having same attributes and respond to same messages can be group
ed together to form a class.
14. Example
o class
Branchno=b003 City=london Postcode=78jj Branchno=b005 City=london Postcode=09jik
methods print() getpostcode() attributes branchno city postcode BRANCH
15. Subclasses, Superclasses and inheritance Some objects may have similar b
ut not identical attributes and methods. If there is a large degree of similarit
y, it would be useful to be able to share the common properties. Inheritance all
ows one class to be defined as a special case of a more general class. These spe
cial cases are known as subclasses and the more general cases are known as super
classes.
16.
o There are several forms of inheritance
o Single inheritance
o Multiple inheritance
o Repeated inheritance
o Selective inheritance
o Single inheritance:
o Single inheritance refers to the fact that the subclasses inherit from n
o more than one superclass.
17. Example person staff manager SalesStaff Superclasses subclasses Staff is
also a subclass Of a superclass person
18. Multiple inheritance
o Multiple inheritance refer that the subclass inherit from more than one
superclasses.
o Example:
manager SalesStaff salesmanager
19.
o The multiple inheritance is very problematic . The conflict arises when
the superclasses contain the same attributes or method.
o It can be handled by the following ways:
o Include both attributes/method and use the name of the superclass as qua
lifier
o For example if bonus is attribute of both manager and SalesStaff the sub
class salesmanager can inherit bonus from both, and qualify bonus in salesmanage
r as either manager.bonus or SalesStaff.bonus
20.
o Use single inheritance to avoid conflict
o For example
o Salesmanager manager salesstaff
o Or
o Salesmanager salesstaff manager
o Repeated inheritance
o It is a special case of multiple inheritance in which the superclasses i
nherit from a common superclass.
o The inheritance mechanism must ensure that the subclass does not inherit
properties from the superclass twice.
21.
o The multiple inheritance is very problematic . The conflict arises when
the superclasses contain the same attributes or method.
o It can be handled by the following ways:
o Include both attributes/method and use the name of the superclass as qua
lifier
o For example if bonus is attribute of both manager and SalesStaff the sub
class salesmanager can inherit bonus from both, and qualify bonus in salesmanage
r as either manager.bonus or SalesStaff.bonus
22. Example staff manager salesstaff salesmanager
23. Selective inheritance
o It allows a subclass to inherit a limited number of properties from the
superclass.
o Overriding and overloading
o Properties are automatically inherited by subclasses from their supercla
sses.
o However it is possible to redefine a property in the subclass. This proc
ess is called overriding.
24.
o For example we might define a method in the staff class to increment sal
ary
o Method void givecommission(float profit)
o {
o Salary=salary+0.02*profit;
o }
o However we may wish to perform a different calculation for commission in
manager subclass, we can do this by redefing the overriding
o Method void givecommission(float profit)
o {
o salary=salary+0.05*profit;
o }
25. Overloading
o Overloading allows the name of a method to be reused within a class defi
nition.
o This means that a single message can perform different functions dependi
ng on which object receive it.
o For example:
o Overloading print method for branch object and staff object
26. Method void print() { Printf(“branchno%s”,branchno); Printf(“city %s”,city); Pri
ntf(“postcode%s”,postcode); } method void print() { Printf(“staffno%d”,staffno); Printf(“n
ame%s”,name); Printf(“gender%c”,gender); }
27. Storing objects in a relational database
o Mapping classes to relations
o There are number of strategies for mapping classes to a relation but eac
h result in a loss of semantic information.
o Map each class to a relation
o One approach is to map each class to a relation.
o With this approach we loss the semantic information of which class is su
perclass and which one is subclass.
28. Staff Staffno Name Position Dob salary Manager Bonus mgrstartdate Salesp
erson Salesarea carallowance Secretary typingspeed
29.
o Staff( staffno ,name,position,dob,salary)
o Manager( staffno ,bonus,mgrstartdate)
o Salesperson( staffno ,salesarea,carallowence)
o Secretary( staffno ,typingspeed)
o Map each subclass to a relation
o A second approach is to map each subclass to a relation.
o In this approach we lost semantic information , it is no longer clear th
at the relations are subclasses.
30.
o Manager(staffno,name,dob,position,salary,bonus,mgrstartdate)
o Salesperson(staffno,name,dob,position,salary,salesarea,carallowence)
o Secretary(staffno,name,dob,position,salary,typingspeed)
o Map the hierarchy to a single relation
o The third approach is to map the entire hierarchy to a relation.
o Again we lost some semantic information and it will produce an unwanted
number of nulls for attributes that do not apply to the tuple.
31.
o Staff(staffno,name,dob,position,salary,bonus,mgrstartdate,salesarea,cara
llowence,typingspeed)
o For example for a manager tuple the attributes like salesarea,carallowen
ce,typingspeed will be null.
o Built-in interfaces for collection objects
o Any collection of object inherits the basic collection interfaces such a
s:
32.
o o.cardinality() operation returns the number of elements in the collecti
on.
o o.empty() returns true if the collection is empty
o O.insert-element(e) and o.remove-element(e) insert or remove an element “e”
from the collection o
o Automatic (user-defined) objects
o These are specified using keyword class in ODL.
33.
o Class employee
o {
o attribute string name;
o attribute date birthdate;
o attribute enum gender{M,F} gender;
o relationship department work-for
o Void reassign(in string new-dname);
o };
34. Object definition language (ODL)
o The ODL is designed to create an object database schema.
o Class Class inheritance
o relationships
1.1 1:N M:N
35. person faculty student gradstudent department courses section Has facult
y Works in advises advisor students Has section offers Registered in
36. Architecture
o Client—Server
o Many commercial OODBMS based on the client—server architecture.
o However not a system uses same client—server model, we can distinguish thr
ee basic architecture for a client—server.
o Page server
o In this approach most of the database processing is performed by the cli
ent.
37.
o The server is responsible for providing pages at the client’s request.
o Database server
o In this approach most of the database processing is performed by the ser
ver. The client simply passes request to the server.
o Object server
o This approach attempts to distribute the processing between the two comp
onents. The server is responsible to managing locks, recovery, r=enforcing secur
ity and integrity. The client is responsible for transaction management .

You might also like