Objectorienteddbms Selective Inheritance
Objectorienteddbms Selective Inheritance
DBMS
Database that stores data elements as
abbreviated by OO or O-O
Object
The entity that contains both attributes as well as
the actions associated with it
The object has two components
1. State
2. behavior
Attributes can be classified into simple and
complex
An object is described by following characteristics
Identifier: a system-wide unique id for an object
Name: an object may also have a unique name in
DB (optional)
Lifetime: determines if the object is persistent or
transient
A simple attribute can be an
integer, string, real and so on.
Which takes on specific values.
A complex attribute can contain
collection and/or references.
A reference attribute represent a
relationship between objects and
contain a value or values.
Example
Attribute Values
BranchNo B003 simple
Street 163 main st
City Islamabad
Postcode 22010
SalesStaff Ali khan; Atif khan c/r
Manager Amjad khan
BranchNo is example of simple
attribute with value B003
The attribute Salesstaff is collection
of staff objects.
Salestaff is example of reference
attribute.
The reference attribute is similar to
foreign key in the relational
DBMS.
Features of OO
1.Object Identity
An OO database provides a unique
identity to each independent object
stored in the database.
This unique identity is implemented via
a unique system generated object
identifier OID.
The value of OID is not visible to the
user but it is used internally by the
system to identify each object uniquely.
The main property required of an OID
is that it be immutable that is the OID
value of a particular object should not
change.
It is also desirable that each OID be
used only once, that is even the object
is removed from the database its OID
should not be assigned to another
object.
OID cannot be modified by the user.
2.Abstraction
Abstraction is the process of
identifying the essential aspects of an
entity and ignoring the unimportant
properties.
There are two fundamental aspects of
abstraction
1. Encapsulation
2. Information hiding
Encapsulation
The concept of encapsulation means that an object contains
both data structure and the set of operations that can be
used to manipulate it.
Example
attributes
branchno
city Branchno=b005
postcode City=london
Postcode=09jik
methods
print()
getpostcode()
Subclasses, Superclasses
and inheritance
Some objects may have similar but not
identical attributes and methods. If there
is a large degree of similarity, it would
be useful to be able to share the common
properties.
Inheritance allows one class to be
defined as a special case of a more
general class.
These special cases are known as
subclasses and the more general cases
are known as superclasses.
There are several forms of inheritance
1. Single inheritance
2. Multiple inheritance
3. Repeated inheritance
4. Selective inheritance
Single inheritance:
person
Superclasses
manager SalesStaff
subclasses
Multiple inheritance
Multiple inheritance refer that the
subclass inherit from more than one
superclasses.
Example:
manager SalesStaff
salesmanager
The multiple inheritance is very
problematic . The conflict arises when
the superclasses contain the same
attributes or method.
It can be handled by the following ways:
Include both attributes/method and use
the name of the superclass as qualifier
For example if bonus is attribute of both
manager and SalesStaff the subclass
salesmanager can inherit bonus from
both, and qualify bonus in salesmanager
as either manager.bonus or
SalesStaff.bonus
Use single inheritance to avoid conflict
For example
Salesmanager manager salesstaff
Or
Salesmanager salesstaff manager
Repeated inheritance
It is a special case of multiple inheritance in
which the superclasses inherit from a
common superclass.
The inheritance mechanism must ensure that the
subclass does not inherit properties from the
superclass twice.
The multiple inheritance is very
problematic . The conflict arises when
the superclasses contain the same
attributes or method.
It can be handled by the following ways:
Include both attributes/method and use
the name of the superclass as qualifier
For example if bonus is attribute of both
manager and SalesStaff the subclass
salesmanager can inherit bonus from
both, and qualify bonus in salesmanager
as either manager.bonus or
SalesStaff.bonus
Example
staff
manager salesstaff
salesmanager
Selective inheritance
It allows a subclass to inherit a limited
number of properties from the superclass.
Overriding and
overloading
Properties are automatically inherited
by subclasses from their superclasses.
However it is possible to redefine a
property in the subclass. This process
is called overriding.
For example we might define a method in the
staff class to increment salary
Method void givecommission(float profit)
{
Salary=salary+0.02*profit;
}
However we may wish to perform a different
calculation for commission in manager subclass,
we can do this by redefing the overriding
Method void givecommission(float profit)
{
salary=salary+0.05*profit;
}
Overloading
Overloading allows the name of a method
to be reused within a class definition.
This means that a single message can
perform different functions depending on
which object receive it.
For example:
Overloading print method for branch object
and staff object
Method void print()
{
Printf(“branchno%s”,branchno);
Printf(“city %s”,city);
Printf(“postcode%s”,postcode);
}
Staffno
Name
Position
Dob
salary
Manager Salesperson
Secretary
Bonus Salesarea
mgrstartdate typingspeed
carallowance
Staff(staffno,name,position,dob,salary)
Manager(staffno,bonus,mgrstartdate)
Salesperson(staffno,salesarea,carallowence)
Secretary(staffno,typingspeed)
Map each subclass to a relation
relationships
1.1
1:N
M:N
Has faculty
person department
offers
Works in
faculty student courses
Client—Server
Many commercial OODBMS based on the client—
server architecture.
However not a system uses same client—server
model, we can distinguish three basic
architecture for a client—server.
Page server