Chapter 12: Object and Object-Relational Databases
1
CHAPTER 12: OBJECT and OBJECT-RELATIONAL DATABASES
Answers to Selected Exercises
12.25 – Convert the example of GEOMETRY_OBJECTS given in section 11.1.5 from the
functional notation to the notation given in Figure 11.2 that distinguishes between attributes
and operations. Use the keyword INHERIT to show that one class inherits from another
class.
Answer:
(GEOMETRY_OBJECTS to attribute/operation)
define class GEO_OBJECT:
type tuple ( shape : enumerated(rectangle, triangle, circle);
refpoint : tuple ( x: float,
y: float) );
12.26 – Compare inheritance in the EER model (see Chapter 8) to inheritance in the OO
model described in Section 11.1.5.
Answer:
(EER inheritance vs. OO inheritance)
EER inheritance has closer correspondence to the real world, in the sense that it is
Copyright © 2016 Pearson Education, Inc., Hoboken NJ
12.29 12.30: No solutions provided.
12.31 – Map the COMPANY ER schema of Figure 7.2 into ODL classes. Include appropriate
methods for each class.
Answer:
class Employee
( extent employees
key ssn
{
attribute struct name {string fname, string mname, string lname}
name;
attribute string ssn;
attribute date bdate;
Chapter 12: Object and Object-Relational Databases
4
short no_of_employees();
class Project
( extent projects
key pname, pnumber
{
attribute string pname;
attribute short pnumber;
attributte string location;
class Hours_Worked
( extent hours_worked
{
attributte float hours;
relationship Employee work_by inverse Employee:: work;
attribute date bdate;
attribute enum Gender{M, F} sex;
12.32 Specify in OQL the queries in the exercises of Chapter 7 and 8 that apply to the
COMPANY database.
(a) Retrieve the names of employees in department 5 who work more than 10 hours per
week on the ‘ProductX’ project.
select e.name.fname
Copyright © 2016 Pearson Education, Inc., Hoboken NJ
from k in dependents
where k.name = k.suporter.fname
(c) List the name of employees who are all directly supervised by ‘Franklin Wong’.
select e.fname
from e in employee
from p in projects)
: g.pnumber in (select e.work.work_on.pnumber);
(f) Retrieve the names of all employees who do not work on any project.
select e.name.fname
from e in employee
12.33 No solution provided.