Exercise 1: Answer the following questions about OODB: a) Discuss the concept of
ID: 3674708 • Letter: E
Question
Exercise 1: Answer the following questions about OODB:
a) Discuss the concept of information hiding in OODB.
b) Give examples of inheritance, multiple inheritance, and selective inheritance?
c)What is the difference between persistent and transient objects?
Exercise 2: Write the following XPath queries on the “inventory.xml” to select:
a) All editors elements in the document.
b) The author(s) of the third book element
c) All book elements whose style attribute value is equal to the textbook attribute value of the bookstore element at the root of the document.
d) All award elements that belong to book elements.
e) All title elements one or more levels deep in the <bookstore> element.
f) All price elements elements of the magazine elements.
g) All author elements of books whose prices is greater than 50.
h) All book elements with style attributes.
inventory.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="myfile.xsl" ?>
<bookstore specialty="novel">
<book>
<author>
<first-name>Joe</first-name>
<last-name>Bob</last-name>
<award>Trenton Literary Review Honorable Mention</award>
</author>
<price>12</price>
</book>
<book>
<author>
<first-name>Mary</first-name>
<last-name>Bob</last-name>
<publication>Selected Short Stories</publication>
</author>
<editor>
<first-name>Britney</first-name>
<last-name>Bob</last-name>
</editor>
<price>55</price>
</book>
<magazine frequency="monthly">
<price>2.50</price>
<subscription price="24" per="year"/>
</magazine>
<book id="myfave">
<author>
<first-name>Toni</first-name>
<last-name>Bob</last-name>
<degree from="Trenton U">B.A.</degree>
<degree from="Harvard">Ph.D.</degree>
<award>Pulitzer</award>
<publication>Still in Trenton</publication>
<publication>Trenton Forever</publication>
</author>
<price intl="Canada" exchange="0.7">6.50</price>
<excerpt>
<p>It was a dark and stormy night.</p>
<p>But then all nights in Trenton seem dark and
stormy to someone who has gone through what
<emph>I</emph> have.</p>
<definition-list>
<term>Trenton</term>
<definition>misery</definition>
</definition-list>
</excerpt>
</book>
<my:book xmlns:my="uri:mynamespace" price="29.50">
<my:title>Who's Who in Trenton</my:title>
<my:author>Robert Bob</my:author>
</my:book>
</bookstore>
Explanation / Answer
1Q.a) Discuss the concept of information hiding in OODB.
1.a.Ans: OODB stands for OBJECT ORIENTED DATABASE
An OODB stores persistent objects permanently on disk, and allow the sharing of these objects It is related to the concepts of ADTs and information hiding.
Meta variables are introduced for information hiding, data abstraction, and type , In this paper, we also discuss several concepts in object-oriented databases.
Encapsulation in OODB :
DATA ABSTRACTION :
The concept of representing important details and hiding away the implementation details is called data abstraction.
1Qb.)Give examples of inheritance, multiple inheritance, and selective inheritance?
1Q.b.Ans: INHERITENCE : To make a class inherit from another, simply use an inherit clause , Eiffel supportsmultiple inheritance: a class may have as many parents as it needs. Each parent name -- A , B , in the example -- can be followed by a Feature inherited feature keeps its original export status.
A class can be defined using another class as a foundation. In object-oriented programming terminology, one class can inherit fi elds and methods from another. An object that inherits from another is called a subclass, and the object it inherits from is called a superclass. A subclass extends the superclass.
MULTIPLE INHERITENCE :
Multiple inheritance is a feature of some object-oriented computer , For example, one might create a variable class Mammal with features such as eating,and Ruby implement single inheritance, although protocols, or interfaces, provide.
The constructors of inherited classes are called in the same order in which they are inherited. For example, in the following program, B’s constructor is called before A’s constructor.
#include<iostream>
using namespace std;
class A
{
public:
A() { cout << "A's constructor called" << endl; }
};
class B
{
public:
B() { cout << "B's constructor called" << endl; }
};
class C: public B, public A // Note the order
{
public:
C() { cout << "C's constructor called" << endl; }
};
int main()
{
C c;
return 0;
}
Run on IDE
Output:
Selective inheritance :
The key feature with regards to the typing of selective inheritance in the new model is that the self of the
subclass is not an argument to the superclass. This eliminates the possibility that methods not inherited by
a subclass affect the type of that subclass. To see how the passing of the self of the subclass as an argument
to the superclass affects the type of the subclass, consider the situation where a class C inherits a method
from the class S. In the usual model, S(sefj) is a subexpression of the translation of class C. Thus, S(self)
must be typable for class C to be typable. This means that the self of C must meet all type demands
imposed by its 5uperclass S. If method m in S demands that method k have type integer, then the type of
the self of C must have a k field of type integer, regardless of whether C has inherited methods mor k from
s.
To illustrate this situation further, consider the superclass S given by
class () methods i=3, j=self.i, k=selt.i+l end
and two subclasses C and D given by
class 0 inherits j tram S methods i=true end
class () inherits j,k trom S methods i=true end
respectively.
1Q C) What is the difference between persistent and transient objects?
Ans :
The detached object have corresponding entries in the database. These are persistent and not connected to the Session object. These objects have the synchronized data with the database when the session was closed. Since then, the change may be done in the database which makes this object stale. The detached object can be reattached after certain time to another object in order to become persistent again.
#include<iostream>
using namespace std;
class A
{
public:
A() { cout << "A's constructor called" << endl; }
};
class B
{
public:
B() { cout << "B's constructor called" << endl; }
};
class C: public B, public A // Note the order
{
public:
C() { cout << "C's constructor called" << endl; }
};
int main()
{
C c;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.