Ehlmann - Object Relationship Notation (ORN) For Database Applications (2009)
Ehlmann - Object Relationship Notation (ORN) For Database Applications (2009)
by
Bryon K. Ehlmann
Southern Illinois University Edwardsville
Edwardsville, IL, USA
123
Bryon K. Ehlmann
Department of Computer Science
Southern Illinois University Edwardsville
Edwardsville, IL 62026
[email protected]
Motivation
The motivation for this book is the same as the motivation driving the research and
its results that are the subject of this book. This motivation originated in 1990 when
I attended a class on Ontos, an early object database management system (ODBMS).
Despite much support in the system for the storing of objects, i.e., object persistence,
I saw little support for relationships, specifically the types of relationships that bind
different objects together. A classic example of this type of relationship is the one-
to-many relationship that binds each object representing a department to the objects
representing the employees who work for the department. The support for such rela-
tionships improved little in later ODBMSs and in a subsequent ODBMS standard. I
viewed the support for relationships in ODBMSs to be slightly less than that pro-
vided by relational database management systems (RDBMSs).
And this latter support has, I believe, been dismal, especially when one considers
the age and pervasiveness of RDBMSs and the fact that for decades relational data-
bases have been developed based on the Entity-Relationship (ER) model. This belief
has provided even more motivation for the contents of this book. When the relation-
ships defined in ER models are implemented in relational databases, much of their
meaning—expressed by their one-to-one, one-to-many, many-to-many, and cardinal-
ity notations—is lost or very difficult to resurrect. Support for these concepts is
lacking in RDBMSs, which makes implementation unnecessarily more difficult and
error-prone.
I will “come clean” on another motivation for my research and this book. I con-
fess I have a passion for relationships. I find them fascinating! There are so many
different kinds, and it is often a challenge to try to discover their essence. What is it
viii Preface
that makes one type of relationship different from or similar to another? Some as-
pects of a relationship’s nature can be defined mathematically, but others often seem
only “vague notions.” For example, the notions of “containment” contribute to the
nature of many relationships, e.g., a car contains, or is composed of, many parts. But
what exactly is containment? It seems to come in different “flavors”—e.g., a car
also contains materials like plastic, which aren’t really “removable,” and a car may
contain passengers, which certainly must be removable. Can these flavors of con-
tainment somehow be generically defined and distinguished so that they can be ulti-
mately and properly “appreciated,” i.e., managed, by a DBMS?
Purpose
The purpose of this book is to highlight in more detail the lack of support for rela-
tionships in DBMSs but, more importantly, to point a way toward improvement. To
this end, I describe in this book a simple, yet powerful notation that modestly ex-
tends the basic ER model and its more modern, standard incarnation, the UML class
diagram. This notation, the Object Relationship Notation (ORN), allows the true na-
ture of relationships—more specifically, “associations” using UML terminology—to
be more precisely defined. It also allows these relationship definitions to be included
in a data definition language (DDL), like SQL. This permits a more direct mapping
from model to implementation and facilitates better support for relationships in
DBMSs, both object and relational.
In this book, I also describe patterns and software tools that demonstrate how
ORN can be used to more productively model and implement databases. The pat-
terns are given in Chapter 4, and the software tools are available via the Web. (See
the Downloads section later in this Preface.) The patterns, called association pat-
terns, assist in developing a better understanding of relationships and in modeling
data, regardless of whether ORN is used. The software tools—ORN Simulator, Ob-
ject Relater Plus, and ORN Additive—can be used as research tools to verify the ex-
amples given in this book, to test others, and to serve as prototypes for development
efforts that would integrate ORN into a commercial modeling tool or DBMS. In ad-
dition, the software tools can be used to assist in the development of real database
applications, and the ORN Simulator can serve as a pedagogical tool for learning the
concepts of data modeling and transaction processing.
The research results I describe in this book do not relate to a “sizzling” area of re-
search in computer science. Rather, they relate to a traditional area—namely, data
modeling and database definition—where little research is occurring, where the ma-
jor advancements were made in the 1970's, where much effort since then has been on
standardization, and thus where any breakthrough is slow to be adopted. Neverthe-
less, this book is an effort on my part to present and promote some practical research
results that I feel can advance the state-of-the-art in this traditional area. I believe
that these results can be adopted with little cost and can significantly improve the
productivity of developing database systems and improve their integrity.
Preface ix
Readers
The intended readers for this book are researchers in database systems, developers
of DBMSs or data modeling tools, practitioners of database systems development,
and students of database management. Others who may be interested are software
engineering researchers or anyone having an interest in data modeling, database de-
velopment, or simply learning more about relationships. The book can be used as a
supplemental text for courses in database management or database modeling where
students use association patterns or one or more of the tools that are discussed.
The prerequisite knowledge for the reader is a basic understanding of data struc-
tures, files, and databases. The database knowledge needed is that normally obtained
in an introductory course in database management—most importantly, a familiarity
with the ER model, relational databases and SQL, and to a lesser extent object data-
bases. In Chapter 1, I provide a brief overview of all of these topics. I use UML
class diagrams extensively throughout the book. In Chapter 1, I explain these dia-
grams so that a reader familiar with ER diagrams should develop a sufficient under-
standing.
Structure
This book is divided into three parts. The first part contains introductory material
about relationships in general and ORN in particular. This material is intended for
all readers. The second part contains material for readers interested in using ORN to
develop database applications or for readers merely interested in developing a better
understanding of the benefits and capabilities of ORN. The third part is for readers
interested in including support for ORN in database modeling tools or DBMSs or for
readers merely interested in investigating the algorithms required for implementing
ORN. Here is a brief summary of each chapter:
standing of its semantics. The user can easily create an ORN-extended database
model and then manipulate a prototype database in the context of the model. By
creating and deleting objects and creating, destroying, and changing associations
in the database, the user readily sees the effects of different ORN specifications.
• Chapter 4, Association Patterns: Emerging from a Variety of Association
Types, provides examples of the variety of associations that can be defined using
ORN and identifies among them some association patterns that can be used to
guide database modeling.
• Chapter 5, Comparing ORN to Similar Declarative Schemes, compares ORN
to similar schemes for declaring relationship semantics in terms of simplicity and
expressive power. It also discusses how ORN relates to efforts to better define
the semantics of whole-part relationships.
Part II Using ORN to Develop a Database System
• Chapter 6, ORN Additive: A Tool for Extending SQL Server with ORN, dis-
cusses a tool that allows its user to add ORN support to Microsoft’s SQL Server.
The tool automatically generates the T-SQL triggers and stored procedures that
are required to implement ORN-defined associations in a database application.
• Chapter 7, Object Relater Plus (OR+): An ORN-Extended Object DBMS,
discusses a tool that allows its user to add ORN support to Progress’s Object
Store. The tool automatically generates the C++ methods that are required to im-
plement ORN-defined associations in an object database application.
• Chapter 8, Mapping Database Models to DDLs: From ORN-Extended Class
Diagrams to ORN-Extended DBMSs, shows how one can easily map the ORN-
defined associations in a class diagram to an ORN Additive/T-SQL definition of a
database or an OR+ Object Database Definition Language (ODDL) definition of a
database.
• Chapter 9, Association Semantics: Dealing with the Subtleties, Inconsisten-
cies, and Ambiguities, discusses some of the finer points about association se-
mantics and how certain association definitions can lead to associations and com-
binations of associations that are mathematically inconsistent, likely inconsistent,
or ambiguous. Database developers can better identify and deal with such asso-
ciations when their semantics are defined by ORN.
Part III Adding ORN to the DBMS
• Chapter 10, A Conceptual Implementation of ORN: Exploring Semantic Cir-
cularity and Ambiguity, provides algorithms, which are independent of database
type, for the implementation of ORN. Based on these algorithms, it also discusses
the circularity and clarity of ORN semantics in the presence of link cycles within
a database. A theorem is stated and proved about the clarity of ORN semantics.
• Chapter 11, Adding ORN to the SQL Standard for RDBMSs, provides the syn-
tax and semantics for adding ORN to the SQL relational DBMS standard.
• Chapter 12, Adding ORN to the ODMG Standard for ODMSs, provides the
syntax, semantics, and algorithms for adding ORN to the ODMG 3.0 standard for
Object Data Management Systems (ODMSs).
Preface xi
The diagram in Fig. P.1 shows the dependencies between chapters and thus the
order in which chapters can be read. A reader very knowledgeable of data modeling,
class diagrams, and database management systems can skip Sections 1.1 and 1.2 of
Chapter 1, but should read Sections 1.3 and 1.4 for a proper introduction to the sub-
ject matter of this book. If desired, Chapters 2 and 3 can be studied together to allow
experimentation and perhaps a better understanding of the contents of Chapter 2.
Part I
Chapter 1
Chapter 2 Chapter 3
Part II
Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9
Part III
Downloads
The ORN Additive and Object Relater Plus (OR+) software tools, which are dis-
cussed in this book, can be downloaded from www.siue.edu/~behlman. Access the
site and click on the “Download Software” link.
Acknowledgments
A number of people and organizations have contributed to the writing of this book
and the work that produced its contents.
I thank the Computer Science Department and School of Engineering at Southern
Illinois University Edwardsville and the Computer and Information Systems De-
partment at Florida A&M University for their support. I particularly thank the stu-
dents in my DBMS, software engineering, and independent study classes for the pro-
jects they completed over the course of many semesters that resulted in the extensive
testing of the ORN Simulator, OR+, and ORN Additive software prototypes and the
association patterns presented in Chapter 4. Special recognition in this regard should
go to Anwesha Chattopadhyay, Brock Green, Jian Li, and Rajesh Vaddi.
xii Preface
I thank the co-authors on my previous papers related to ORN for their reviews and
assistance. They are Larry Dennis, Siebert Hardeman, Erika Neal, Gregory Riccardi,
Naphtali Rishe, Michael Stewart, Jinyu Shi, and Xudong Yu. Gregory Riccardi de-
serves special recognition for giving me the latitude and support that made my early
efforts in developing ORN possible.
I thank my editor at Springer, Susan Lagerstrom-Fife, and especially her assistant,
Sharon Palleschi, for working with me, reviewing my drafts, and answering my
many questions.
I thank my wife Barbara Ehlmann and Professor William White for their efforts in
reviewing and proofreading the entire book and finding my many errors. Still more
errors were found by the much appreciated efforts of Bethany Ehlmann, my daugh-
ter, and three students—Gerald Jackson, Aaron Jansen, and John Jenkins—in care-
fully reviewing and proofreading selected chapters.
Finally, I am especially grateful to my wife for enduring my many moments of
mental preoccupation while writing this book. Her patience, understanding, and
tremendous support made this book possible and makes my work more enjoyable.
Early research related to the development of ORN and Object Relater Plus (OR+)
was partially supported by the National Science Foundation under grant CDA-
9313299 and the U.S. Dept. of Energy under contract DE-FG05-92ER40735.
Jim Melton, SQL standards editor and SQL standards representative for Oracle
Corporation, provided helpful clarification on referential integrity for SQL:2003 ref-
erence types, which was relevant to Chapter 10.
The opening quotation in Chapter 1 is extracted with permission from (Zdonik
and Maier 1990), © 1990, Morgan Kaufmann.
Preface..................................................................................................................vii
Motivation .......................................................................................................vii
Purpose ...........................................................................................................viii
Readers .............................................................................................................ix
Structure ...........................................................................................................ix
Downloads ........................................................................................................xi
Acknowledgments ............................................................................................xi
Contents ............................................................................................................... xv
List of Abbreviations..........................................................................................xxi
2.4.2 <1-to-*>............................................................................................ 45
2.4.3 <0..1-to-*>|- ..................................................................................... 47
2.4.4 <0..1-to-*>|-X- ................................................................................. 47
2.4.5 <0..1-to-1..*>?................................................................................. 48
2.4.6 !<0..1-to-*> ...................................................................................... 49
2.4.7 '<*-to-1..*> ....................................................................................... 50
2.5 Flashback to the Company Database........................................................ 51
Chapter 11 Adding ORN to the SQL Standard for RDBMSs ..................... 205
11.1 Motivation ............................................................................................ 205
11.2 Overview of SQL Association Capabilities.......................................... 206
11.3 Proposed ORN Extension to SQL ........................................................ 209
11.4 Conclusion............................................................................................ 213
Chapter 12 Adding ORN to the ODMG Standard for ODMSs ................... 215
12.1 Motivation ............................................................................................ 215
12.2 Adding ORN to ODL ........................................................................... 217
12.2.1 Associations in ODL..................................................................... 217
Contents xix
Introduction
Including a Brief History of Relationships
A relationship is a named correspondence between objects. Much work in data modeling has
focused on understanding the many types of relationships that naturally surface in any
application. Relationships are one of the most fundamental parts of any data model. From
one point of view, they are what distinguishes databases from file systems.
(Zdonik and Maier 1990, p. 21)
Relationships are even more fundamental than the above quotation indicates. They
have been around since the beginning of time. Since there have been “things,” there
have been relationships among them. And, since humans have been recording in-
formation about things, we have been recording relationships. After all, an atom
“contains” one or more subatomic particles—a relationship. A figure in a prehistoric
cave painting “is adjacent to” some other figure, likely recording some meaningful
relationship in the mind of the ancient artist.
This chapter introduces the concept of relationships and gives a brief history of
how they have been understood, viewed, and recorded. This historical overview al-
lows us to briefly review topics germane to a complete understanding of this book:
class diagrams, relational databases and SQL, and object databases. The chapter also
discusses current problems in modeling relationships and recording, or implement-
ing, them in a database management system (DBMS). It ends by giving a glimpse at
a possible solution.
1.1 Relationships
book, when confusion could result, I use the terms “relationship type” and “relation-
ship instance” (or “link”) instead of just “relationship.”
The reader may skip this paragraph and its mathematics, but formally, a relation-
ship is defined as an n-ary relation on n sets of things, and a relationship instance is
defined as an n-tuple. If Orders is a set of orders and Customers is a set of custom-
ers, the “is placed by” relationship between orders and customers is defined as
which is read as “the set of all 2-tuples, or ordered pairs, (o, c) such that o is in Or-
ders and c is in Customers and o is placed by c and there does not exist another cus-
tomer c′ where c′ is in Customers and c′ is not c and o is placed by c′. Both the
statement identifying the relationship and the rule constraining it are part of the con-
ditional statement defining the set of allowable ordered pairs. Within this set, the re-
lationship instance involving order 612 and customer John Doe is represented as
(612, John Doe) where 612 is used to uniquely identify the order with order number
612 and John Doe is used to uniquely identify the customer with name John Doe.
Relationship types can usually be viewed from the perspective of any of the types
of things being related. For example, instead of stating that an order “is placed by” a
customer, we could state that a customer “places” an order. An instance of this rela-
tionship, which is the inverse relationship of “is placed by,” would be (John Doe,
612). (In this paragraph and hereafter only the words that relate things are quoted in
the relationship’s identifying sentence.)
Relationship types can exist between things that are the same type. For example,
a person “is married to” another person. Some of these relationships are symmetric,
providing an exception to relationship types having different perspectives. For ex-
ample, a person “is a colleague of” another person can be stated only one way.
All of the examples of relationships given thus far are binary relationships, in that
they relate two things. Most relationships are binary; however, as our definitions
imply, they can be n-ary where n > 2. A classic ternary relationship is that between
parts, vendors, and projects: a part “is supplied” by a vendor to a project. An in-
stance of this relationship might be (Type C Gear, ACME Supply, Alpha Project).
Many different relationships often exist among the same types of things. There is,
however, usually no interest in recording many of these. For example, the state-
ments that a customer “would like to place” an order and that a customer “would
never place” a particular order identify relationships, but an item purchasing system
would be unlikely to record them.
We can discover more about relationships by retracing the history of how our knowl-
edge of relationships has evolved; how relationships have been represented, or mod-
Introduction: Including a Brief History of Relationships 5
eled; and how they have been recorded, or implemented. By “implemented” I mean
how they have been stored, used for reference, and kept up-to-date. As we progress
through the various data models and data management technologies, which mark the
stages of relationship evolution and have largely been defined by them, I offer my
perspective on the advancements made and the problems yet to be solved. We begin
our review by skipping ahead in time from depictions on cave walls to paper-based
systems.
Before computer file-based systems were invented to record and process data, there
were paper-based systems. These systems consisted of forms, documents, folders,
shelves, and file cabinets. In paper-based systems, there was not much talk of rela-
tionships in an abstract sense; instead, they only existed in reality and were recorded
by suitable groupings and lists within forms or other documents.
For example, in a paper-based, item purchasing system, the “is placed by” rela-
tionship between orders and customers was recorded only by the existence of order
forms, each containing entries to record information about one order, as shown in
Fig. 1.1. Since there was space to record information about only one customer per
form, the rule was enforced that an order “is placed by” only one customer. Of
course, the same customer could appear on multiple order forms, such as John Doe
as seen in Fig. 1.1. This also means that a customer can place many orders.
Total $ 37.00
Fig. 1.1 Order forms showing the relationship between orders and customers
6 ORN FOR DATABASE APPLICATIONS
The order forms in Fig. 1.1 record more relationships than just the “is placed by”
relationship. An order “is placed for” one or more items, as indicated by the list of
line items provided on the form, each recording one item. The inverse of this rela-
tionship is that an item “is ordered by” an order; actually, it could be ordered by
more than one order, such as item number 51006. Some less obvious relationships
recorded by the order forms are that a customer “could be” a person and a customer
“could be” an organization; or inversely, a person “is a” customer and an organiza-
tion “is a” customer when placing an order. All of these relationships are addressed
later in this chapter in more detail.
Often relationships are recorded by not giving all of the information about the
things that are related. Instead, some unique bit of information is given about one or
both of the things to allow more information, which is recorded elsewhere, to be ref-
erenced and accessed when needed. In our paper-based, item purchasing system, an
item catalog likely exists, giving the item number, description, and cost for each
item. The Item No. given on an order form references the catalog and can be used to
access the item’s description in the catalog when needed.
Obviously, in the paper-based system this type of referencing and all of the work
needed to keep recorded relationships up-to-date were done by humans in a variety
of ways. Relationships were updated by manually creating and deleting forms and
documents and making revisions, when possible, to existing ones. The burden of
this effort led first to mechanized, punch card systems and then to computerized, file-
based systems. Since the former were much like the latter in terms of recording rela-
tionships, we skip ahead to the latter.
With the advent of computers in the 1940s and continuing into the 1960s, paper-
based (and punch card-based) systems for recording information began to be com-
puterized. A file-based system for data recording and processing consisted of a col-
lection of files and programs. Each program needed to have knowledge of, i.e., to
declare, the structure of the files that it processed. There was no central control.
In a file-based system, the “system” had no knowledge of the relationships that
existed among the data within one file or across files. This knowledge existed only
in the minds of the programmers who created and processed the files and was re-
flected in their program code.
The programs in a file-based system created files with a variety of structures in
order to record relationships. Sometimes, physical groupings (i.e., group items) and
lists (i.e., arrays) were created that were similar to those used in paper-based sys-
tems. Sometimes relationships were recorded in a file by having records of one type
sequentially follow each record of a different type.
An example can illustrate some of these possibilities. Fig. 1.2 shows two files
that are maintained by a file-based, item purchasing system developed to support or
possibly replace the order forms given in Fig. 1.1.
Introduction: Including a Brief History of Relationships 7
Order File
| |sub- |date |total |
orderNo |custNo |Rec- | lineItem
| |Type|lin |itemNo |itemCost |qty
307 | 022 | 0 | 03/17/2008 | 636.50|
307 | 022 | 1 | 1 | 51006 | 20.95 | 20
307 | 022 | 1 | 2 | 47000 | 6.75 | 10
307 | 022 | 1 | 3 | 24500 | 10.00 | 15
456 | 015 | 0 | 03/18/2008 | 125.70|
456 | 015 | 1 | 1 | 51006 | 20.95 | 6
Sort by
570 | 005 | 0 | 04/02/2008 | 120.00| custNo,
570 | 005 | 1 | 1 | 24500 | 10.00 | 12 orderNo,
612 | 015 | 0 | 05/28/2008 | 37.00| subRecType,
612 | 015 | 1 | 1 | 65003 | 3.50 | 2 and lin
612 | 015 | 1 | 2 | 24500 | 10.00 | 3
Fig. 1.2 Relationships between customers and orders and between orders and line items in a file-
based system
An Order file is a sequential file, ordered by two fields within each record, an or-
derNo and a subRecType. The subRecType indicates whether the remaining
fields in a record pertain to the order in general, value 0, or to a line item, value 1.
lineItem is a group item that contains four fields. lin is a line item number that se-
quentially numbers the items ordered, itemNo is a unique item number, itemCost is
the unit cost of the item, and qty is the quantity of the item being ordered. Records
with the same orderNo and subRecType = 1 are ordered by lin.
A Customer file is a sequential file, ordered by no, the customer number. Each
record contains the data for one customer. If the customer happens to be an organi-
zation, contact is the name of a contact person, else it is blank.
Four relationships are recorded in these two files. The “is placed by” relationship
between orders and customers is recorded by having the custNo (customer number)
of the customer placing the order recorded in each record of the Order file along
with the orderNo (order number). The rule that an order can only be placed by one
customer is enforced by the fact that there is only one field provided for a customer
8 ORN FOR DATABASE APPLICATIONS
number in each order record. The programmer, however, must ensure that the same
customer number is placed in all of the records pertaining to an order.
The “is placed for” relationship between orders and items (or inversely, the “is
ordered by” relationship between items and orders) is recorded by having records for
each ordered item placed sequentially after the “main record” for the order. These
records contain the itemNo, itemCost, and qty (quantity) for each item ordered.
The “could be” relationships between customers and organizations and between
customers and persons (or inversely, the “is a” relationships) are recorded by simply
having a contact field in each Customer file record that means the following: if the
customer happens to be an organization, this field contains a name, while if the cus-
tomer happens to be a person, this field is blank.
In a file-based system, relationships were used for access, using a variety of data
processing algorithms that sorted, matched, and/or merged records based on certain
fields in the records. For example, to access the name, address, and phone number of
the customer placing each order, the Order file was often sorted as shown in Fig.
1.2, and then this sorted file was sequentially accessed along with the Customer file
to match up corresponding records based on custNo and no When random access,
magnetic disk storage became available in the late 50s, relationship-based access like
that from an order record to the related customer record was implemented by 1) us-
ing custNo as a disk file key (or index key) to directly (or indirectly via an index)
access the customer record or 2) storing the absolute disk address of the customer re-
cord in the order record, instead of the custNo, and using it to read the related cus-
tomer record.
While records were being accessed, they could be updated or deleted. With se-
quential accessing this often resulted in the creation of new files. Because of the
way relationships were physically recorded, deleting a record or records to remove
information about one thing from a file often had a side-effect: information about a
number of related things was also removed. For example, deleting the Order file re-
cords for an order also removed data about the ordered items. If the order deleted
was the only order for a particular item (e.g., order 307 and item 47000 in Fig. 1.2),
then all information about that item disappeared from the updated file system.
With file-based systems as with paper-based systems, there was not much talk of
relationships in an abstract sense; instead, they only existed in reality and perhaps
still on forms, and, as we have seen, they were recorded within the computer using a
variety of physical organizations within and among files.
With the advent of data models and databases in the 1960s, a couple of major ad-
vances were made concerning relationships. They began to be viewed abstractly, or
logically, and knowledge of them was embedded in the data storage system, now the
DBMS. Briefly, a data model is a set of concepts for abstractly describing some
relevant data, the constraints on this data, and possibly its manipulation. A database
Introduction: Including a Brief History of Relationships 9
is a shared collection of logically related, relevant data and a description of this data.
A database management system (DBMS) is a software system that allows and con-
trols the definition and manipulation of a database.
The quotation at the beginning of this chapter implies that relationships played an
important role in the development of data models. Indeed, as we shall see, it was
largely improvements in our understanding of relationships that ushered in new and
improved data models.
The quotation at the beginning of the chapter also implies that relationships are
what distinguishes databases from file systems. What is meant here is that databases
have a knowledge of relationships while file systems do not. That is, the metadata
(i.e., data about the data) that is stored in a database records information about the re-
lationships recorded in the database so that the DBMS can support their use in refer-
encing and update operations. A file system, on the other hand, only records infor-
mation about the types of things, i.e., the types of entities, that are recorded in the
files, including for each entity type information about the attributes that are re-
corded. This information is stored in the form of the record and data field definitions
given in the file description of each file. The knowledge of relationships is recorded
only in the minds of the file system developers and is reflected in the physical file
structures they create and the applications code they write to process these structures.
The DBMS—by storing knowledge about relationships, by providing a logical
view of them, and by providing central control over the files comprising the data-
base—significantly increased the importance of recorded relationships and improved
their handling. Information that before was stored separately in different file-based
systems and thus was often incompatible, redundant, and inconsistent could now be
integrated into a single database by means of relationships. Also, the operations re-
quired to access records via relationships and update relationships could now be
done in a uniform manner. These operations were based on having the database de-
signer, application programmer, and user logically view the data (and relationships)
in the database in a more abstract manner based on a specific data model.
The earliest DBMSs appeared in the 1960’s. IBM’s Information Management
System (IMS) was based on the hierarchical data model. General Electric’s Inte-
grated Data Store (IDS), one of the oldest DBMSs, and Computer Associate’s Inte-
grated Database Management System (IDMS), one of the most popular along with
IMS, were based on the network data model. The description given of these models
and databases draws from a more detailed description given in Ricardo (2004).
The hierarchical model uses a tree as its basic logical structure. The hierarchical
model for a database is given by a tree structure diagram. An example of this dia-
gram, and a possible hierarchical model for our item purchasing system, is shown in
Fig. 1.3 (a). A hierarchical database consists of a collection of instances of the type
of tree defined in the tree structure diagram. Each node, or segment, of this tree
represents a particular type of entity and contains one or more fields representing its
10 ORN FOR DATABASE APPLICATIONS
Customer Order
custNo name address phone contact orderNo date total
Order Customer
orderNo date total custNo name address phone contact
LineItem LineItem
lin itemNo itemCost quantity lin itemNo itemCost quantity
(a) (b)
Fig. 1.3 Hierarchical model of item purchasing system, (a) organized by Customer and (b) organ-
ized by Order
Customer
015 John Doe 201 Main ... 555-0040
Order Order
456 03/18/2008 125.70 612 05/28/2008 37.00
(a)
015 John Doe ... 456 ... 1 51006 ... 612 ... 1 65003 ... 2 24500 ...
(b)
Fig. 1.4 Instance of the Customer tree given in Fig. 1.3 (a), (a) as viewed logically and (b) as stored
physically
In the hierarchical database modeled in Fig. 1.3 (a), the “is placed by” relationship
between orders and customers is recorded by making an Order segment a child of
the Customer segment, thus providing access from a customer to all related orders,
Introduction: Including a Brief History of Relationships 11
i.e., from the one-side of the relationship to the many-side. The “is placed for” rela-
tionship between orders and items is recorded by making a LineItem segment a child
of the Order segment, thus providing access from an order to all related items, again
from the one-side of the relationship to the many-side.
In the database a tree instance may be stored as one record, where the segments of
the tree are stored adjacent to each other in preorder fashion. This storage method is
indicated in Fig. 1.4 (b) for the tree instance in Fig. 1.4 (a). Here, the Customer
segment is followed by its first Order segment, which is followed by all of its
LineItem segments, which is followed by the second Order segment, which is fol-
lowed by all of its LineItem segments, etc.
In a hierarchical database, searching the database for particular entities involves
searching for tree instances and then, if needed, navigating through trees, i.e., doing
tree searches. The hierarchical model given in Fig. 1.3 (a) facilitates organizing a
file of tree instances so that a Customer segment could be efficiently retrieved given
a custNo. (For example, an Index Sequential Access Method (ISAM) file organiza-
tion with key custNo could be used). This model, however, would be undesirable if
efficient retrieval of orders given an orderNo was required. This is because the
custNo may not be known and each tree instance, i.e., each file record, may contain
many order numbers. A better model for locating orders is given in Fig. 1.3 (b).
This model, however, is problematic in that customer information is redundantly
stored. Here, each Order segment has just one Customer segment, but because
many orders can have the same customer, many tree instances can contain the same
Customer segment.
A major problem with the hierarchical model was that the database designer was
forced to record relationships so that one type of entity was the parent, and dominant
entity, and the other type was the child, and dependent entity. While this may be
natural for some relationships, such as that between an order and its line items, it is
unnatural for many others, such as that between orders and customers. The “forced
dependency” between related entity types made one type of entity more difficult to
reference and access (since access was always through the other type of entity),
forced an entity of the type made child to always be connected to an entity of the
type made parent, and forced the implicit deletion of a child entity whenever its par-
ent entity was deleted. This implicit deletion can be seen as a forced “referential ac-
tion.” (Similar actions involving relationships are discussed extensively throughout
this book.) In addition, if the database designer made the entity type on the many-
side of a relationship the parent for better accessibility, like Order in “is placed by,”
substantial redundancy resulted making updating and the maintenance of consistency
very problematic.
Another problem with the hierarchical model was that a segment could have only
one parent. Suppose we wanted to computerize the item catalog in our item purchas-
ing system. That is, we would now like to record information about the items that
can be ordered and record an “is ordered by” relationship between items and (not or-
ders as before, but more specifically) line items. In Figure 1.3, we would like to add
another segment, an Item segment, to either of our models and make LineItem a
12 ORN FOR DATABASE APPLICATIONS
child of this segment. Unfortunately, this is not possible since LineItem already has
Order as its parent segment.
The problems discussed above were addressed to some degree in IMS with logi-
cal databases and pointers, but at the cost of added complexity. These problems did
not exist with the network model.
The network model uses a graph as its basic logical structure. It is also called the
DBTG model based on the standard developed for the model by the Database Task
Group (DBTG) of the Conference on Data Systems Languages (CODASYL). The
network model for a database is represented by a network data structure diagram.
An example of this diagram, and a network model for our item purchasing system, is
shown in Fig. 1.5. A network database consists of a collection of records of the type
defined in the network structure diagram linked together by pointers as also defined
in the diagram. Each node, or record type, in a network data structure diagram, such
as Customer in Fig. 1.5, represents a particular type of entity and contains one or
more fields representing its attributes. Each directed edge, such as Cust-Ord, repre-
sents an owner-dependent relationship between the entity type represented by the re-
cord type at the base of the arrow, the owner record type (Customer), and that rep-
resented by the record type being pointed to, the dependent record type (Order),
wherein any instance of a dependent record is dependent on an instance of its owner
record. A single owner record type together with one or more (normally one) de-
pendent record types is called a set type. Fig. 1.5 shows three set types: Cust-Ord,
Ord-LI, and Item-LI. In a set type, access to the dependent records are provided
through the owner record and access to the owner record is provided from the de-
pendent record.
Customer
custNo name address phone contact
Cust-Ord
Order Item
orderNo date total itemNo description cost
Ord-LI Item-LI
LineItem
lin quantity
1 12
1 2
2 3
Fig. 1.6 Instance of a database for network model given in Fig. 1.5
Fig. 1.6 shows an instance of a network database, our item purchasing database,
consistent with that modeled by Fig. 1.5. Any specific node, which always occurs
just once in a network data structure diagram, can occur zero, one, or more times in a
database instance.
In the network database modeled in Fig. 1.5, the “is placed by” relationship be-
tween orders and customers is recorded by the Cust-Ord set type. This set type,
with the Customer record type as owner and the Order record type as dependent,
provides easy access from a customer to all related orders, i.e., from the one-side of
the relationship to the many-side.
The “is placed for” relationship between orders and items is actually recorded by
two set types, Ord-LI and Item-LI. This is because this relationship is actually a bit
more complicated than first described. It can actually be viewed as two relation-
ships: an order “contains” one or more line items and an item “is ordered by” one or
more line items. (The latter relationship was revealed in the previous section when
we attempted to relate an item from the item catalog to a line item.) The Ord-LI and
Item-LI set types and set types in general should become more clear when we look at
actual instances of the sets defined by these types.
An instance of a set is a collection of records having one owner record and any
number of related dependent records, called members. In Fig. 1.6, the Order record
for order 307, along with its dependent LineItem records with lin values 1, 2, and 3,
form an instance of the set Ord-LI. In total, there are four set instances for Ord-LI,
one for each Order record. In the DBTG model, a set type is implemented by a cir-
cular linked list for each instance, requiring just one pointer in both the owner and
dependent record types. (A dependent record can be a member of at most one in-
stance of a given set type.) The implementation of the Ord-LI set instance for order
307 is shown in Fig. 1.7. To access the items for which an order is placed, we ac-
cess all member LineItem records from an owner Order record via Ord-LI by trav-
ersing its linked list. For each LineItem record we come to, we access the owner
Item record via Item-LI by traversing its linked list until we come to the owner.
Note the amount of navigation! (The DBTG model provides options to add to each
14 ORN FOR DATABASE APPLICATIONS
member record a direct pointer to its owner or to make the circular linked list a dou-
bly linked list, but these options result in a big increase in the number of required
pointers. The model also provides an option to have each owner record point to each
member record via a dynamic array of pointers stored in the owner record.)
Fig. 1.7 An instance of the Ord-LI set for order 307 implemented as linked list
With the network model, the database designer was still forced to record relation-
ships so that one type of entity is the owner and the other type is the dependent;
however, because of certain aspects of the network model, this does not cause the
same problems as those caused by the parent/child representation in the hierarchical
model. First, in the network model, a record type can have more than one owner,
i.e., “parent.” Second, all records of a particular record type are in separate files with
pointers connecting them, so that access to the records of a particular type, e.g., Or-
der, can be direct and so that there is no structurally imposed rule that each entity of
the type made the dependent must be connected to an entity of the type made the
owner. And finally, deletion of an owner record type does not necessarily require
deletion of all of its connected dependent records.
This is because of the unique referential actions that the model makes available to
the database designer, actions that were not forced by the structures used to represent
relationships. A referential action is a system action or non-action that occurs when
an update operation is done that impacts a relationship. This action or non-action
may be defined by the model or the DBMS or both. It can be automatic, or it can be
optionally specified by the database designer. Referential actions enforce rules that
maintain the integrity of the relationship representation and, more importantly, can
also serve to define the nature of a relationship.
In the DBTG data definition language (DDL), optional referential actions were
defined for each set type and pertained to update operations on owner and member
type records. Basically, on insertion of a member record, the possible actions were
1) to do nothing, allowing the programmer to manually CONNECT or not connect
the record to an owner record, or 2) to automatically connect the record to an owner
record based on a given selection method. On deletion of an owner record, the pos-
sible actions were 1) to automatically delete all member records, 2) to automatically
disconnect all member records allowing them to exist independently, or 3) to issue
an error if there are any member records. On disconnect of a member record from an
owner record the possible actions were 1) to do nothing, allowing the disconnect, or
2) to issue an error. On a reconnect of a member record from one owner record to
another, the possible actions were 1) to do nothing, allowing the reconnect, or 2) to
issue an error.
Introduction: Including a Brief History of Relationships 15
In summary, the network model and DBMS that evolved during the 1960’s and
early 1970’s offered improvements over the hierarchical model and DBMS in terms
of representing and recording relationships. The model offered a logical structure
that was more suitable for representing a wider variety of relationship types without
data redundancy, and the DBMS supported an impressive set of referential actions to
enforce a number of meaningful relationship rules, i.e., relationship semantics.
Nevertheless, both approaches retained some characteristics of file-based systems
that were problematic. One problem was that accessing records (or segments in the
case of hierarchical databases) using relationships required writing code to navigate
from record to record through the implementing structures. The second problem was
that this code was often dependent on the indexing structures available, the assumed
ordering of records, and how the records had been logically structured. This latter
consideration was especially true for a hierarchical database. Any change in avail-
able indices, ordering, or logical structure resulted in many program changes. These
problems were addressed by the relational model and database.
The relational model and relational database were proposed and refined in the
1970’s and 1980’s by E.F. Codd (Codd 1970, 1980, 1990). Today, the most widely
used DBMS is the relational DBMS (RDBMS). The data model was the first to pro-
vide a mathematical foundation for a data model and database. Here, I briefly de-
scribe how relationships are viewed and recorded in a relational database assuming
the SQL:2008 standard (ANSI 2008) minus its object-oriented features.
The relational model uses an n-ary relation as its basic logical structure. A model
for a database is represented by one or more definitions of such named relations,
which can simply be viewed as tables. An example of such definitions, and the rela-
tional model for our item purchasing system, is given in Fig. 1.8. Each relation (or
table) represents a particular type of entity and contains one or more named attrib-
utes (or columns). Each attribute can be assigned values from a particular domain,
i.e., set, of values, one value per tuple (or row) within the relation. Domain defini-
tions are not given in Fig. 1.8. One or more attributes whose values uniquely iden-
tify each tuple are defined as the primary key of the relation. Primary key attributes
are underlined in Fig. 1.8. Such attributes cannot contain null values, a data integrity
rule integral to the relational model.
One or more attributes of a relation can also be defined as a foreign key. A rela-
tion can have more than one foreign key. A relationship exists between an entity
type represented by a relation that declares a foreign key, i.e., the referencing rela-
tion, and the entity type represented by the relation that the foreign key references,
i.e., the referenced relation. An instance of this relationship exists when a foreign
key value in a tuple of the referencing relation matches a primary key value in a tu-
ple of the referenced relation. Foreign key values can be null, unless foreign key
columns are defined in SQL as NOT NULL or they are also primary key columns.
16 ORN FOR DATABASE APPLICATIONS
Null foreign key values allow entities recorded in a referencing relation to not be re-
lated to any entity recorded in the referenced relation. Foreign key values must ei-
ther match a primary key in the referenced relation or be null, another integral rule of
the relational model that enforces what is called referential integrity.
Customer Order
no name address phone contact no date total custNo
005 Sue Bany 8 Elk Ct... 472-1112 307 03/17/2008 636.50 022
015 John Doe 201 Mai... 555-0040 456 03/18/2008 125.70 015
022 ABC Co. 782 Wes... 115-0540 Joe 570 04/02/2008 120.00 005
612 05/28/2008 37.00 015
Item LineItem
no description cost orderNo lin itemNo quantity
24500 Claw Hammer 10.00 307 1 51006 20
47000 25 ft. Hose 6.75 307 2 47000 10
51006 6 ft. Ladder 20.95 307 3 24500 15
65003 Sprayer 3.50 456 1 51006 6
570 1 24500 12
612 1 65003 2
612 2 24500 3
Fig. 1.9 Instance of a database for relational model given in Fig. 1.8
Fig. 1.9 shows an instance of a relational database, our item purchasing database,
consistent with that modeled by Fig. 1.8. In this database, the “is placed by” rela-
tionship between orders and customers is recorded by the foreign key custNo in the
Order relation. This key and the primary key no in the Customer relation allow the
tuple for any order to be matched up, or joined, with the tuple for the customer plac-
ing that order. The “contains” relationship between orders and line items is recorded
by the foreign key orderNo in LineItem, and the “is ordered by” relationship be-
tween items and line items is recorded by the foreign key itemNo in the relation
LineItem. These relationship implementations should become more evident after we
examine queries that access information using these foreign keys.
A major advance with relational databases was that access to information using
relationships was no longer navigational, i.e., record by record; instead, access was
specified using a higher-level query language. The earliest such languages were re-
lational algebra and relational calculus. SQL, a less mathematical and more English-
Introduction: Including a Brief History of Relationships 17
like language, appeared later. In these languages, database operations would operate
on relations rather than records, or tuples. I provide two examples using SQL, the
standard DDL and data manipulation language (DML) for relational databases.
Fig. 1.10 (a) shows an SQL query that accesses the order number, date, and total
of all orders such that the order “is placed by” customer John Doe. The FROM Or-
der, Customer WHERE Customer.no = Order.custNo specifies that the relations
Order and Customer are to be joined based on matching the foreign key values of
custNo in relation Order with the primary key values of no in Customer. The
WHERE … AND name = 'John Doe' specifies that only the joined tuples contain-
ing the value John Doe for the name attribute are to be selected. The SELECT
Order.no, date, total specifies that only the attributes no from Order, date, and to-
tal are to be selected for, or projected onto, the resulting relation. The query oper-
ates on two relations and returns a third as the result, which is shown in Fig. 1.10 (b).
The query shown in Fig. 1.11 (a) illustrates access using the relational database
implementations for all recorded relationships. This query results in a relation con-
taining all of the information recorded in the top order form shown in Fig. 1.1—i.e.,
it reassembles the order. This query involves three joins of four relations to again
produce one result relation, which is shown in Fig. 1.11 (b).
no date name address phone lin itemNo cost quantity extendedCost total
612 05/28/2008 John Doe 201 Mai... 555-0040 1 65003 3.50 2 7.00 37.00
612 05/28/2008 John Doe 201 Mai... 555-0040 2 24500 10.00 3 30.00 37.00
(b)
Fig. 1.11 (a) SQL query for all information about order 612 and (b) result relation
With the relational model, unlike the network and hierarchical models, the logical
structure does not force the database designer to record relationships so that one type
18 ORN FOR DATABASE APPLICATIONS
of entity is dominant over the other. The structure, however, does force relationships
to be recorded so that the referencing relation, the one with the foreign key, repre-
sents the many-side of the relationship, if such side exists, and the referenced relation
represents the one-side of the relationship, of which at least one must exist. (To
model the fact that a many-side does not exist, a foreign key is defined as UNIQUE.)
Furthermore, referential integrity forces something to be done when update opera-
tions lead to unmatched foreign key values in the referencing relation. As in the net-
work model, what is done is determined by referential actions.
These actions can be defined by the database designer for each foreign key.
Again, as with network databases, the choice of actions more precisely defines the
nature, or semantics, of a relationship. Basically, on deletion of a tuple in the refer-
enced relation (see ON DELETE clause in Fig. 1.8) possible actions are 1) to do
nothing (deferring to a referential integrity check that will be done on transaction
commit), 2) to issue an error if any foreign key values in the referencing relation are
unmatched, 3) to set any foreign key values now unmatched in the referencing rela-
tion to null, or 4) to CASCADE deletion to all tuples in the referencing relation hav-
ing now unmatched foreign key values. On update of the primary key value in the
referenced relation similar actions are possible, except that instead of deleting all tu-
ples in the referencing relation having now unmatched foreign key values, the new
primary key value is “cascaded” to these tuples replacing the unmatched values.
The relational model and RDBMS provides a number of advantages in dealing
with relationships over previous models and DBMSs. The logical structure pro-
vided, including the representation of relationships, is more simple than that of pre-
vious models. The operations provided and the query languages based on these op-
erations allow data to be accessed using relationships and manipulated at a higher
level of abstraction and in a manner totally independent of how the data is physically
stored—i.e., its file organization, indexing, and ordering.
Still many believe the logical structure provided by the relational model is too
simple. That is, representing information by placing data into a set of relations (or
simple tables) is too constraining, too unnatural, and fails to capture the true seman-
tics, or meaning, of the data. After all, information is often distinctly defined as data
plus meaning (although I have been using “information” and “data” interchangea-
bly). What is lacking in the relational model is the representation of meaning. To a
degree, I believe this is true regarding relationships.
First, for complex entities, i.e., those composed of many parts—such as blue-
prints, Web pages, or even purchase orders—the relational model presents two mod-
eling choices, both problematic. Since column values must be atomic, the first
choice is to place the information about each type of entity into multiple rows of a
single table resulting in much data redundancy. For purchase orders, this choice is
shown in Fig. 1.12. The problem here is that redundancy means wasted space, up-
date anomalies, and possible data inconsistencies. The recommended choice is to
use a process called normalization to eliminate redundancies by breaking up this ta-
ble into a set of simpler tables that “properly distribute” the information about each
entity. For purchase orders, this choice is shown by the relations shown in Fig. 1.9.
Here the problems are 1) the “main table” for each entity type no longer reflects its
Introduction: Including a Brief History of Relationships 19
true nature, e.g., in Order in Fig. 1.9 any indication of line items has been lost, and
2) multiple joins are now required to “reassemble” the entity whenever it is needed
for processing or display, e.g., the query for reassembling an order in Fig. 1.11 (a).
Order
no date name address phone lin itemNo cost quantity total
307 03/17/2008 ABC Co. 782 Wes... 115-0540 1 51006 20.95 20 636.50
307 03/17/2008 ABC Co. 782 Wes... 115-0540 2 47000 6.75 10 636.50
307 03/17/2008 ABC Co. 782 Wes... 115-0540 3 24500 10.00 15 636.50
456 03/18/2008 John Doe 201 Mai... 555-0040 1 51006 20.95 6 125.70
570 04/02/2008 Sue Bany 8 Elk Ct... 472-1112 1 24500 10.00 12 120.00
612 05/28/2008 John Doe 201 Mai... 555-0040 1 65003 3.50 2 37.00
612 05/28/2008 John Doe 201 Mai... 555-0040 2 24500 10.00 3 37.00
Second, for relationships, the relational model provides a representation that is, in
a sense, “second class” to that of entities. As stated earlier, the model was the first to
have a mathematical foundation. The focus, however, was on formally defining enti-
ties and the relationships between entity attributes, not on the relationships between
entities. Simply representing a relationship as a foreign key having values that may
be null or may reference another tuple in a referenced relation disguises and fails to
record the true nature and meaning of the relationship. This problem was addressed
by the entity-relationship model.
In fairness to the relational model, some relationship semantics can be provided
by adding constraints to a database model using a constraint language like SQL. But
in practice, the constraints needed are often difficult to formulate and the constraint
language as implemented is often not powerful enough to support them. These prob-
lems are discussed further in the last section of this chapter.
As the name implies, the entity-relationship (ER) model finally elevated the status of
relationships to that of entities. The model and database were proposed by Peter P.
Chen in Chen (1976), a paper that has been one of the most cited in computer science
literature. The model presented a higher-level view of information than that pre-
sented by previous models—a conceptual view, or conceptual model, from which
previous logical models (and even future ones) could be derived. As such, the ER
model or an enhanced version of it is the most popular model used today in concep-
tually modeling information and databases. In fact, creating an ER model first and
then mapping it to a relational model has replaced the normalization process, men-
tioned earlier, as the preferred way to develop a relational database.
An ER model of a database can be depicted by an ER diagram, which contributed
to the popularity of the model. An example of this diagram, and the ER model for
20 ORN FOR DATABASE APPLICATIONS
our item purchasing system, is shown in Fig. 1.13. (I use the original form of the
diagram rather than one of the many “enhanced” forms later proposed by others.) In
the diagram, each entity set is represented as a rectangle containing its name, and
each relationship set is represented as a diamond containing its name. A diamond
and the lines connecting one or more entity sets indicate that the relationship identi-
fied in the diamond is defined among these sets.
In Fig. 1.13, the “is placed by” relationship between orders and customers is rep-
resented by the Cust-Ord relationship set, which is defined between entity sets Cus-
tomer and Order. The “is placed for” relationship between orders and items is rep-
resented by the Ord-Item relationship set.
Like the relational model, the ER model is mathematically based. An entity set
contains entities sharing common properties, i.e., relationships and attributes. Infor-
mation about an entity consists of attribute-value pairs, e.g., name-‘John Doe’ for a
customer, where the values for an attribute are drawn from a particular value set.
(Some ER diagrams may show the attributes of an entity set as labels within ovals
connected by a line to the proper rectangle.) A relationship set is mathematically de-
fined as a relation among n entities each taken from an entity set. This definition is
compatible with the definition of a relationship given at the beginning of this chap-
ter. Fig. 1.14 (a) shows instances of the entity and relationship sets in a tabular form
for the item purchasing database. Here each entity is shown with a unique, concep-
tual identifier followed by the values of its attributes.
The ER model went further than previous models in representing the semantics of
relationships. Relationships can have attributes—e.g., the lin and quantity of Ord-
Item, recording for each related order and item the line number in the order of the
ordered item and the quantity of the item ordered, respectively. The role that an en-
tity plays in a relationship can be identified—e.g., an item in the Item entity set
when related to an order plays the role of an orderedItem, as is indicated in Fig.
1.13. Also, n-ary relationships with n ≥ 3 can be represented just as easily as binary
relationships (n = 2) by simply connecting a diamond with three or more rectangles
(and expanding relationship sets to include n-tuples where n ≥ 3).
In addition, the mapping of a binary relationship can be expressed as 1:1, 1:N, or
M:N, meaning a one-to-one, one-to-many, or many-to-many relationship, respec-
tively. This important characterization of a relationship type has only been alluded
to in our discussions of previous models since there was no support for such. In fact,
the logical structures provided were incompatible with the many-to-many relation-
ship type, which had to be treated as two one-to-many relationships. Now we know
that the “is placed for” relationship between orders and items is actually a many-to-
many relationship having attributes! Also, the logical structures of previous models
had no inherent, or at least obvious, means to constrain the one-to-one type.
1 N M N
Customer Cust-Ord Order Ord-Item Item
ordered-
Item
(a)
Customer Cust-Ord
no name address phone contact custNo orderNo
005 Sue Bany 8 Elk Ct... 472-1112 022 307
015 John Doe 201 Mai... 555-0040 015 456
022 ABC Co. 782 Wes... 115-0540 Joe 005 570
015 612
Item
no description cost Ord-Item
24500 Claw Hammer 10.00 orderNo orderedItem lin quantity
47000 25 ft. Hose 6.75 307 51006 1 20
51006 6 ft. Ladder 20.95 307 47000 2 10
65003 Sprayer 3.50 307 24500 3 15
456 51006 1 6
Order 570 24500 1 12
no date total 612 65003 1 2
307 03/17/2008 636.50 612 24500 1 3
456 03/18/2008 125.70
570 04/02/2008 120.00
612 05/28/2008 37.00
(b)
Fig. 1.14 Instance of a database for model given in Fig. 1.13 where entities and relationships are
viewed (a) conceptually as sets in a tabular form and (b) as logical structures using primary keys
ticipation. For example, for Cust-Ord in Fig. 1.13, if the 1 was replaced by 0..1 and
the N by 2..15, then we would have a 0..1:2..15 mapping and an order would not
have to be placed by a customer and each customer would have to place between two
and fifteen orders, inclusive. These are strange semantics from this relationship but,
as we shall see, very appropriate semantics for another relationship.
Fig. 1.14 (b) shows a logical structure for our item purchasing system where con-
ceptual identifiers have been replaced by primary keys and entity sets and relation-
ship sets have been replaced by entity relations and relationship relations, respec-
tively. Such an “information structure” was recommended by Chen (1976). Note
that if we join the Order entity relation to the Cust-Ord relationship relation based
on no and custNo, we get something that looks a lot like a relational database (see
Fig. 1.9), which partly explains why no DBMS was ever developed based on the ER
model (to my knowledge). Also, the query languages proposed for the ER model
were very similar to the relational database query languages. And furthermore, the
ER model could be mapped to the hierarchical, network, and relational models, all of
which already had DBMS support.
1 N M N
Customer Cust-Ord Order Ord-Item Item
ordered-
1 Item
N
Cust-Con Contact
(a)
Customer Contact
no name address phone custNo name phone
005 Sue Bany 8 Elk Ct... 472-1112 010 Jane 220-0188
010 ACME 88 Oak, ... 022 Joe 115-0540
015 John Doe 201 Mai... 555-0040 022 Bill 115-0322
022 ABC Co. 782 Wes... 022 Jane 115-1028
(b)
Fig. 1.15 (a) ER model and (b) information structure for Customer and Contact relationship
Before discussing the shortcomings of the ER model, I discuss one more relation-
ship semantic that can be represented. In converting a model’s conceptual view of
information, like that shown in Fig. 1.14 (a), to the information structure view, like
that shown in Fig. 1.14 (b), we may discover that some entity sets have no primary
keys; instead, the entities of the set depend on their relationship to another entity for
their identity and existence. For example, for an organization that is a customer, we
may wish to record multiple contacts each having a different phone number. Fig.
1.15 (a) gives the ER diagram for our item purchasing system updated with a new
entity set Contact and relationship set Cust-Con, which represents the fact that a
customer “may have” many contacts. A Contact entity is a weak entity in this rela-
Introduction: Including a Brief History of Relationships 23
tionship, as denoted by the double line border. Fig. 1.15 (b) gives the new entity re-
lations for Customer and Contact. (I have added one more customer, ACME). The
primary key for Contact is custNo and name. The existence of a contact is de-
pendent on its Cust-Con relationship, as denoted by the arrow in Fig. 1.15 (b), so
that if a customer is deleted, all related contacts must be deleted.
Despite the many advances made on the relationship front by the ER model, in
some respects it fell short. The model as defined in (Chen 1976) provided that “en-
tity sets may not be mutually disjoint,” e.g., the set of organizations may belong to
the set of customers, yet it did not provide any special representations for such over-
lapping sets or elaborate on any special impact. This oversight would be addressed
later by the semantic and object models.
Also, the Chen (1976) paper in specifically addressing the semantics and rules for
data manipulation of entity and relationship sets states:
It is always a difficult problem to maintain data consistency following insertion, deletion,
and updating of data in the database. One of the major reasons is that the semantics and
consequences of insertion, deletion, and updating operations usually are not clearly defined;
thus it is difficult to find a set of rules which can enforce data consistency.
(Chen 1976, p. 9)
The paper then proceeds to discuss some semantics and rules for data manipulation,
including for some operations the “consequences” that “can be performed by the sys-
tem” to ensure “data consistency.” These “consequences,” however, which are in
fact referential actions, are incomplete and do not enforce the relationship mappings
that can be given in an ER diagram. This problem will be addressed by a notation,
which is a central topic of this book.
The purpose of semantic models was to allow more of the meaning, or semantics, of
the data to be represented in the model and ultimately recorded in the database.
“More” meant more than that allowed by the relational model, which was considered
“semantically impoverished.” Even Codd seemed to agree as he proposed adding
more semantics to his model in Codd (1979).
Beginning in the late 1970’s and continuing into the 1980’s there were many se-
mantic models proposed. The ER model could be considered the first and was ex-
tended multiple times to make it “semantically richer.” Other semantic models pro-
posed were the functional model (Shipman 1981), the semantic data model (SDM)
(Hammer and McLeod 1981), and the model for the General Entity Manipulator
(GEM) language (Zaniolo 1983). None of these semantic models gained widespread
use as the supported model for a DBMS; however, the extended ER models became
the basis for the class diagram in the Unified Modeling Language (UML) (OMG
2005), and the logical structure provided by semantic models like SDM became the
static structure for the object model, which was supported by multiple object DBMSs
(ODBMSs) (Kim 1990, Zdonik and Maier 1990).
24 ORN FOR DATABASE APPLICATIONS
In 1997, the UML class diagram was released as part of UML to standardize the
many forms of extended ER diagrams that were currently in use. Fig. 1.16 (a) shows
a class diagram for our item purchasing database, accounting for the added need of
having multiple contacts for an organization. Like the ER diagram, a rectangle pro-
vides the name of an entity set or type, which in object-oriented (OO) terms is called
a class. A class defines a set of entities, which in OO terms are objects, that have
similar properties and behavior, i.e., semantics. Objects may have value-based or
object-based attributes. These may be listed within the rectangle as shown in Fig.
1.16 (b), a more detailed class diagram. Unlike an ER diagram, methods for the
class, which define operations on the class and implement behavior, may also be
listed for the class. I do not list any of these since our focus is on relationships.
{mandatory, disjoint}
LineItem
lin
quantity
1 has ► *
Person Organization Contact
(a)
Fig. 1.16 UML class diagrams for the item purchasing system, (a) initial model and (b) revised and
more detailed model
Introduction: Including a Brief History of Relationships 25
Relationships of the type called associations in UML are represented much like
relationships in an ER diagram, except that the diamond is eliminated and a phrase
that names the association, e.g., “is placed by,” is put near the middle of the line link-
ing the two related classes. (Ternary and higher degree relationships are depicted
much like they are in an ER diagram except that the diamond is smaller and doesn’t
contain any identifier.) A readability indicator, e.g., ◄, can be placed next to an as-
sociation name to indicate the direction in which the association should be read, e.g.,
“an Order is placed by 1 Customer.”
The “1” is a multiplicity. Multiplicities are placed at each association end (next
to the classes for which they apply) and in ER terms provide the “mapping” for the
relationship. A multiplicity for a class A indicates how many objects of type A can
be related to one object of the related class (or to a fixed set of n – 1 objects each
taken from one of the n – 1 related classes for an n-ary association where n ≥ 3). In
general, multiplicities can be given as n..m, where n is the lower bound and m is the
upper bound or *, which implies no limit. A 1 means 1..1 and a * means 0..*.
Like the ER diagram, a role name can be given at an association end, e.g., or-
deredItem in Fig. 1.16 (b). A role name indicates the role that an object plays when
involved in the association. As we shall see, these names can play an important
“role” when a class diagram is mapped to an object model.
An important advancement with semantic models was the recognition that an “is
a” relationship (or inversely, a “may be a” relationship) between two types of things,
e.g., an organization “is a” customer, is fundamentally different from other types of
relationships (Smith and Smith 1977). Here, the two things being related are basi-
cally one and the same. That is, in ER terminology, one entity set is a subset of the
other entity set, or in OO terminology, one class is a subclass and the other is a su-
perclass. Since an object in a subclass is an object in a superclass, it inherits the at-
tributes and relationships (and methods) of the superclass object. Also, because of
its “being singled out for special treatment,” it may have its own attributes and rela-
tionships.
In UML, an “is a” relationship between a subclass, e.g., Organization, and a su-
perclass, e.g., Customer, is denoted as shown in Fig. 1.16. A “white” arrowhead
points to the superclass. It is assumed that any attributes listed for a superclass—
e.g., no, name, and address for Customer in Fig. 1.16 (b)—and any associations
involving the superclass, e.g., “is placed by,” are inherited by a subclass, e.g., Per-
son and Organization. Association names, multiplicities, and roles are not applica-
ble to an “is a” relationship. The {mandatory, disjoint} constraint given in Fig. 1.16
indicates that a Customer must be either a Person or Organization and cannot be
both. In class diagrams constraints such as these are given in braces.
So, to be precise, we must now distinguish between two types of relationships:
“is a” relationships and associations. The “is a” relationship is also called a gener-
alization/specialization relationship because a superclass is a generalization of its
subclasses and a subclass is a specialization on its superclass(es). An association is
sometimes called a structural relationship—because it is often represented structur-
ally, e.g., using trees, networks, or embedded foreign keys or pointers. An “is a” re-
lationship, on the other hand, is usually represented by some programmer convention
26 ORN FOR DATABASE APPLICATIONS
within a record or tuple, e.g., a contact attribute is blank if the customer represents a
person and non-blank if an organization, or it must be defined to and properly han-
dled by the system as specific type objects are created and manipulated. It is impor-
tant to note that an association “is a” relationship, but the inverse is not true. I some-
times still refer to an association as a relationship in the remainder of this book.
In Fig. 1.16 (a), an association class is given for the many-to-many association “is
ordered by.” An association class can be given for any association to indicate that
the association has some attributes, e.g., lin and quantity for the “is ordered by” as-
sociation. (Often, the name of the association class is omitted and only association
attributes are listed.) While many-to-many associations, including an association
class, can also be represented directly in an ER model and database (see Ord-Item in
Figs. 1.13 and 1.14), they must be viewed and recorded in other models and data-
bases as two one-to-many associations. These one-to-many associations share an in-
tersecting relation in the relational model and a “class that represents the associa-
tion,” or an associating class, in the object model.
For this reason, the “is ordered by” association in Fig. 1.16 (a) has been remod-
eled in Fig. 1.16 (b). Here, the associating class is LineItem. A constraint is given
on this class to ensure that our remodeling preserves the semantics of the original as-
sociation. In UML, an association is a set of tuples where each element in a tuple
represents an object of one of the related classes, and being a set, it can contain no
duplicate tuples. So, while Fig. 1.16 (a) does not allow a particular order and item to
be related twice, Fig. 1.16 (b) would (perhaps with different lin or quantity values) if
it were not for the given constraint.
In addition to the “is a” relationship, a class diagram provides for the representa-
tion of another important kind of relationship type. These are associations that have
semantics based on the concept of “whole-part,” i.e., the concept that one thing “is a
part of” another thing. The diamond in Fig. 1.16 (b), placed at the Order end of the
“contains” association, indicates that an order is an aggregate and a line item is a
component in this association. What this means mathematically, according to the
UML specifications (OMG 2005), is that the relationship between the aggregate
class, here Order, and the component class, here LineItem, is an asymmetric and
transitive relation. (Asymmetric means that if a contains b, then b does not contain
a. Transitive means that if a contains b and b contains c, then a contains c.) Aggre-
gation also means something that is more difficult to define mathematically, simply
the sense that a specific component, here a line item, “is a part of” a specific aggre-
gate, here an order. (Chapter 5 contains a more detailed discussion of these con-
cepts.)
Actually, two types of aggregation can be represented in a class diagram. The
strong type, called composition, is represented by a darkened (black) diamond, as in
Fig. 1.16 (b). Here, there is an added semantic, or rule, that a component can only be
part of one aggregate (no matter what the type). Obviously, a line item can only be
part of one order, so composition applies and an order is a composite object. The
other type of aggregate is a weaker form called shared aggregation and is repre-
sented by an unfilled (white) diamond. Here, a component can be part of more than
one aggregate, e.g., a type of engine can be part of more than one type of vehicle.
Introduction: Including a Brief History of Relationships 27
Like the ER diagram, the class diagram provides a conceptual model that can be
mapped to other logical models. Today, the generally adopted methodology for da-
tabase development first builds a conceptual model using a class diagram, then maps
this to a logical model, either relational or object, and then “implements” this model
using a target DBMS. Next, we review the object model and ODBMS and map the
class diagram for our item purchasing system to an object model and database im-
plementation.
Object databases began to appear in the mid 1980s (Copeland and Maier 1984) and
many ODBMSs were developed in the late 1980s and early 1990s. Their develop-
ment was motivated by a need to record and efficiently manipulate complex objects,
e.g., blueprints and Web pages, a need not being met by relational databases. An-
other driving force was the development of OO programming languages. Object da-
tabases and ODBMSs combine the richer modeling concepts and constructs of se-
mantic models—like unique, attribute-independent entity identifiers, type
hierarchies, inheritance, and single and multiple valued, entity-valued attributes—
with OO features like data abstraction and object behavior, i.e., the dynamic aspects
of user-defined operations or methods. In 1993, the Object Data Management Group
(ODMG), a group supported by ODBMS vendors, released a standard for an Object
Model, Object Definition Language (ODL), and Object Query Language (OQL)
(Cattel et al. 2000). Most of the discussion below is based on this standard.
Customer Order
Person
orders
customer
Organization
contacts
lineItems order
Contact
orderedItem
lineItems
Item LineItem
Fig. 1.17 Semantic/object model of the item purchasing system based on class diagram in Fig. 1.16
Fig. 1.17 is a directed graph that shows how the classes and relationships in Fig.
1.16 are represented in an object model. (Actually, this type of diagram was often
used for the semantic model.) In the graph, each node represents a class. A directed
edge from a class A to a class B represents an object-based attribute within class A
that records a relationship between A and B from the perspective of class A. For each
object of class A, the attribute references all related objects of class B and thus pro-
28 ORN FOR DATABASE APPLICATIONS
… class Order {
class Customer { int no;
int no; Date date;
string name; float total;
string address; Customer customer inverse orders;
Set<Order> orders inverse customer; List<LineItem> lineItems inverse order;
… …
}; };
class Person isa Customer { class LineItem {
string phone; int lin;
… int quantity;
}; Order order inverse lineItems;
class Organization isa Customer { Item orderedItem inverse lineItems;
List<Contact> contacts; …
… };
}; class Contact {
class Item { string name;
int no; string phone;
string description; };
float cost; extent Set<Customer> Customers;
Set<LineItem> lineItems extent Set<Order> Orders;
inverse orderedItem; extent Set<Item> Items;
… …
};
Fig. 1.18 Partial ODDL specification for the model shown in Fig. 1.17
Fig. 1.19 Instance of database consistent with semantic/object models given in Figs. 1.16 and 1.17
and ODDL given in Fig. 1.18
30 ORN FOR DATABASE APPLICATIONS
Fig. 1.20 shows an OQL query that accesses the order number, date, and total cost
of all orders such that the order “is placed by” customer John Doe. We can compare
this query to its relational counterpart, shown in Fig. 1.10 (a). While the data that re-
sults is the same as that shown in Fig. 1.10 (b), the type of the result is not the same.
Instead of resulting in a relation, this query results in an instance of a structure for
each order and returns a collection of these instances of the type:
Set<struct(no: int, date: Date, total: float)>
The query shown in Fig. 1.21, illustrates access using the object database imple-
mentations for the “is placed by,” “contains,” and “is ordered by” relationships in-
volving orders, customers, line items, and items. We can compare this query to its
relational counterpart, shown in Fig. 1.11 (a). Again, while the data that results is
the same as that shown in Fig. 1.11 (b), the type of the result is not the same. Instead
of resulting in one relation to represent an order, which “flattens it out” and dupli-
cates data, this query results in an instance of a complex structure that better repre-
Introduction: Including a Brief History of Relationships 31
sents the natural structure of an order, which is a complex object. Specifically, it re-
turns a struct of the following type, involving no data duplication:
struct(no: int, date: Date, name: string, address: string, phone: string,
lineItems: Set<struct(lin: int, no: int, cost: float, quantity: int, extendedCost: float)>,
float total)
It is interesting that even though object databases can better represent complex
objects (e.g., the definition of an Order object in Fig. 1.18 clearly includes a list of
line items), the individual parts of a complex object, like an order, must still be ac-
cessed and “reassembled” from the database, as with relational databases. Path ex-
pressions, however, provide a more natural way and usually a more efficient way to
access these parts than do joins.
It is also interesting that the data independence achieved with relational databases
is compromised with object databases. When relationships are used to access related
objects, the order of access on the many side of a relationship is determined by the
type of collection defined to implement that side. If program or query code is de-
pendent on a known ordering provided by a collection, e.g., List, and the ordering is
later changed, perhaps because of a change in collection type, e.g., to a Set, then this
code must be changed.
The ODMG object model enforces referential integrity for relationships by pro-
viding some automatic referential actions. Here, “referential integrity for relation-
ships” means no dangling references (i.e., no references to objects that do not exist)
in any attribute used to implement a relationship. If an object is deleted, any single-
valued attribute that references the object is set to null and any reference to that ob-
ject in any multi-valued attribute is removed. If a change is made to any attribute
that implements a relationship, an appropriate corresponding change is automatically
made to its inverse attribute. For example, if currentOrder.customer is set to null,
a reference to currentOrder is automatically removed from its inverse attribute cur-
rentOrder.customer.orders. Referential actions do not apply to object-based at-
tributes that do not implement a true relationship, e.g., contacts in class Customer.
What is missing from the standard object model and ODBMS are additional, de-
veloper-specifiable referential actions. Even the equivalent actions to those available
in the ON DELETE clause of the foreign key declaration in SQL are missing. Such
actions would, for example, automatically delete all related LineItem objects when
an Order object is deleted or cause an exception when an attempt is made to delete a
Customer object if related Order objects exist. Apparently and unfortunately, it is
assumed that such actions will be implemented by programmers within appropriate
class methods.
As already mentioned in the discussion on the UML class diagram, the current tech-
nology for developing databases first builds a conceptual model using a class dia-
gram, then maps this model to a logical model, and then “implements” this model us-
ing a target DBMS. The logical model and DBMS are usually relational, object, or
object-relational, but are most often relational. This section discusses relationship-
related problems that still exist with the current technology—specifically, with data
models and DBMSs—that make database development overly difficult and prone to
error. We have seen the fundamental role that relationships have played in defining
models and DBMSs. Yet, despite this role, their mapping from their modeled repre-
sentations to implementation is not straightforward and can be quite difficult.
One reason for this stems from the fact that the technology for implementing rela-
tionships using a DBMS has not caught up with the technology for modeling them
using a class diagram. Since the inception of the ER model (Chen 1976), database
developers have been modeling relationships using one paradigm and then have been
forced to implement them using a totally different one, that offered by the DBMS.
As a result, the one-to-one, one-to-many, and many-to-many notations for relation-
ships—and particularly, their more precise mapping or multiplicity semantics—
given in an ER or class diagram must be essentially abandoned when it comes time
to define relationships to a DBMS. Consequently, they must be defined indirectly in
DDLs or often implemented in code with great difficulty in both relational and object
DBMSs (Ehlmann and Yu 2005b).
In an RDBMS, a many-to-many relationship must, of course, always be imple-
mented as two one-to-many relationships, and a one-to-one relationship implemented
as a UNIQUE constraint on the implementing foreign key. The implementations of
precise multiplicity constraints, however, are more problematic. The only multiplic-
ity constraint that is easy to implement, is a lower bound of 1 on the one side of a re-
lationship. This can be implemented by defining a NOT NULL constraint on the
Introduction: Including a Brief History of Relationships 33
implementing foreign key, provided the referenced relation is the 1 side of the rela-
tionship. (This need not always be the case in a one-to-one relationship—e.g., an
Employee relation, the referencing relation, contains a foreign key issuedCard that
may reference a credit card number in the CreditCard relation, the referenced rela-
tion, and each credit card must be assigned to 1 employee). Other multiplicity con-
straints must be implemented by complex constraints and triggers as we shall soon
discover by an example.
In an ODBMS, the one side of the relationship is implemented as a reference and
the many side as a collection. A many-to-many relationship must be implemented as
two one-to-many relationships if it has some attributes. The implementation of pre-
cise multiplicity constraints is totally the responsibility of the database developers.
The constraints must be enforced by properly coding all class methods that deal with
the inserting or deleting of objects or the initial setting or updating of any object-
based attribute. The appropriate checks must be made in these methods and the
proper exceptions must be raised .
Another significant reason why relationship implementation can be difficult with
current technology is a dearth of declarative referential actions available to database
developers. Such actions, if specifiable in a class diagram, would allow database de-
signers to better model relationships and, if supported by the DBMS, would allow
developers to more easily implement them. As previously discussed:
• The ER diagram (and model) allows no optional referential actions to be specified
except those related to weak entity types. When an entity type is made weak, then
presumably an entity of this type is automatically deleted on deletion of its related
“strong” entity, and on insertion of a weak entity, an error is given if the entity is
not linked to an entity of its strong entity type.
• The class diagram, like the ER diagram, allows no optional referential actions to
be specified except that some referential actions are assumed when a class is
made a component class of a composite class or a subclass of a superclass. In the
former case, on deletion of a composite object, any related component object is
deleted, and on linking a component object to a second composite object, an ex-
ception is raised. In the latter case, on deletion of a subclass object, the superclass
object is deleted and vice versa. These “objects,” however, are really the same
objects, so these actions cannot really be called referential actions. (Stereotypes,
e.g., «weak entity», can be used in class diagrams to label classes as weak or
strong entity types. This presumably indicates the same referential actions as
those for ER diagrams.)
• SQL has ON DELETE and ON UPDATE referential actions for foreign key dec-
larations. These, however, only deal with tuple deletion and primary key update
operations on one side of a relationship, i.e., on the referenced relation side. They
do not provide any actions relevant to tuple deletion or update foreign key opera-
tions on the referencing relation. These foreign key operations are important in
that they result in the creation and destruction of relationship instances.
• The ODMG object model provides no optional referential actions for associations,
period! The “referential actions” for subclass/superclass objects are the same as
those inferred by a class diagram.
34 ORN FOR DATABASE APPLICATIONS
I use the words “presumably” and “assumed” above in describing the referential ac-
tions supported by the ER and class diagrams because both are only models and
without corresponding support from a DBMS, the actions are not automatic, but
must be manually implemented by the database developer. Productivity improves
immensely when the DBMS supports the declarative referential actions of a model.
Today, the class diagram model does not provide referential actions relevant to
the enforcement of multiplicities, and DBMSs do not support the enforcement of
multiplicities or any relevant referential actions, i.e., “multiplicity actions.” Why
can’t multiplicities be specified in the DDL of a DBMS and be enforced by the
DBMS? Why, for example, can’t a system action like CASCADE be specified for
object deletion when this deletion would violate a lower bound multiplicity? As we
shall see in subsequent chapters, such enforcement and related actions can better de-
fine the nature, i.e., semantics, of relationships and thus improve the productivity of
developing database systems and enhance database integrity.
An example will illustrate the current difficulty of modeling certain relationships
in a class diagram and implementing them in a relational database. Fig. 1.22 models
part of a company database. Relationships exist wherein a unit within the company
“consists of” zero or more units, an employee “works for” a unit, and an employee
“belongs to” zero or one carpool. The “consists of” association is an example of an
intra-class association since it involves just one class. It is also an example of a re-
cursive association since a child unit can itself be a parent unt. A unit may consist
of units, each of which may consist of units, each of which may consist of units, … .
0..1 ♦ *
parent child
consists of ►
Besides the semantics described in the diagram, here are some additional ones
relevant to the relationships that cannot be described in the diagram:
• An attempt to remove a unit that has employees working for it should cause an er-
ror since all employees must work for a unit. (This semantic may seem to be im-
plied by the 1 for Unit, but employees could just be removed along with the unit.)
• If a unit is removed, all subordinate, i.e., component, units should be automati-
cally removed unless those units still have employees working for them. Such
units may remain independent or later be placed within another unit.
• If a unit is removed from its parent unit, similar semantics should apply. It and all
of its subordinate units should be automatically removed unless they have em-
ployees working for them.
• A carpool is defined by having at least two riders, so that if the number of riders
falls below two, due to employee terminations or employees quiting the carpool,
the carpool really no longer exists and so should be automatically removed.
Introduction: Including a Brief History of Relationships 35
I close this first chapter by giving a sneak preview of what lies ahead, namely a solu-
tion to the problems just discussed. Fig. 1.24 (a) shows an extended class diagram,
which includes notations that provide the desired referential actions that better define
the modeled associations. These are the ' binding symbol given at the parent end of
the “consists of” association, the ? binding symbol given at the Employee end of the
“belongs to” association, and the lack of binding symbols given at all other associa-
tion ends.
Fig. 1.24 (b) gives an extended SQL that implements all of the desired association
semantics. Again, the code specifically written to implement these semantics is
given in italics. All that is needed is a notation for each foreign key definition, e.g.,
?<2..15-to-0..1> for foreign key fk_Carpool_rO, that directly maps the class dia-
gram representation of an association to its SQL definition, which is also its imple-
mentation since the DBMS will now enforce all multiplicities and execute all refer-
ential actions. No complex constraints, triggers, or programming is required.
36 ORN FOR DATABASE APPLICATIONS
Fig. 1.23 Partial standard SQL currently needed to implement model shown in Fig. 1.22
Introduction: Including a Brief History of Relationships 37
(b)
Fig. 1.24 For part of a company database, (a) an extended class diagram and (b) an extended SQL
implementation
Chapter 2
The Object Relationship Notation (ORN) was first described in Ehlmann et al.
(1992). It was proposed for “representing non-inheritance relationships in an object-
oriented, scientific database,” as indicated by the title of this 1992 paper. Like the
relational and ER models, ORN has evolved from what was originally proposed. Its
syntax, graphical representation, and semantics have changed slightly, and it has
been integrated into UML class diagrams, adapted to relational databases, and ap-
plied to the development of all types of databases, not just scientific (Ehlmman and
Riccardi 1994, Ehlmann and Stewart 1997, Neal and Ehlmann 2000, Ehlmann and
Yu 2002, Ehlmann 2006).
Today, ORN can best be described as a declarative scheme that adds referential
actions to UML multiplicities to allow the semantics of associations to be better de-
fined. Its symbols for describing referential actions, called bindings, are included in
ER and class diagrams to better describe associations during conceptual modeling.
Its complete syntax, including multiplicities, is included in DDLs to better define as-
sociations to DBMSs, object or relational. This allows a DBMS to enforce multiplic-
ities and perform the specified referential actions. When ORN is supported by an
ORN-extended DBMS, a variety of association types can be easily modeled, more di-
rectly mapped to a database definition, and automatically implemented.
This chapter defines the syntax of ORN, its graphical representation in an ER and
class diagram, and its semantics. It explains these semantics with a number of ex-
amples and concludes by returning to the company database model given at the end
of the previous chapter to explain the ORN previewed by this example. The chapter
can be read with Chapter 3, which presents a tool that is helpful in learning ORN.
2.1 Syntax
The syntax of ORN is that of an <association> and is given by the syntax diagram
in Fig. 2.1. Valid syntax results only from traversing the diagram in the direction of
the arrows. Some examples of <association>s are given below. As we shall see in
Section 2.3, the last two examples are semantically equivalent.
1..*, and reflects what is given in a UML class diagram. A <multiplicity> is given
for each class or role. An <association> delimits a <multiplicities> specification
by < and > symbols and adds more semantic detail by including a <binding> for
each end of the association, e.g., !<1-to-1..*>?.
<association>: <binding>:
<binding> < <multiplicities > > <binding>
<di>
<multiplicities>:
<multiplicity> -to- <multiplicity> 1 | <di>
1 X
<multiplicity>:
<minimum>.. <maximum> <di>:
* –
<number> ?
* ~ !
1 – path can be taken only once for each <binding> '
Fig. 2.1 ORN Syntax (Reprinted, with permission, from [Ehlmann 2007] © 2007 IEEE)
A <binding> uses just a few special characters, or symbols, to indicate the de-
structibility of association links, which prescribe one or more referential actions. A
<binding> is nil, i.e., contains no symbols, which specifies default binding; or it is a
<di>, destructibility indicator; or it is a |, an implicit indicator, or X, an explicit in-
dicator, followed by a destructibility indicator; or it is the latter followed by the op-
posite of the given implicit or explicit indicator followed by another destructibility
indicator. A destructibility indicator is a -, ?, !, or ' symbol, where the latter three
symbols can be preceded by an optional ~, a cascade indicator.
where <binding1> and <multiplicity1> are given for the subject class and <bind-
ing2> and <multiplicity2> are given for the related class. An example of the graphi-
cal representation for a <0..1-to-2..15>|?X? association is given in Fig. 2.2 (b).
Fig. 2.3 (a) shows the |?X? binding properly placed on the association line in an
ORN-extended ER diagram, and Fig. 2.3 (b) shows its equivalent placed next to the
Object Relationship Notation (ORN) 41
entity set mapping. The former placement is appropriate when explicit and implicit
indicators are given. It is also the original graphical representation for ORN in ER
diagrams and is the basis for the ORN logo (see Chapter 3, bottom-left of Fig. 3.1).
<multiplicity1> <multiplicity2>
subject related
<binding1> <binding2>
class class
(a)
(b)
Fig. 2.2 ORN in a class diagram, (a) generic description and (b) example
0..1 2..15
Carpool belongs Person
to ? ?
(a)
0..1 2..15 ~?
Carpool belongs Person
to
(b)
Fig. 2.3 ORN in an ER diagram, symbols placed (a) on the association line and (b) by the mappings
2.3 Semantics
ORN describes the semantics—or one could say the “nature” or “behavior”—of a
large variety of binary association types. The semantics of ORN itself are derived
from the semantics of the multiplicities and bindings given in an <association>.
The role of multiplicities in describing association semantics is well known and is
described in Chapter 1. The role of “bindings” needs a lot of explaining.
Bindings can be viewed three ways at three different levels.
• At the highest level, bindings when added to multiplicities determine the extent
and cohesiveness of complex objects. As we saw in Chapter 1, both the relational
and object models disassemble complex objects to some degree. ORN is the
42 ORN FOR DATABASE APPLICATIONS
“glue” that identifies and holds these objects together. The glue can provide a
weak bond, a super bond as for composite objects, or somewhere in between.
• Bindings indicate the degree of “binding” between related objects by indicating
the destructibility of association links, both implicit and explicit. Here, implicit
means automatic, or system initiated, and explicit means application initiated, ei-
ther by a program or query. Implicit destructibility describes whether association
links involving an object can be implicitly destroyed when an object is deleted
and whether such destruction requires related objects to be deleted. Explicit de-
structibility describes similar rules that apply when association links are explicitly
destroyed.
• At the lowest level, bindings indicate the referential actions, or multiplicity ac-
tions, that should occur on object deletion and association link destruction. These
system actions enforce multiplicity integrity (not just referential integrity), pro-
vide the desired implicit and explicit destructibility for an association, and imple-
ment the required implicit cascading of link destruction and deletion operations
within a complex object operation.
In an <association>, the <multiplicity> and <binding> before the -to- apply to
the subject class, or role for an intra-class association, and those after the -to- apply
to the related class or role. The subject class (or role) can be viewed as the related
class (or role) and vice versa, in which case the inverse <association> applies. In
general, the inverse of b1<m1-to-m2>b2 is b2<m2-to-m1>b1, and specifically that of
<0..1-to-2..15>~? is ~?<2..15-to-0..1>. The <multiplicity> and <binding> se-
mantics for one end of an association are independent of those for the other end.
Those for the other end, however, can be “in play” on certain operations, e.g., link
destruction, and so can affect the final outcome of an operation.
Table 2.1 gives the semantics of ORN from the perspective of a subject class S in
an association A. We shall refer to this table often as we study examples of ORN
that illustrate the different bindings. One thing to keep in mind with ORN semantics
is that object deletion and a link destruction, implicit or explicit, can actually be im-
plemented as object archival then deletion and link archival then destruction. In
many databases today, it is rare to actually delete or destroy anything.
2.4 Examples
To illustrate how ORN describes association semantics, this section presents varia-
tions on the classic, normally one-to-many association between departments and em-
ployees. Instead of using “department,” however, I use “unit” since it is more ge-
neric (and shorter in length). So, the association we now focus on is: an employee
“works for” a unit. Although the semantics of some of the variations on this associa-
tion that we examine will seem odd, they make sense for other associations, which
we explore later in this chapter and Chapter 4. Here, I focus on just this one associa-
tion so the reader can focus solely on the varied multiplicities and bindings and not
have to think about new associations and their own semantic peculiarities.
Object Relationship Notation (ORN) 43
The generic class diagram for the “works for” association is shown in Fig. 2.4
with variables given for the multiplicities and bindings. Also, included in the figure
is the syntactical representation of the <association>, given in terms of these vari-
ables. The examples discussed in this section are created by assigning different mul-
tiplicities and bindings to these variables.
In discussing the variations on the “works for” association, we derive the precise
meaning of each binding by paraphrasing from Table 2.1 while making appropriate
44 ORN FOR DATABASE APPLICATIONS
mU mE
◄ works for
Unit bU bE Employee
bU<mU-to-mE>bE
Fig. 2.4 Class diagram for “works for” association with variable multiplicities and bindings
2.4.1 <*-to-*>
* *
◄ works for
Unit Employee
The default binding for Unit implies both implicit default binding and explicit de-
fault binding. ORN semantics require that an object cannot be deleted unless all as-
sociations that it has with other objects can be implicitly destroyed. This means that
when an object of type Unit is deleted, all links that it has with other objects, includ-
ing any Employee objects, must be implicitly destructible. The implicit binding for
a deleted object’s class, e.g., Unit, in an association, e.g., “works for,” determines
whether such implicit destruction of the links of the association type is allowed.
Thus, the implicit default binding for the Unit class in the “works for” association
applies when a Unit object is deleted and means (paraphrasing from the nil case for a
destructibility indicator in Table 2.1): a “works for” link can be destroyed provided
this does not violate the * multiplicity. A *, i.e., 0..*, multiplicity is never violated.
Thus, a unit can always be deleted, even if it has some employees (unless the dele-
tion is disallowed by other associations in which it is involved). The referential ac-
tions given for the default binding in Table 2.1 make it clear (if it was not already)
that deletion of a unit results only in the implicit destruction of the “works for” links
with related employees; the related employees are retained.
Object Relationship Notation (ORN) 45
The explicit default binding for Unit applies when a “works for” link is explicitly
destroyed and means (again, paraphrasing from Table 2.1): the link can be destroyed
provided this does not violate the * multiplicity. Again, a * is never violated. Thus, a
“works for” link can always be explicitly destroyed, at least based on the Unit multi-
plicity and binding. For explicit destruction, however, the multiplicities and bind-
ings at both ends of an association are applicable.
The implicit default binding for the Employee class in the “works for” associa-
tion applies when an Employee object is deleted and means (paraphrasing from Ta-
ble 2.1, now where S = Employee and R = Unit): a “works for” link can be de-
stroyed provided this does not violate the * multiplicity. A * is never violated. Thus,
an employee can always be deleted.
The explicit default binding for Employee applies when a “works for” link is ex-
plicitly destroyed and means (paraphrasing from Table 2.1): the link can be de-
stroyed provided this does not violate the * multiplicity. A * is never violated. Thus,
a “works for” link can always be explicitly destroyed, based on the multiplicities and
explicit bindings at both ends of the association.
2.4.2 <1-to-*>
This <association> may be the most appropriate description for the “works for” as-
sociation. It is the one shown in the class diagram of Fig. 1.22. A unit can contain
any number of employees but each employee must belong to one and only one unit.
The association exemplifies the use of a default binding with a constrained multiplic-
ity lower bound and upper bound. The class diagram is shown in Fig. 2.6 (which is
the diagram in Fig. 2.4 where mU = 1, mE = *, and bU = bE = nil).
1 *
◄ works for
Unit Employee
The 1, or more precisely the 1..1, multiplicity for Unit in this association imposes
constraints on object and link creation. Paraphrasing the second paragraph under
<multiplicity> in Table 2.1: an Employee object can be created provided this does
not violate the 1 multiplicity. The check for a lower bound violation (of 1) is de-
ferred until transaction commit (i.e., delayed until the commit of the application-
defined transaction). A “works for” link can be created provided this does not vio-
late the 1 multiplicity. The check for an upper bound violation (of 1) is immediate
(i.e., done as part of the current operation). Thus, an employee cannot be created
unless it is linked to a unit, and an employee cannot be linked to more than one unit.
The implicit default binding for the Unit class in the “works for” association ap-
plies when a Unit object is deleted and means (paraphrasing from Table 2.1): a
46 ORN FOR DATABASE APPLICATIONS
“works for” link can be destroyed provided this does not violate the 1 multiplicity.
The 1 is violated if the Unit object being deleted is linked to an Employee object
because an employee must belong to a unit. Thus, a unit cannot be deleted if it has
any employees. It can, however, be deleted if it has no employees (at least based on
this association).
The explicit default binding for Unit applies when a “works for” link is explicitly
destroyed and means (paraphrasing from Table 2.1): the link can be destroyed pro-
vided this does not violate the 1 multiplicity. Here again, the 1 is violated because
an employee must belong to a unit. Thus an association between a unit and an em-
ployee, once created, cannot be explicitly destroyed.
It can, however, be changed. Paraphrasing the fine print of footnote 1 in Table
2.1: A link change done as a single operation that replaces the Unit object with an-
other is not treated as an explicit link destruction relative to the Unit class (but is
relative to the Employee class) and is allowed if allowed by other multiplicities and
bindings. We shall soon see that this link change is allowed by the multiplicity and
binding of the Employee class, for which the link change is treated as an explicit
link destruction (since a unit is losing an employee and another is gaining one).
Thus an employee who works for a unit can be assigned to another unit.
The implicit and explicit default bindings for the Employee class mean the same
as they did in the <*-to-*> association. Explicit destruction of a “works for” link is
allowed, at least based on * multiplicity and default binding for Employee. While
this allows the link change discussed in the previous paragraph, explicit destruction
of a “works for” link is stymied by the 1 multiplicity and default binding at the Unit
end of the association. By the way, a link change that exchanges one employee for
another is disallowed (see again footnote 1). Allowing such would mean an em-
ployee would be left without a unit.
Since both footnotes 2 and 3 of Table 2.1 are referenced for default destructibility
and are relevant to a 1 multiplicity, I now explain the last of the fine print. I do so in
the context of the <1-to-*> “works for” association and an attempted deletion of the
Unit object.
With ORN an explicit object deletion is a complex object operation, as is any ex-
plicit link destruction or change. Such an operation takes place within its own inter-
nal transaction and can involve many implicit link destructions and object deletions
based on the ORN semantics of one or more associations. For a Unit object deletion,
footnote 2 means that the check for a lower bound violation of the 1, i.e., 1..1, mul-
tiplicity is not done until the end of the transaction that encompasses this complex
object operation, i.e., it is partially deferred. In most cases, deferred versus immedi-
ate checking is immaterial in understanding ORN semantics, but in some unusual
cases, it can make a difference. For example, in deleting a Unit object it is possi-
ble—though very unlikely with this association—that because of other associations
and bindings, an Employee object that was linked to the Unit object at the beginning
of the complex object deletion has been implicitly deleted by the time of its conclu-
sion. If so, deferred checking at the commit of the operation will not reveal a viola-
tion of the 1 multiplicity for this deleted Employee object. Thus, its original link to
the deleted Unit object will not cause the failure of the explicit Unit object deletion.
Object Relationship Notation (ORN) 47
Footnote 3 states that the complex object operation is undone, which means the
internal transaction that encompasses the operation is rolled back. Thus, when the
deletion of a Unit fails because, for instance, the 1 multiplicity for Unit in the “works
for” association is violated at the end of this complex operation, all implicit link de-
structions and object deletions resulting from the operation, as well as the original
explicit Unit deletion itself, are rolled back.
As we have seen, the semantics of default bindings simply enforce multiplicities.
Next, we examine the non-default bindings.
2.4.3 <0..1-to-*>|-
With this <association> a unit can have none or many employees and each em-
ployee may (or may not) work for a single unit. An implicit negative destructibility
binding is given for Employee. The class diagram is shown in Fig. 2.7 (which is the
diagram in Fig. 2.4 where mU = 0..1, mE = *, and bU = nil, bE = |-).
0..1 *
◄ works for
Unit |- Employee
The |- binding for Employee in the “works for” association applies when an Em-
ployee object is deleted and means (paraphrasing from Table 2.1): a “works for”
link cannot be destroyed. Thus, since ORN dictates that an object cannot be deleted
unless all existing links involving the object can be implicitly destroyed, an em-
ployee who works for a unit cannot be deleted. Such an employee’s link with a unit
would have to be explicitly destroyed, which is now allowed by the 0..1 multiplicity
and explicit default binding, before the employee could be deleted.
2.4.4 <0..1-to-*>|-X-
This <association> is like the previous one except that an explicit negative destruc-
tibility binding is given for the Employee class. Since both implicit and explicit
negative destructibility are specified, the association can also be described as <0..1-
to-*>-. Its class diagram is shown in Fig. 2.8 (which is the diagram in Fig. 2.4 where
mU = 0..1, mE = *, and bU = nil, bE = |-X- or -).
The X- binding for Employee in the “works for” association applies when a
“works for” link is explicitly destroyed and means (from Table 2.1): a “works for”
link cannot be destroyed. Thus, an association between a unit and an employee, once
created, cannot be explicitly destroyed.
48 ORN FOR DATABASE APPLICATIONS
0..1 *
◄ works for
Unit - Employee
It can, however, be changed. For the X- binding, the variable S is Employee and
R is Unit, and we again paraphrase footnote 1 in Table 2.1: a link change done as a
single operation that replaces the Employee object with another is not treated as an
explicit link destruction relative to the Employee class (but is relative to the Unit
class) and is allowed if allowed by other multiplicities and bindings. This link
change is allowed by the multiplicity and binding of the Unit class, for which the
link change is treated as an explicit link destruction. Thus an employee who works
for a unit can be replaced by another employee.
This link change would not be allowed if we add the X- binding to the Unit end of
this association. An X-<0..1-to-*>- association joins an employee with a unit until
“death do ye part.” Here, this means until the unit is deleted because the |- binding
for Employee keeps a linked employee from being deleted. (The link change not al-
lowed by the X-<0..1-to-*>- association would also not be allowed by a <1-to-*>-
association, because an employee would be left without a unit.)
2.4.5 <0..1-to-1..*>?
This <association> specifies that each unit must have at least one worker. It exem-
plifies the use of conditional cascade destructibility with a lower bound multiplicity
constraint. Since both |? and X? are implied by the ?, the association can also be de-
scribed as <0..1-to-1..*>|?X?, or <0..1-to-1..*>|~?X~? if the optional cascade
symbol is given. The class diagram for this association is shown in Fig. 2.9.
0..1 1..*
◄ works for
Unit ? Employee
The |? binding for the Employee class in the “works for” association applies
when an Employee object is deleted and means (paraphrasing from Table 2.1): a
“works for” link can be destroyed, but if this violates the multiplicity 1..*, the de-
struction must be cascaded to the related Unit object, i.e., this object must be implic-
itly deleted. The 1 is violated if the Employee object being deleted is the only one
linked to the related Unit object. Thus, deletion of the last employee who works for
a unit causes the deletion of the unit.
Object Relationship Notation (ORN) 49
The X? binding applies when a “works for” link is explicitly destroyed and means
(from Table 2.1): a “works for” link can be destroyed, but if this violates the multi-
plicity 1..*, the destruction must be cascaded to the related Unit object, i.e., this ob-
ject must be implicitly deleted. Again, the 1 is violated when the Employee object
being “de-linked” from the Unit object is the only one linked to this object. Thus
terminating the “works for” relationship between a unit and its last employee termi-
nates the unit!
If the association was <0..1-to-2..*>?, then deletion or explicit delinking of one
of just two employees working for a unit would cause deletion of the unit. Assuming
this association, Fig. 2.10 shows object diagrams representing the state of a database
before and after the deletion of an employee e4. In an object diagram, circles repre-
sent objects and lines represent the association links between these objects.
e1 e1
u1
e2 e2
u2 e3 u2 e3
e4
e5 e5
(a) (b)
Fig. 2.10 For a <0..1-to-2..*>? association between units and employees, object diagrams for the
database state (a) before and (b) after deletion of e4
2.4.6 !<0..1-to-*>
0..1 *
◄ works for
Unit ! Employee
The |! binding for the Unit class in the “works for” association applies when a
Unit object is deleted and means (from Table 2.1): a “works for” link can be de-
stroyed, but the destruction must be cascaded to the related Employee object (i.e.,
this related object must be implicitly deleted). Thus, deletion of a unit causes the
implicit deletion of all employees who work for that unit.
The X! binding applies when a “works for” link is explicitly destroyed and means
(from Table 2.1): the “works for” link can be destroyed, but the destruction must be
cascaded to the related Employee object (i.e., this related object must be implicitly
deleted). Thus terminating the “works for” relationship between a unit and an em-
ployee always terminates the employee.
2.4.7 '<*-to-1..*>
* 1..*
◄ works for
Unit ' Employee
The |' binding for the Unit class in the “works for” association applies when a
Unit object is deleted and means (from Table 2.1): a “works for” link can be de-
stroyed, but an attempt must be made to cascade the destruction to the related Em-
ployee object; however, this implicit Employee object deletion must be undone if
it fails, but is required if and only if its undoing would violate the * multiplicity. A *
is never violated, so the deletion of the related Employee object is never required.
Here, the attempted deletion of a related object fails if it is the only Employee object
related to another Unit object. It fails because of the lower bound 1 multiplicity and
default implicit binding for the Employee class, which does not permit the implicit
destruction of an existing link when the multipicity is violated. Thus, deletion of a
unit causes the implicit deletion of all employees who work for that unit except any
such employee who is the only employee working for another unit.
The X' binding applies to the explicit destruction of a “works for” link. Its mean-
ing is similar to that of the |' binding. Essentially, on explicit destruction of a link,
the related Employee object is implicitly deleted unless it is the only Employee ob-
ject linked to another Unit object.
Let us suppose that on deletion of a unit or explicit destruction of an employee’s
working relationship with a unit, we do not want to delete any employee who is
Object Relationship Notation (ORN) 51
working for another unit. Then, the <association> should be '<*-to-1..*>|-. Now,
the |- binding for the Employee class blocks the implicit destruction of an existing
link on an attempted deletion of an employee, thus making it fail. Employees, how-
ever, who do not have existing links with other units are deleted. Assuming this as-
sociation, Fig. 2.13 shows object diagrams representing the state of a database before
and after the deletion of a unit u3. The “blockage” provided by the |- is independent
of the Employee multiplicity and so would also work for a '<*-to-*>|- association
between units and employees.
e1 e1
u1 u1
e2
u2 e3 u2 e3
e4 e4
u3
e5
(a) (b)
Fig. 2.13 For a '<*-to-1..*>|- association between units and employees, object diagrams for the da-
tabase state (a) before and (b) after deletion of u3
We now revisit the company database example given at the end of Chapter 1. Fig.
2.14 shows the same extended class diagram that was given in Fig. 1.24 (a). The ex-
tensions to the diagram—i.e., the ORN bindings, both explicit and default—can now
be examined and understood based on ORN semantics presented in this chapter.
Repeated below are the descriptions of relevant association semantics for this ap-
plication that could not be modeled in the standard class diagram. The applicable
bindings and multiplicities that represent each semantic in the extended-ORN class
diagram are given within parentheses. Also given within these parentheses is a ref-
erence to a subsection of Section 2.4 that describes a semantically similar variation
of the “works for” association between employees and units. Hopefully now, after a
bit of study, how these nontrivial semantics can be represented in a class diagram by
simply adding two symbols—' and ?—will be clear to the reader.
• If an attempt is made to explicitly remove a unit that has employees working for
it, an error should result because all employees must work for a unit (the implicit
default binding and 1 multiplicity for Unit in the “works for” association, see Sec-
tion 2.4.2).
• If a unit is removed, all subordinate, i.e., component or child, units should be
automatically removed unless those units still have employees working for them
(the |' binding for the parent end of the “consists of” association along with the
implicit default binding and 1 multiplicity for Unit in the “works for” association,
see Section 2.4.7). Such units may remain independent (the 0..1 multiplicity for
the parent end of the “consists of” association) or later be placed within another
unit.
• If a unit is removed from its parent unit, similar semantics should apply. It and all
of its subordinate units should be automatically removed unless they have em-
ployees working for them (the X' binding for the parent end of the “consists of”
association along with the implicit default binding and 1 multiplicity for Unit in
the “works for” association, see Section 2.4.7).
• A carpool is defined by having at least two riders, so that if the number of riders
falls below two, either because of employee terminations or because employees
quit the carpool, the carpool really no longer exists and so should be automatically
removed (the ? binding and 2..15 multiplicity for Employee in the “belongs to”
association, see Section 2.4.5).
The next chapter discusses a tool that allows the reader to very easily model all of
the associations presented in this chapter using ORN and to readily observe their se-
mantics being automatically enforced by a database system. The visualization pro-
vided by this type of tool is intended to help the user become competent at using
ORN.
Chapter 3
ORN Simulator
A Modeling Tool Where Associations Come Alive
The ORN Simulator is a Web-accessible, prototype, data modeling tool that allows a
user to model a database and then immediately simulate its operation (Ehlmann and
Riccardi 1999, Ehlmann 2002). The user defines object types, or classes, and rela-
tionships, or associations, in the context of an ORN-extended ER or class diagram.
The model defined by the diagram “comes alive” in the sense that the user can read-
ily create, view, and manipulate a prototype database in the context of the model.
This allows a database designer to observe, fine-tune, and verify the semantics, or
behavior, of associations before implementing them in a real database application.
It also allows a user of the tool to develop a better understanding of ORN and
other database management concepts. I developed the ORN Simulator as a research
prototype to showcase ORN and the concept of simulating a database within its
model. I soon discovered, however, that this tool could be an effective pedagogical
tool for learning the concepts of data modeling, transaction processing, and ORN.
As such, I have been using the tool, I believe quite successfully, in my software en-
gineering and database management classes since 2001.
The ORN Simulator is a prototype. The number of object and relationship types
that can be modeled in one diagram is very limited. To model a typical database, a
number of overlapping diagrams would be required. Also, only associations can be
modeled, not “is a” relationships. A real modeling tool, perhaps developed based on
the concepts inherent in the ORN Simulator, would not have such limitations.
This chapter provides an overview of the ORN Simulator, showing how it can be
used to first create a database model and database and then verify association behav-
ior. To do this, it utilizes many screen shots and the company database example used
in the first two chapters. The chapter also discusses the architecture of the ORN
Simulator and concludes by summarizing the benefits that such a tool can offer.
The ORN Simulator can be accessed via the Web by clicking on the “ORN Simu-
lator” link at www.siue.edu/~behlman. The reader is encouraged to create the sam-
ple model and database shown in this chapter and perform the operations demon-
strated herein. The reader may also wish to use the ORN Simulator to experiment
with and verify the semantics of any of the many associations presented in this book.
After clicking on the “ORN Simulator” link, an introductory screen is shown for
ORN and the ORN Simulator. After clicking on the “Run ORN Simulator” link on
this screen, a window appears asking for the user’s name and affiliation, which is
only used to track who is using the tool. After clicking OK on this screen, the screen
shown in Fig. 3.1 appears. It is an ER diagram, but we wish to use a class diagram.
Fig. 3.1 Initial screen showing ER diagram and default database model and database
After clicking on “View” and “UML Class Diagram” as shown in Fig. 3.2, the
screen shown in Fig. 3.3 appears, which shows the default model and database. The
model contains three classes—X, Y, and Z—and four associations—R1, R2, R3, and
R4. The association line for R4 between classes Y and X is only partially shown in
Fig. 3.3. Clicking “View” and “R1, R3, R4” results in the screen shown in Fig. 3.4,
which fully displays the R4 association. All associations in the default model and
database are <*-to-*>. The default database is empty, i.e., there are no objects shown
within any class. This will become clear after some objects have been created.
Fig. 3.2 Top of screen showing selection of the UML Class Diagram view
ORN Simulator: A Modeling Tool Where Associations Come Alive 55
Fig. 3.3 Screen showing UML class diagram and default database model and database
Fig. 3.5 Partial screen showing dropdown menu selections for Help
Fig. 3.5 shows the dropdown menu selections for the menu bar “Help” selection.
Clicking “About Program…” displays a window giving the current version and a
one-sentence description of the tool. “Using Program…” displays a window that ex-
plains how to use the tool, including the functions provided by all menu selections.
“ORN Syntax and Semantics…” displays a window showing the syntax diagram for
ORN and a table very similar to Table 2.1, describing ORN semantics.
The “Using Program…” help text explains to the user the beginning steps of using
the ORN Simulator:
Normally you begin by selecting the “View” in which you wish to operate, an ER Diagram
or a UML Class Diagram. … [We have already done this.] Then you “Map” one or more of
the given classes and relationships (UML associations) in the diagram to those in your
application … . Next, for each mapped relationship you can “Redefine Relationship Type”
using ORN. Now you can create objects and relationship instances (or links), delete objects,
and destroy and change links, and thereby observe the behavior of your relationships. If the
behavior is not what is desired, you can clear the database, “Redefine Relationship Type,”
and perform database updates to observe the new behavior. You would continue this process
until all relationships in your application have been defined and their behavior verified.
To “Map” a class, the user clicks on one of the class identifiers: X, Y, or Z. This
action displays the popup menu shown in Fig. 3.6 (a), where X has just been se-
lected. Clicking “Map Object Class…” displays a window that allows a class name
to be entered by the user, e.g., Unit.
To “Map” a relationship, the user clicks on one of the relationship identifiers: R1,
R2, R3, or R4. This displays the popup menu shown in Fig. 3.6 (b), where R1 has
just been selected. Clicking “Map Relationship…” displays a window that allows an
association name to be entered by the user, e.g., “works for.” (A readability indica-
tor can be included in the name if readability is opposite to that of the given default
direction.)
To “Redefine Relationship Type” for a relationship, the user clicks on one of the
relationship identifiers. Again, this displays the popup menu shown in Fig. 3.6 (b).
Clicking “Map Relationship Type…” displays a window that allows an <associa-
tion> to be entered by the user, e.g., <1-to-*>. This <association> replaces the cur-
rent one defined for the relationship, e.g., the default <*-to-*>.
In addition to allowing relationships to be mapped and redefined, the popup menu
displayed for a relationship also allows role names to be given for both ends of the
association. The given readability indicator for a relationship identifier always indi-
cates a reading from subject to related class—e.g., for R1, X is the subject class and
Y is the related class.
ORN Simulator: A Modeling Tool Where Associations Come Alive 57
Once the database model has been defined, objects are created and deleted using
the popup menu selections shown in Fig. 3.6 (a), and association links are created,
destroyed, or changed using the popup menu selections shown in Fig. 3.6 (b).
Fig. 3.7 shows the company database model that matches Figs. 1.24 (a) and 2.14
after classes and relationships have been properly mapped, relationships have been
properly redefined, and role names have been defined. In the context of the model, it
also shows a conforming company database after some objects and links have been
created. A link, which is an ordered pair, appears as a subject object followed by <-
-> followed by a related object. That is, (u0, e0) is represented as u0<-->e0.
(a)
(b)
Fig. 3.6 Partial screens showing popup menus that appear (a) after clicking on a class id, e.g., X,
and (b) after clicking on a relationship id, e.g., R1.
58 ORN FOR DATABASE APPLICATIONS
Fig. 3.7 Screen showing initial company database model and database
Fig. 3.8 shows the dropdown menu selections for the menu bar “Database”,
“Transaction”, and “Options” selections. These selections provide the remaining
functionality of the ORN Simulator and are briefly explained in Table 3.1. Some
additional information about these selections is as follows:
• The dump for the database given in Fig. 3.7—including its meta data, i.e.,
model—is given in Fig. 3.9. Clicking “Database Restore…” and then copying
and pasting this text into the displayed textbox restores (or creates) the database
shown in Fig. 3.7.
• “Generate …” selections generate skeletal DDL specifications that can be used to
implement the modeled database as a real object or relational database. ODDL is
discussed in Chapter 7 and ORN Additive is discussed in Chapter 6. Clicking
“Generate T-SQL w/ ORN Additive” for the model shown in Fig. 3.7 results in
the screen shown in Fig. 3.10. (Readability indicators were first removed from
the mapped association names as these names are used to form constraint names.)
• A Commit was done after creating the objects and links shown in Fig. 3.7. All
lower bound multiplicities must be satisfied at the commit of a transaction.
• The “Set RXC mode” and “Reset RXC mode” are discussed in the next section.
• Clicking on a class id, for instance X, then clicking on “Create Some Objects”
creates SomeObjectsMax minus the current number of X objects. Selecting
“SomeObjectsMax…” under “Options” allows the user to set this parameter to a
value between 2 and 10.
ORN Simulator: A Modeling Tool Where Associations Come Alive 59
Fig. 3.8 Partial screens showing menu bar selections for Database, Transaction, and Options
Table 3.1 Functions provided by the menu selections shown in Fig. 3.8
Database
Clear… Clears all objects and links from the database without changing mappings or relation-
ship types.
Update… Prompts the user to “Select an object class or relationship for update by clicking on a
class id or relationship id, respectively.”
Dump… Dumps the database as text into a textbox so that it can be copied to a text file,
saved, and later used to restore the database.
Restore… Restores the database by using the text that was previously copied and saved. A
textbox is provided into which the text is pasted.
Load Sample… Loads a sample database that can be updated for demonstration or experimentation.
Generate ODDL Generates partial Object Database Definition Language (ODDL) specifications for the
database as it has been modeled.
Generate T-SQL w/ Generates Microsoft T-SQL with ORN Additive specifications for the database as it
ORN Additive has been modeled.
Exit Exits the ORN Simulator program.
Transaction
Commit Commits all changes made to the database since the initiation of the ORN Simulator,
the last Database Clear, the last Commit, or the last Undo.
Undo… Undoes all changes made to the database since the last Commit.
Set RXC mode Sets Relationship eXChange mode, which suspends the implicit deletions of related
objects to facilitate the interchange of existing association links between objects.
Reset RXC mode Resets Relationship eXChange mode.
Options
SomeObjectsMax… Provides a textbox to set SomeObjectsMax, which determines the maximum number
of objects created for the Create Some Objects popup menu selection
60 ORN FOR DATABASE APPLICATIONS
Fig. 3.10 Generated T-SQL w/ ORN Additive for the database shown in Fig. 3.7
multiplicity of 1 for the Unit class in the “works for” association. Here, the implicit
default destructibility binding for Unit in the R1, or “works for” association, is op-
erative. The <R1 in the exception message refers to the inverse relationship to R1>.
In the <R1 relationship, Employee is the subject class and Unit is the related class.
Fig. 3.11 Partial screen after clicking on class X and selecting Delete an Object…
Fig. 3.12 Screen after clicking on Delete an Object…, showing prompt to “Select the X object …”
62 ORN FOR DATABASE APPLICATIONS
Next, we shall delete employee e2. Figs. 3.14 through 3.16 show the sequence of
screens.
Fig. 3.14 Partial screen after clicking on class Y and selecting Delete an Object…
ORN Simulator: A Modeling Tool Where Associations Come Alive 63
Fig. 3.15 Screen after clicking on Delete an Object…, showing prompt to “Select the Y object …”
The semantics described by the multiplicities and bindings of ORN for R2, the
“belongs to” association, cause the DBMS to destroy the link between e2 and car-
pool c0 on deletion of e2 and then delete car pool c0 (since it has less than two rid-
ers). Here, the |? binding is operative. The deletion of c0 then implicitly destroys
the link between e1 and c0. Here, the implicit default destructibility binding for
Carpool in R2 is operative. Also, the ORN for R1 (more precisely <R1), the “works
for” association, causes the DBMS to destroy the link between unit u1 and employee
e2. Here, the implicit default destructibility binding for Employee is operative.
Lastly, we verify the X' binding for the parent role in R3, the “consists of” asso-
ciation. This association records the current organization of the company. An “org
chart” reflecting the current links between organizations in the database is shown as
an object diagram in Fig. 3.17. Units u2, u6, u7, and u8 currently have no employ-
ees. We shall remove unit u2 from u0, i.e., destroy the link between u0 and u2.
Figs. 3.18 through 3.20 show the sequence of screens.
u0
u1 u2
u3 u4 u5 u6 u7
u8 u9
Fig. 3.18 Partial screen after clicking on relationship R3 and selecting Destroy a Link…
ORN Simulator: A Modeling Tool Where Associations Come Alive 65
Fig. 3.19 Screen after clicking on Destroy a Link…, showing prompt “Select the relationship …”
The semantics described by the ORN for the “consists of” association cause the
DBMS on destruction of the u0<-->u2 link to essentially attempt the deletion of
u2 and all units linked directly or indirectly to u2. If any of these units have em-
ployees, the attempted deletion of the unit is undone. If not, the deletion is success-
ful. Here, the X' binding for parent in R3 is operative, as is the subsequent recursive
application of the |’ binding for parent in R3, as is the implicit default destructibility
binding for Employee in R1, the “works for” association. The final result of delink-
ing u2 from u0 is the removal of u2, u6, u7, and u8, all of the units reporting to
u0 that have no employees. Units u5 and u9 remain as independent units, with their
employees.
Before concluding this section, the “Set RXC mode” and “Reset RXC mode” se-
lections under Transaction, which are documented in Table 3.1, need more explana-
tion. Suppose that in the original company database, as first seen in Fig. 3.7 and last
seen in Fig. 3.15, we wish to exchange the carpools for employees e2 and e9. That
is, the carpools for these riders have agreed to trade them. Both c0 and c2 currently
have just two riders, and an employee can be in only one carpool at a time because of
the 0..1 multiplicity. So how do we “cleanly” do this trade without violating the
lower bound multiplicity of 2 for Employee and causing the implicit deletion of car-
pool c0 or c2? We click “Set RXC mode,” destroy links e2<-->c0 and e9<--
>c2, create links e2<-->c2 and e9<-->c0, and “Reset RXC mode.” The setting
of RXC mode suspends the otherwise implicit carpool deletions of c0 and c2. The
subsequent transaction commit, which we must do, will ensure that the 2 has not
been violated for the carpools, i.e., that we put back the rider we owed to each car-
pool.
3.3 Architecture
The ORN Simulator is actually an application program that uses Object Relater Plus
(OR+), a prototype ODBMS (Ehlmann and Riccardi 1997b). OR+ is discussed in
Chapter 7.
The tool is implemented with a front-end user interface component and a back-
end database management component. The front-end is implemented in Java and
runs as an applet client. The back-end is implemented in Java and C++ and runs as
an application/database server. Communication between client and server is via
Java's Remote Method Interface (RMI). The remote methods are Java native meth-
ods coded in C++, which call still other C++ methods defined as part of an object da-
tabase system. The C++ code manipulates the database using the Object Database
Manipulation Language (ODML) of OR+. OR+ implements ORN as an extension to
ObjectStore (Progress Software Inc 2006).
ORN Simulator: A Modeling Tool Where Associations Come Alive 67
3.4 Benefits
The benefits of a tool such as the ORN Simulator for database developers are signifi-
cant. First, they can more precisely model association semantics. Thus, any incon-
sistencies in association semantics can be detected. This was not discussed in this
chapter but is discussed at length in Chapter 9. Second, association semantics can be
verified by simulation before being implemented. This can eliminated wasted effort.
Another significant benefit occurs when the DBMS supports ORN. In the ORN
Simulator the user can click on “Database” in the menu bar, then click on one of two
“Generate …” selections. The tool then automatically generates the partial DDL
specifications to implement the modeled database as an object database or relational
database, depending on the selection. These DDL specifications must of course be
processed by a DBMS that automatically maintains the modeled association behav-
ior. Such support for ORN increases data integrity and significantly reduces the
amount of database applications code that must be implemented, tested, and main-
tained by database developers.
The benefits of a tool such as the ORN Simulator for students of software engi-
neering and database management are also significant. They can quickly model and
remodel object classes and associations and see firsthand the concrete realizations of
their models. This facilitates a more rapid and better understanding of the abstrac-
tions inherent in the data model notations. The tool also facilitates student under-
standing of the concepts involving transactions in database management. It forces
students to either commit or abort their changes. When creating objects, they learn
constraint checking can be deferred (for lower bound multiplicities). When creating
links, they learn constraint checking can also be immediate (for upper bound multi-
plicities). And finally, when committing their transactions, they quickly discover that
all database constraints must be satisfied on transaction commit.
Chapter 4
Association Patterns
Emerging from a Variety of Association Types
When combined with multiplicities, the bindings of ORN allow the semantics of a
large variety of association types to be specified. As many of these types are mod-
eled in numerous application domains using ORN, some patterns begin to emerge.
Each such pattern can be described as an association pattern.
Association patterns provide guidance for modeling the associations that occur
among objects in the real world when these objects are implemented in computer ap-
plications. The patterns help the designer better understand and more precisely de-
fine the semantics of these associations, which allows them to be more easily and
properly implemented. This chapter describes a number of association patterns using
ORN and by doing so provides evidence for the effectiveness of this notation. It
then shows how the development of database systems can be improved by an ap-
proach that builds a database model using association patterns and then implements
the model by mapping it into an ORN-extended database definition that is supported
by a DBMS. The feasibility of this approach and the applicability of our association
patterns have been validated by DBMS research prototypes and by the modeling,
implementing, and testing of numerous associations.
This chapter is organized into four sections. Section 4.1 can be skipped by the
more practical minded. It provides context for association patterns—explaining what
they are, what they are not, and what they are like as well as how they relate to
analysis patterns, design patterns, patterns in general, and ORN. Section 4.2 is the
main focus of the chapter. It first explains how association patterns are to be de-
scribed and then describes seven basic patterns and fourteen patterns in all as three of
the basic patterns have major variations. Section 4.3 shows how association patterns
can be used to more productively model and implement database systems. Section
4.4 provides examples of association types that do not conform to any defined asso-
ciation pattern. Section 4.5 concludes by summarizing the motivations for associa-
tion patterns and their significance.
4.1 Context
The association patterns that are the subject of this chapter are neither the “associa-
tion patterns” that are discovered in data mining, e.g. (Tan et al. 2006), nor the “as-
sociation pattern” expressions of an object-oriented database language, e.g. (Guo et
al. 1991). Instead, they are patterns for the types of associations relevant to data
modeling. Three such association patterns were introduced by Fowler (1997); how-
ever, since then (as far as this author knows), no similar patterns have been proposed.
The closest things to such patterns are the proposed characteristics and limited no-
tations for identifying the semantics of certain types of relationships, which are dis-
cussed further in Chapter 5. These are the weak entity in the ER model (Chen 1976),
generalization/specialization in semantic and object models (Smith and Smith 1977),
the characteristics ascribed to whole-part relationships—e.g., (Albert et al. 2003),
(Barbier et al. 2003), (Odell 1994), (Winston et al. 1987)—and the shared aggrega-
tion and composition that are given special notation and semantics in the Unified
Modeling Language (UML) (OMG 2005). The patterns described here, however,
rather than focusing on certain types of relationship—like whole-part relationships or
those with weak entities—address associations in general.
In purpose, association patterns are similar to design patterns (Gamma et al.
1995) and data model patterns (Hay 1996), also termed analysis patterns (Fowler
1997). They differ, however, from these patterns in level and focus.
Design patterns are “descriptions of communicating objects and classes that are
customized to solve a general design problem in a particular context” (Gamma et al.
1995). They are normally used during systems design and generically describe the
classes, relationships, methods, and constraints that provide a solution to a common
design problem in developing software. An example of a design pattern is the
Adapter pattern (Gamma et al. 1995), which provides for the conversion of one inter-
face of a class into another.
Analysis patterns are “groups of concepts that represent a common construction in
business modeling” (Fowler 1997). They are normally used during requirements
analysis and database conceptual modeling. Analysis patterns generically describe
application-related classes, relationships, and constraints for modeling similar con-
cepts and requirements that are common to many application domains. An example
of an analysis pattern is the Party pattern (Fowler 1997), which provides for the con-
ceptual representation of people and organizations common to many applications.
Association patterns are descriptions of the semantics that define common types
of associations, i.e., structural relationships, that occur between objects. Like analy-
sis patterns, they are normally used during the requirements analysis and conceptual
modeling phases of software development. An association pattern, as defined in this
paper, generically describes the multiplicities and referential actions for defining an
application-independent association type that is common to many application or
solution domains. The pattern generically names the association type and the par-
ticipating classes to indicate the roles that related classes and objects play in the as-
sociation. The focus of association patterns is more limited than that of design and
analysis patterns. As such, they can be used at a lower level to better define the as-
sociations within these latter patterns. An example of an association pattern is the “is
an instance of” pattern, which relates the concrete objects of a “Concrete Class” to
the abstract objects of an “Abstract Class.”
The purpose of an association pattern is the same as that of any pattern, which is
to increase the productivity of design by turning what would have seemed like a
Association Patterns: Emerging from a Variety of Association Types 71
unique problem for the novice into an ordinary problem, one like many similar prob-
lems often encountered by the expert.
The referential actions that are mentioned above and used to describe association
patterns are the bindings of ORN. As indicated in Chapter 1 and as will be more
fully discussed in Chapter 5, ORN bindings provide actions more varied than the ref-
erential actions of relational DBMSs. These actions can be based on multiplicities
and given at a conceptual level, i.e., in ER (Chen 1976) or UML Class Diagrams
(OMG 2005, Ehlmann and Yu 2002). They implement a variety of association se-
mantics and define the extent of complex objects. The bindings of ORN are funda-
mental to describing association patterns, which to some extent provides a validation
for their inclusion within ORN and their semantics.
This section describes seven basic association patterns. Actually, fourteen different
patterns are described since three of the basic association patterns have major varia-
tions with slightly different semantics. Table 4.1 lists these patterns and variations
along with the subsection in which they are described. Although these patterns are
relevant to a great number of the associations seen in the data models for specific ap-
plications, no claim is made that they are exhaustive. Also, of course, not all asso-
ciations can be classified as fitting into any kind of pattern. Examples of such asso-
ciations are given in Section 4.4.
A defined object “is defined by” its association with a minimum number of defining
objects. If the number of defining objects falls below this minimum, the defined ob-
ject should be deleted. The ORN for this pattern is …-to-m>~? where mL ≥ 1. Its
model is shown in Fig. 4.1(a).
… m
Defined is defined by ► Defining
~?
Class Class
(a)
Fig. 4.1 The “is defined by” pattern—(a) generic model and (b) example
Examples. A Family is defined by at least two members, i.e., two Person ob-
jects, <0..1-to-2..*>~? (see Fig. 4.1(b)). Inversely, a person belongs to zero or one
family. If the number of members in a family falls below two, the family is deleted.
(The optional ~ symbol meaning “cascade” is not used in the remainder of the chap-
ter.)
⎯⎯⎯⎯⎯⎯⎯⎯⎯ Review of the ? and Default Binding ⎯⎯⎯⎯⎯⎯⎯⎯⎯
The ? binding for the Person class implies both a |? and X? binding. The |?
binding applies when a Person object is deleted and means (paraphrasing from Ta-
ble 2.1): a “belongs to” link can be destroyed, but if this violates the multiplicity
2..*, the destruction must be cascaded to the related Family object, i.e., this object
must be implicitly deleted. This multiplicity will be violated when the person being
deleted is one of just two members belonging to the family.
The X? binding applies when a “belongs to” link is explicitly destroyed and
means (paraphrasing from Table 2.1): the link can be destroyed, but if this violates
the multiplicity 2..*, the destruction must be cascaded to the related Family object.
Again, the multiplicity will be violated when the person being “de-linked,” or re-
moved, from the family is one of just two members in the family.
Implicit default binding for the Family class applies when a Family object is de-
leted and means (paraphrasing from Table 2.1): a “belongs to” link can be destroyed
provided this does not violate the 0..1 multiplicity. The 0..1 will not be violated.
Thus a family can be deleted despite having persons that belong to it. (The “family”
simply dissolves.)
Explicit default binding for Family applies when a “belongs to” link is explicitly
destroyed and means (paraphrasing from Table 2.1): the link can be destroyed pro-
vided this does not violate the 0..1 multiplicity. Again, the 0..1 will not be violated.
74 ORN FOR DATABASE APPLICATIONS
Thus based on the Family binding, persons can be removed from the family (though
as we have seen, based on the Person binding, this could mean the death of the fam-
ily).
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
A Polygon is defined by at least three Line objects, <*-to-3..*>?. A Track
through a particle detector is defined by at least two connecting Subtrack objects in
adjacent layers of the detector, which has eight such layers, <0..1-to-2..8>?.
Variations. An alternative ORN that may be desirable is …-to-m> where mL ≥ 1.
Here, the implicit and explicit default bindings for the Defining Class mean that a
defining object cannot be deleted and a link to a defining object cannot be explicitly
destroyed if either would cause the m multiplicity (actually mL) to be violated. This
forces the defined object to be explicitly deleted if it is no longer valid.
Comments. The ? binding is necessary for the semantics of this pattern when
automatic deletion of invalid defined objects is desired. (A ! binding can be used if
mU = mL.)
Association Patterns: Emerging from a Variety of Association Types 75
A supporting object “is recorded for” one or more primary objects. It may exist in-
dependent of any primary object in the real world, but in the system being modeled a
supporting object is recorded only because of its relevance to some primary object,
and if it is no longer relevant to any primary object, it should be deleted.
A supporting object is recorded for only one primary object. The Supporting Class
is what is often called a weak entity type in ER modeling. The ORN for this pattern
is ...-to-1>!, and its model is shown in Fig. 4.2(a).
… is recorded for ► 1
Supporting Primary
!
Class Class
(a)
* ◄ claims 1
Dependent ! Employee
(is recorded for ►)
(b)
Fig. 4.2 The “is recorded for” pattern, Case 1—(a) generic model and (b) example
Comments. The ! binding is sufficient for this pattern but not necessary. The ?
binding could have been used since the lower bound multiplicity for the Primary
Class is 1. Later we will see a pattern where the ! binding is necessary. The |! as-
pect of the ! binding is similar to the ON DELETE CASCADE referential action in
SQL; however, unlike this action, the |! binding can be used for either end or both
ends of a binary association.
A supporting object can be recorded for multiple primary objects being related to
these objects via just one association. The ORN for this pattern is ...-to-1..*>?, and
its model is shown in Fig. 4.3(a).
Fig. 4.3 The “is recorded for” pattern, Case 2—(a) generic model and (b) example
Examples. A Doctor is recorded for a soccer league Player, playing the role of a
familyPhysician, <0..1-to-1..*>? (see Fig. 4.3(b)). If the last player related to a
particular doctor is deleted, the doctor is implicitly deleted. Also, the doctor is im-
plicitly deleted when a doctor no longer serves any player because a player's rela-
tionship to the doctor has been severed (via link destruction) or the player has
changed doctors (via a link change).
A code Library is recorded for a software system Executable if the executable
uses any components in the library, <*-to-1..*>?. If a library is no longer used by
any executable, it should not be recorded. For purposes of automatic payroll deduc-
tion, a Charity (actually, up to three) is recorded for an Employee, <0..3-to-1..*>?.
Variations. Though rare, an upper bound ≥ 2 can be given for the Primary
Class, restricting the reuse of a supporting class object.
Comments. The ? binding is necessary to describe the semantics of this pattern.
This pattern is similar to the “is defined by” pattern. This is because the Support-
ing Class object’s existence depends on being related to at least one Primary Class
object. With this pattern, however, a Primary Class multiplicity with lower bound
other than 1 is senseless and with upper bound other than * is quite unusual.
Association Patterns: Emerging from a Variety of Association Types 77
A supporting object can be recorded for multiple primary objects of the same type or
different types, via multiple “is recorded for” associations. For each such associa-
tioni with a Primary Class i, where i = 1, 2, …, n and n ≥ 2, the ORN is b<m-to-
0..*>' where the binding b includes a |- if mL = 0. Primary Class j may be the same
class as Primary Class k where 1 ≤ j < k ≤ n. The model for the pattern is shown in
Fig. 4.4(a).
Fig. 4.4 The “is recorded for” pattern, Case 3—(a) generic model and (b) example
object. Each of the implicit default bindings for the “has a” associations means
(paraphrasing from Table 2.1): a link can be destroyed provided this does not violate
the 1 multiplicity. This 1, however, will always be violated. The |- binding for Ad-
dress in the “may have a” association means (from Table 2.1): a link cannot be de-
stroyed.
The X' binding, implied by the ' binding for all associations, applies to the explicit
destruction of a link. Its meaning is similar to that of the |' binding. Essentially, on
explicit destruction of a link, the related Address object is implicitly deleted unless
it has another link with a Student or Alumnus object.
For explicit link destruction, however, the bindings at both ends of an association
are operative. In fact, for each “has a” association, explicit link destruction is not al-
lowed because of the explicit default binding and 1 multiplicity for Address, which
would be violated. A link change, however, done as a single operation that replaces
the Address object with another is not treated as an explicit link destruction relative
to the Address class and is allowed in this case (see footnote 1 in Table 2.1). In
such a link change, the old address is deleted if no longer used (based on the X' bind-
ing for Student, the related class in the link change). An example of a link change
done as a single operation is changing a non-null foreign key value in a relational da-
tabase to a different non-null value.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
A Beneficiary is recorded for a Policy via two associations, playing the role of
primaryBeneficiary in one and contingentBeneficiary in the other, <1-to-*>' and |-
<0..1-to-*>', respectively. Two EmergencyContact objects, each with name and
phone numbers, are recorded for each Employee and Student. Both associations
are <2-to-*>'.
Variations. Though rare, an upper bound can be given for the Primary Class, re-
stricting the reuse of a supporting class object.
Comments. The ' binding is necessary for the semantics of this pattern. The |-
binding is needed when the lower bound multiplicity for the Supporting Class is 0.
For this particular pattern variation, ORN does not constrain independent support-
ing objects from being created, thus the need for the constraint given in braces in the
model of Fig. 4.4 (b).
If the bindings and multiplicities for the Supporting Class are the same for all
associations, a Case 2 pattern can often be used instead of a Case 3 pattern by creat-
ing a super class for all Primary Class i and associating the Supporting Class to
the super class.
Association Patterns: Emerging from a Variety of Association Types 79
A concrete object “is a realization of” an abstract object. An abstract object should
not be deleted if there are any related concrete objects. Once a concrete object is cre-
ated, its relationship to its abstract object must not be changed or destroyed. The
ORN for this pattern is X-<…--to-1>X-, and its model is shown in Fig. 4.5(a).
… is a realization of ► 1
Concrete Abstract
X- X-
Class Class
(a)
* ◄ has 1
Copy X- X- Book
(is a realization of ►)
(b)
Fig. 4.5 The “is a realization of” pattern—(a) generic model and (b) example
An associated object “is associated by” an associating object to one or more other
associated objects representing a many-to-many or n-ary association. For each such
associationi between an Associated Class i and the Associating Class, where i =
1, 2, …, n and n ≥ 2, the ORN is !<1-to-… . Associated Class j may be the same
class as Associated Class k where 1 ≤ j < k ≤ n. The model for the pattern is shown
in Fig. 4.6(a).
1 is associated by i ► ...
Associated Associating
Class i ! Class
{ The combination of Associated Class i objects associated
by each Associating Class object is unique. }
(a)
1 has ► 1..*
Employee !
(is associated by 1 ►)
Assignment
1 ◄ is for *
Project !
(is associated by 2 ►) { The combination of an Employee
and a Project associated by an
Assignment is unique. }
(b)
Fig. 4.6 The “is associated by” pattern—(a) generic model and (b) example
mended) since the insertion and deletion of Associating Class objects, e.g., as-
signments, essentially creates and destroys relationships between Associated Class
objects, e.g., between employees and projects.
A versioned object “is an update of” another such object, i.e., a newer object is an
updated version of an older object. Only the first version of an object is not an up-
dated version of an older object. If an object is deleted, all updated versions should
also be deleted. The link between an updated version of an object and its old version
cannot be destroyed; however, a new version of the object can replace an updated
version, in which case the original updated version is implicitly deleted. The ORN
for the association pattern is X-<0..mU-to-0..1>! where mU ≥ 1. Its model is shown
in Fig. 4.7(a).
newVersion newRelease
X- X-
0..mU 0..1
Versioned is an update Release updates ▼
Class of ▼ (is an update
0..1 of ▼)
0..1
! !
oldVersion oldRelease
(a) (b)
Fig. 4.7 The “is an update of” pattern—(a) generic model and (b) example
A component object “is a part of” an aggregate object. The semantics of this basic
pattern are quite varied and are described in a manner consistent with the aggregate
associations as defined in UML (OMG 2005). The semantics include the transitive
and antisymmetric properties for relationships and a notion of a “whole” and a “part”
in a whole-part relationship (Barbier et al. 2003, Winston et al. 1987). The “is a part
of” may also be recursive, meaning the component object can itself be an aggregate
object and are either the same object type or the component object type “is a” object
type that can also be an aggregate object type.
The component object can be part of multiple aggregate objects of the same type or
different types, i.e., it can be shared, and can also exist separate from, i.e., independ-
ent of, an aggregate object. The ORN for the association pattern is …-to-0..mU>
where mU ≥ 2 if all aggregates are of the same type, else mU ≥ 1. Its model is shown
in Fig. 4.8(a).
… is a part of ► 0..mU
Component
◊ Aggregate
(a)
* ◄ contains *
Chip
(is a part of ►) ◊ CircuitBoard
(b)
Fig. 4.8 The “is a part of” pattern, Case 1—(a) generic model and (b) example
A component object can be part of multiple aggregate objects of the same type, via a
single association, but cannot exist separate from, i.e., independent of, an aggregate
object.
If the association is not recursive, the ORN for the association pattern is …-to-
1..*>?, and the model is shown in Fig. 4.9(a).
If the association is recursive, the ORN for the pattern is b<m-to-0..*>' where b
includes |- if mL = 0. The model is shown in Fig. 4.10(a). For a recursive associa-
tion, the lower bound on the aggregate end is 0 since not all objects can play the role
of a component object, i.e., there must be at least one aggregate that is not a compo-
nent. (The 0 allows an object to be created that is not part of another object. Such
an object must be an aggregate and not an independent component.)
… is a part of Ź 1..*
Component ? ¸ Aggregate
(a)
* 1..*
Ż contains
Citation
(is a part of Ź)
? ¸ Document
(b)
Fig. 4.9 The “is a part of” pattern, Case 2a, non-recursive—(a) generic model and (b) example
0..* component
Component-Aggregate Step |-
is a
m
component
¸ 0..*
aggregate
{ mandatory, disjoint } { An Operation object
is part of at least one part
b '
Task object. } of ź
is a part of Ź
Operation Task
¸0..* '
(a) (b)
Fig. 4.10 The “is a part of” pattern, Case 2a, recursive—(a) generic model and (b) example
Examples. A Citation object is a part of one or more Document objects but does
not exist outside of a Document, <*-to-1..*>? (see Fig. 4.9(b)). A Performance is
one of up to twenty performances that can be planned as a part of a Concert,
<0..20-to-1..*>?. The same performance can be planned for many concerts.
An Operation is part of one or more Task objects, any of which can be part of
one or more other Task objects, etc., until the highest level Task is reached, |-<0..*-
84 ORN FOR DATABASE APPLICATIONS
to-0..*>' (see Fig. 4.10(b)). This recursive association is modeled using the Compos-
ite design pattern (Gamma et al. 1995), which specializes the Component-
Aggregate class into a non-aggregate class, e.g., Operation, and an aggregate class,
e.g., Task. A Step must be an Operation or Task but not both. If a Task is de-
leted (explicitly or implicity), each component is deleted unless it is part of another
Task (or cannot be deleted because of an association with some other object, e.g., a
Task that was a component is required to define a WorkOrder object). Because of
the |- binding, a component can never be explicitly deleted but may be implicitly de-
leted by disconnecting it from its aggregate.
Variations. Though perhaps rare, an upper bound ≥ 2 can be given for the multi-
plicity at the aggregate end of the association. This limits the number of aggregates
that can contain a component.
Comments. The ?, |-, and ' bindings are necessary for the semantics of this pat-
tern.
The non-recursive version of this pattern is similar to the “is recorded for” Case 2
pattern; however, the “is recorded for” association type lacks the additional seman-
tics of the “is a part of” type, e.g., the notion of whole-part, which cannot actually be
expressed in ORN.
Association Patterns: Emerging from a Variety of Association Types 85
A component object can be part of multiple aggregate objects of the same type or
different types, via multiple “is a part of” associations, but can’t exist separate from,
i.e., independent of, an aggregate object. For each associationi between the Compo-
nent class and an Aggregatei class, where i = 1, 2, …, n and n ≥ 2, the ORN is
b<m-to-0..*>' where b includes |- if mL = 0. Aggregatej may be the same class as
Aggregatek where 1 ≤ j < k ≤ n. The model for the pattern is shown in Fig. 4.11(a).
m is a part of i ► 0..*
Component b ' ◊ Aggregatei
◄ contains 0..*
1..*
personalAddr
businessAddr
(is a part of 1 ►)
' ◊
Address 0..* 0..* PhoneBook
◄ contains
{ An Address is part
|-
(is a part of 2 ►)
' ◊
of at least one
PhoneBook or
1..* ◄ contains 0..*
MailingList
MailingList. }
(is a part of 3 ►)
' ◊
(b)
Fig. 4.11 The “is a part of” pattern, Case 2b—(a) generic model and (b) example
A component object can be part of only one aggregate, i.e., composite, object and
can also exist separate from, i.e., independent of, a composite object. If a composite
is deleted, all of its components are implicitly deleted. A component can be discon-
nected from its composite. The ORN for the association pattern is …-to-0..1>|!, and
the model is shown in Fig. 4.12(a).
… is a part of ► 0..1
Component |! ♦ Composite
(a)
* ◄ contains 0..1
Chip
(is a part of ►)
|! ♦ CircuitBoard
(b)
Fig. 4.12 The “is a part of” pattern, Case 3a—(a) generic model and (b) example
Examples. An actual Chip, one that you can hold in your hand, can be part of an
actual CircuitBoard, <*-to-0..1>|! (see Fig. 4.12(b)). If a circuit board is deleted, all
of the chips that it contains are implicitly deleted; however, a chip can be removed
("de-linked") from a circuit board. Destroying the link does not implicitly delete a
Chip object since the binding for the CircuitBoard is |!, versus !.
A Tire is part of an Automobile, <3..4-to-0..1>|!. An original, hardcopy Docu-
ment is part of a client's File, <*-to-0..1>|!.
Variations. Some revisions to the ORN may be desirable. A …-to-0..1>|- would
allow a composite to be deleted only if all components have been explicitly removed.
A StorageBin, for instance, can contain one or more Item objects, |-<0..1-to-*>
(inverse <*-to-0..1>|-) and should not be deleted until the items have been removed.
A …-to-0..1>|' would delete a composite if it contains components but would im-
plicitly delete a component only if its existence is not required by some non-“is a
part of” association with another object. A …-to-0..1>' would be like the previous
association but would also implicitly delete a component if it is detached from its
composite but again, only if its existence is not required by some non-“is a part of”
association with another object. If such existence is required, the component would
be allowed to be independent. (See the “consists of” association between units in
Figs. 1.24 (a) and 2.14 for an example of this latter variation.)
Comments. The |! binding is necessary for the normal semantics of the standard
pattern.
Association Patterns: Emerging from a Variety of Association Types 87
A component object can be part of only one aggregate, i.e., composite, object and
cannot exist separate from, i.e., independent of, a composite object. If a composite is
deleted, all of its components, will be implicitly deleted. If a component is detached
from its composite, the component is implicitly deleted. A component can be de-
tached from its composite and attached to another via a single operation. Also, a
component can be exchanged for another in a composite via a single operation: the
original component will be implicitly deleted. The ORN for the association pattern
is b<…-to-mL..1>! where b does not include an X- binding.
If the association is not recursive, mL = 1 and the model for the pattern is shown
in Fig. 4.13(a).
If the association is recursive,. mL = 0 and the model is shown in Fig. 4.14(a).
For a recursive association, the lower bound on the aggregate end is 0 since not all
objects can play the role of a component object, i.e., there must be at least one com-
posite that is not a component. (The 0 allows an object to be created that is not part
of another object. Such an object must be a composite.)
… is a part of Ź 1
Component b ! Ƈ Composite
(a)
1..* Ż contains 1
LineItem
(is a part of Ź)
! Ƈ Order
(b)
Fig. 4.13 The “is a part of” pattern, Case 3b, non-recursive—(a) generic model and (b) example
0..*
component
Component-Composite Element
{ Each File object is
is a
…
component
Ƈ 0..1
composite
{ mandatory, disjoint } part of a Directory
object. } part
of ź
b !
is a part of Ź
File Directory Ƈ0..1!
(a) (b)
Fig. 4.14 The “is a part of” pattern, Case 3b, recursive—(a) generic model and (b) example
In a file system, a File is a part of a Directory, which itself can be part of a Direc-
tory, etc., until a highest level or root Directory is reached, <*-to-0..1>! (see Fig.
4.14(b)). This recursive association is modeled using the Composite design pattern
(Gamma et al. 1995). A file system Element must be a File or Directory but not
both. A component of a Directory can be moved from one directory to another, but
cannot exist on its own.
Variations. Some revisions to the ORN may often be desirable. A …X-< …-to-
mL..1>! only allows a component to be detached from its composite (and implicitly
deleted) by exchanging it with a new component in a single operation. A <…-to
mL..-1>X-|! only allows a component to be detached from its composite by reattach-
ing it to another composite in a single operation. Perhaps more commonly desired, a
…X-< …-to- mL..1>X-|! makes an attachment permanent. A Room is a permanent
part of a Building, X-<*-to-1>X-|!.
Comments. The ! binding is necessary for the recursive version of this pattern.
Association Patterns: Emerging from a Variety of Association Types 89
When a programming language or a DBMS does not support an “is a” type of rela-
tionship, then the “is a” must be implemented as an association. In this situation, a
subclass object (though a separate object) “is a” superclass object. When a subclass
object is deleted, the related superclass object must be implicitly deleted; likewise,
when a superclass object is deleted, any related subclass object must be implicitly
deleted. Thus, the related objects are essentially treated as the same object.
0..1 is a i ► 1
SubClass i |! ! SuperClass
(a)
0..1 is a ► 1
Manager |! !
Employee
0..1 is a ► 1
SalesPerson |! !
(b)
Fig. 4.15 The “is a” pattern, Case 1—(a) generic model and (b) example
0..1 is a i ► 1
SubClass i |! X- X- |! SuperClass
0..1 is a ► 1
GradStudent |! X- X- |!
Student
0..1 is a ► 1
Undergrad |! X- X- |!
{ A Student object is linked to at least one
GradStudent or Undergrad object. }
(b)
Fig. 4.16 The “is a” pattern, Case 2—(a) generic model and (b) example
This section presents two examples to demonstrate the use of multiple association
patterns in database models and their implementation. The first example shows how
the “is associated by” pattern is used to remodel many-to-many associations, which
may have been modeled using other association patterns. Such remodeling is neces-
sary to implement many-to-many associations in relational databases and many-to-
Association Patterns: Emerging from a Variety of Association Types 91
is a part of Ź
2..* Ż is defined by *
Song ? ¸ CD
trackNo
Ļ
is associated by Ź Ż is associated by
is a part of Ź is a part of Ź
2..* Ż is defined by
Ż is defined by *
¸ Track ?
!
1 trackNo 1
!
Ƈ
Song { (Song, CD) is unique } CD
Fig. 4.17 Converting a many-to-many association using the “is associated by” pattern.
DBMS support—and has a job assignment that describes, in more detail than that of
the employee's job description, the expectations for the job currently assigned to the
employee, i.e., its duties and responsibilities. Multiple employees can share the same
job assignment, and employees are often given new assignments. Occasionally, the
company hires temporary workers. Job assignments may also be used to describe the
jobs for which these workers were specifically hired. Job assignments no longer ap-
plicable to any employee or temporary should not be recorded. The company en-
courages its employees to car pool and keeps track of existing carpools by having
employees register them and sign up for them. Occasionally, to keep the records up-
to-date, it surveys employees on their carpooling. Carpools should be removed when
ridership falls below two.
* belongs to Ź 0..1
' Temporary Carpool
(Ż is defined by)
źis hired for 2..15
rider
?
(Ÿ is recorded for) includes Ź
(Ż is a part of)
Ż is assigned * Employee
0..1 ' 0..1 |! *
(is recorded for Ź) parent
|- 1
worker
*
Ƈ child
works for Ź 1
Assignment { An Assignment is related to at least Unit
one Temporary or Employee. }
Three different association patterns, four in all, have been used in modeling the
above requirements as shown in Fig. 4.18. They are identified by the generic pattern
names given in parentheses. The “is recorded for” pattern is a Case 3, and the “is a
part of” pattern is a Case 3a. The association semantics resulting from the use of pat-
terns include the following (with the relevant generic object names, bindings, and
multiplicities given in parentheses):
• If an employee (defining object) is deleted or removed from a carpool (defined
object) and if the employee is one of just two riders in the carpool, the carpool
will be implicitly deleted (? and 2).
• If an employee (primary object) or temporary (primary object) is deleted or if a
job assignment (supporting object) is taken away from an employee or temporary,
then an attempt is made to implicitly delete the related job assignment (' for Em-
ployee and Temporary). This deletion is successful only if the assignment is not
that of another employee (implicit default binding and 1 for Assignment in “is
assigned”) or temporary (|- for Assignment in “is hired for”).
• If a unit (composite) is deleted, all descendant (component) units are implicitly
deleted (|!); however, the deletion of the primary unit will fail if any units have
employees working for them (default implicit destructibility and 1).
Association Patterns: Emerging from a Variety of Association Types 93
…
class Unit {
d_String name;
relationship Unit parent inverse children <*-to-0..1>|!;
// the “relationship” keyword is optional
Set<Unit> children inverse parent;
Set<Employee> workers inverse unit <1-to-*>;
...
};
class Carpool {
d_String id;
Set<Employee> riders inverse carpool;
...
};
class Assignment {
d_String code;
Set<Temporary> temporaries inverse assignment;
Set<Employee> employees inverse assignment;
...
};
class Employee {
d_String ssn;
Carpool carpool inverse riders ?<2..15 -to-0..1>;
Assignment assignment inverse employees '<*-to-1>;
Unit unit inverse workers;
...
};
class Temporary {
d_String ssn;
Assignment assignment inverse temporaries '<*-to-0..1>|-;
...
};
…
Fig. 4.19 ODDL implementation of model given in Fig. 4.18
In Fig. 4.19, the ORN for each modeled association is given for one of the two re-
lationship traversal paths (Cattel et al. 2000), or object-based attributes, that imple-
ments it. Here, the DDL is the ODDL of OR+, which is compatible to the Object
Definition Language (ODL) of the ODMG standard (Cattel et al. 1997). The ODML
of OR+ provides an APL for inserting, updating, and deleting objects in the ODDL-
94 ORN FOR DATABASE APPLICATIONS
defined object database. As these operations are performed, the semantics of the
ORN, and thus those of the association patterns, are automatically maintained by the
object DBMS. Database developers are spared the effort of having to develop and
maintain the complex methods that would otherwise be required to implement these
semantics.
…
CREATE TABLE Unit (
name VARCHAR(20) PRIMARY KEY
...
);
CREATE TABLE Carpool (
id VARCHAR(8) PRIMARY KEY
...
);
CREATE TABLE Assignment (
code CHAR(3) PRIMARY KEY,
...
);
CREATE TABLE Employee (
ssn CHAR(11) PRIMARY KEY,
...
carpoolId VARCHAR(8) CONSTRAINT belongsTo REFERENCES Carpool(id),
--+<> belongsTo ?<2..15-TO-0..1>;
assignCode CHAR(3) CONSTRAINT isAssigned REFERENCES Assignment(code),
--+<> isAssigned '<*-TO-1> ON UPDATE CASCADE;
unitName VARCHAR(20) CONSTRAINT worksFor REFERENCES Unit(name)
--+<> worksFor <*-TO-1>;
);
CREATE TABLE Temporary (
ssn CHAR(11) PRIMARY KEY,
...
assignCode CHAR(3) CONSTRAINT isHiredFor REFERENCES Assignment(code)
--+<> isHiredFor '<*-TO-0..1>|- ON UPDATE CASCADE;
);
In Fig. 4.20, the ORN for each modeled association is given for the foreign key
constraint that implements it. (In a relational context, classes essentially become ta-
bles and objects become rows.) Here, the DDL is T-SQL of SQL Server (Microsoft
Inc. 2005) supplemented by the --+<> statements of ORN Additive. After the T-
SQL is executed to create the database tables and constraints, the --+<> statements
are processed by an ORN Additive utility. This utility automatically generates the T-
SQL code that when executed creates the meta-data, triggers, and stored procedures
required to maintain the semantics of the ORN, and thus those of the association pat-
terns. The triggers are invoked when T-SQL queries insert, update, and delete rows
in the ORN-related tables. Here again, database developers are spared the effort of
Association Patterns: Emerging from a Variety of Association Types 95
having to develop and maintain the complex code needed to implement the associa-
tion patterns. In all, 3,976 lines of T-SQL code were generated by ORN Additive in
order to implement the associations given in Fig. 4.20 (though granted, the code is
well-commented and some code is generic rather than totally customized).
Before concluding this chapter, we should examine some associations that do not
conform to any of the association patterns described in Section 4.2. Obviously,
many such associations exist.
The first example is the “works for” association between the classes Employee
and Unit in Fig. 4.18. This association fits none of the patterns defined in Section
4.2. As is typical of many such associations, it involves a relationship between
classes that are relatively independent and on “equal footing,” which usually means
that they are both strong entity types, as defined by Chen (1976).
Another example is shown in Fig. 4.21. A professor “advises” zero or more stu-
dents. A student may or may not have been assigned a professor as an advisor. This
association, like the “works for” association involves strong entity types. Also, like
the “works for” association, it is defined with only default bindings, which is also
common for associations that fit none of the patterns defined in Section 4.2.
* ◄ advises 0..1
Student Professor
advisor
Fig. 4.22, on the other hand, shows an example of a non-pattern conforming asso-
ciation that is defined with a non-default binding. An object class defined in a CASE
tool may depend on one or more other object classes. The |- binding means that a
class cannot be deleted if any other classes are dependent on it. All dependent
classes must first be deleted or their dependencies must be removed.
But is this really a non-pattern conforming association? Or, does it indicate the
existence of another potential association pattern, a generic “is dependent on” asso-
ciation type between objects?
*
Class depends on ▼
|-
*
4.5 Conclusion
In this chapter we compare ORN to other declarative schemes for describing associa-
tion semantics. We examine schemes that have been proposed by others and ones
that have been generally adopted in current DBMSs. We also examine property
schemes that have been proposed for whole-part, i.e., “is a part of” type, relation-
ships. Our purpose is to better assess the relative simplicity, power, consistency, and
uniqueness of ORN and its scope. The chapter updates and extends the comparisons
made in Ehlmann and Riccardi (1996).1
In making the comparisons, we should recognize the following:
• A declarative scheme can never provide for all of the semantics that may be rele-
vant to a relationship. A language for specifying integrity rules with general con-
ditions and triggers is more powerful in expressing relationship semantics but is
also more verbose and less efficient in dealing with the specialized integrity rules
that define common types of relationships (Date 1981, Stonebraker et al. 1990).
Thus any declarative scheme represents a compromise and must be judged on its
capacity to provide the strongest semantics for the most common relationship
types with a minimum of syntax and conceptual complexity.
• Most semantic modeling schemes, including ORN, are developed mostly on prag-
matic grounds (Rundensteiner et al. 1994). Although syntax and concepts can be
invented to cover some apparent generic cases, no rigorous proof of “complete-
ness” can be given. Rather, the utility of a new scheme is shown by giving many
concrete examples of cases, e.g., real relationships, that are handled adequately by
the scheme, emphasizing those not adequately handled by existing schemes.
• ORN is defined at a conceptual level in terms of an ER or class diagram. Some of
the schemes to which ORN is compared are defined only in terms of a specific
logical model, the relational model or a type of object model. Although ORN can
be adapted to both relational and object models, as is shown in later chapters,
equivalent ORN specifications, when given, are given at a conceptual level.
The remainder of this chapter is organized into four sections. Section 5.1 com-
pares ORN to related declarative schemes for the relational data model and for rela-
tions in a proposed object model. Section 5.2 compares ORN to the declarative ca-
pabilities for describing relationship semantics that generally exist in an ODBMS.
Section 5.3 compares ORN to related declarative schemes that have been proposed
for the ER model. Section 5.4 describes how ORN relates to efforts to better define
1 Portions re-used, with permission, from “A comparison of ORN to other declarative schemes for
specifying relationship semantics,” Information and Software Technology 38, 7. © 1996 Elsevier.
A null integrity constraint on an attribute in a relational database states that its value
cannot be null. The availability of this constraint on foreign keys is assumed in Date
(1981) and Markowitz (1990). Disallowing null values for a foreign key is equiva-
lent to an ORN <multiplicities> specification of …-to-1 between the object type, or
class, represented by the referencing relation and that represented by the referenced
relation. The “…” implies that any <multiplicity> may be given. Allowing null val-
ues for a foreign key is equivalent to declaring a …-to-0..1 association.
For example, Fig. 5.1 shows relations implementing the “works for” relationship
between employees and units. A null constraint on the unit number attribute,
Comparing ORN to Similar Declarative Schemes 99
Relationship multiplicities are also indirectly specified for relations by the presence
or absence of key integrity constraints on foreign keys. These key constraints, real-
ized via the declaration of candidate and primary keys, which must be unique, are in-
tegral to the relational model. In Albano et al. (1991) they provide cardinality con-
straints for object class relationships represented as relations.
Declaring a foreign key as a candidate key in a relation is equivalent to declaring
a 0..1-to-… association between the object class represented by the referencing rela-
tion and that represented by the referenced relation. Not declaring a foreign key in a
relation as a candidate key is equivalent to declaring a *-to-… association between
these relations. A null constraint is assumed for a candidate key that is made a pri-
mary key. The unitNo attribute in relation Employee in Fig. 5.1 is not declared as a
candidate key and has a null constraint as shown. This is equivalent to a *-to-1 asso-
ciation between employees and units. If the unitNo attribute in relation Employee
was declared as a candidate key, then no two employees could have the same unitNo
value, i.e., work for the same unit, and thus the association between employees and
units would be 0..1-to-1. Finally, assume the following two relations:
W-4(ssn, noExemptions, …), FOREIGN KEY ssn REFERENCES Employee;
Employee(ssn, name, …), FOREIGN KEY ssn REFERENCES W-4, …;
1 ◄ is to a … … is for an ► 1
Unit Assignment Employee
Fig. 5.2 Class diagram with “works for” relationship represented using a separate associating class
Referential integrity in relational databases means that every non-null foreign key
value must match a primary key value in the referenced relation. In an object data-
base, referential integrity means that the values of all non-null, object-based attrib-
utes must reference objects in the database—that is, no dangling object references
can exist. Date (1981) proposes referential integrity rules that specify what should
be done when an operation is attempted that would violate referential integrity in a
relational database. These rules are given for each foreign key and provide addi-
tional relationship semantics. In Markowitz (1990) the rules are scaled back for rela-
tional databases generated from an ER model, and in Albano et al. (1991) they are
reduced and repackaged for relations representing relationships in the proposed ob-
ject data model. The following paragraphs discuss ORN equivalencies to Date's and
Albano’s referential rules, which are similar to those in standard SQL (ANSI 2008).
The inserting restricted rule is automatic and states that a tuple with a non-null,
unmatched foreign key value cannot be inserted into a relation. For example, a tuple
with a unitNo value of 03 cannot be inserted into an Employee relation, as defined
in Fig. 5.1, if there is no tuple with unitNo 03 in the Unit relation. The object data-
base equivalent of the inserting restricted rule is assumed by the in and owned_by
referential constraints given in Albano et al. (1991). (The are referential constraint
in Albano et al. (1991) assumes an "inserting cascades" rule but seems relevant only
to the implementation of an “is a” relationship.) These inserting rules are only
needed because of the way relationships are represented in relational and object da-
tabases, i.e., by references. They are not relevant to ORN, which describes relation-
ships at a conceptual level.
The UPDATING rules specify what should be done relative to a particular foreign
key when a primary key value is updated in a tuple of the referenced relation.
UPDATING rules are not relevant to object databases since objects are not refer-
enced by primary key values. Instead, they are referenced by object ids, which can-
not be updated. UPDATING rules are also not relevant to ORN since they do not
specify relationship semantics but instead pertain to maintaining the integrity of the
relationship representation in a relational database.
The DELETING rules (i.e., the ON DELETE referential actions in SQL) specify
what should be done when a tuple is deleted from a referenced relation.
The RESTRICTED option (i.e., RESTRICT in SQL) means that the delete fails
if matching tuples exist in the referencing relation. For example, in Fig. 5.1 deletion
of a Unit tuple with unitNo 03 fails if an Employee tuple exists with unitNo 03.
Comparing ORN to Similar Declarative Schemes 101
RESTRICTED is the default DELETING rule in Date (1981) but not in standard
SQL. It corresponds to the in referential constraint in Albano et al. (1991).
In ORN a |- binding on the class represented by referenced relation provides the
equivalent constraint. For example, a <*-to-0..1>|- association between employees
and units means that a unit cannot be deleted if it has an employee.
The NULLIFIES option (i.e., SET NULL in SQL) means that foreign keys in
matching tuples of the referencing relation are set to null when a tuple is deleted
from a referenced relation. For example, deletion of a Unit tuple with unitNo 03
sets the unitNo to null in all Employee tuples having unitNo 03. (This option
would obviously conflict with a null constraint on the foreign key.) DELETING
NULLIFIES has no corresponding referential constraint in Albano et al. (1991) since
object attributes in relations cannot be null.
In ORN the equivalent constraint is provided by a default implicit destructibility
binding and 0..1 multiplicity for the class represented by the referenced relation. For
example, if the relationship between employees and units is <*-to-0..1>, then dele-
tion of a unit causes the implicit destruction of all association links involving em-
ployees.
The CASCADES option (i.e., CASCADE in SQL) means that matching tuples in
the referencing relation are deleted when a tuple is deleted from a referenced rela-
tion. For example, deletion of a unit tuple with unitNo 03 deletes all Employee tu-
ples having unitNo 03. DELETING CASCADES corresponds to the owned_by
referential constraint in Albano et al. (1991).
In ORN, the equivalent constraint is provided by a |! binding for the class repre-
sented by the referenced relation. For example, if the relationship between employ-
ees and units is <*-to-0..1>|!, then deletion of a unit causes all related employees to
be deleted.
A NO ACTION option, which is not provided by Date (1981) but is by SQL,
means that no action is taken by the DBMS if matching tuples exist in the referenc-
ing relation. On transaction commit, however, if such tuples still exist, an exception
results. So, this option assumes that the application will somehow fix the problem
prior to commit. For example, deletion of a Unit tuple with unitNo 03 results in no
action if an Employee tuple exists with unitNo 03; however, if a referential integ-
rity violation is detected on the unitNo foreign key at transaction commit, an excep-
tion results. NO ACTION is the default ON DELETE action in standard SQL.
In ORN, an implicit default destructibility binding and 1 multiplicity on the class
represented by the referenced relation provides a similar constraint in that the check
for multiplicity violation is deferred until the commit of the complex object opera-
tion. For example, a <*-to-1> association between employees and units implicitly
destroys a link to a related employee on deletion of a unit; however, the deletion will
fail on commit of the complex object operation if the 1 multiplicity is still violated.
Setting RXC_mode before deleting a referenced object may also provide the system
action desired in that checks for lower bound violations are deferred until the commit
of the application-defined transaction.
102 ORN FOR DATABASE APPLICATIONS
Referential integrity and its associated rules do not address a very common relation-
ship constraint. In relational terms, this constraint for a foreign key asserts that a tu-
ple in the referenced relation must have at least one matching tuple in the referencing
relation. For example, a Unit tuple must have at least one Employee tuple with
matching unitNo, which implements a policy that every unit have at least one em-
ployee. The constraint may be unusual for the employees and units relationship, but
for other relationships it is not, e.g., a track in a detector is defined in terms of, i.e.,
must have, at least one subtrack. As with referential integrity, this constraint must
have associated rules specifying what must be done when an operation is attempted
that would violate it. In Albano et al. (1991) the onto and owns clauses provide
these rules and are collectively called surjectivity constraints—a term derived from
viewing relationships as functions (see Section 9.4).
Before discussing ORN equivalencies to onto and owns, we need to clarify some
things about surjectivity and our discussion. In Albano et al. (1991), surjectivity is
defined only for components of associations. An association corresponds to a rela-
tionship relation in the ER model or a class that represents an association in a class
diagram. For purposes of comparison, the discussion below treats surjectivity only
in the context of such an associating class. Examples are based on the units and em-
ployees relationship, as represented in Fig. 5.2 by the class Assignment. As indi-
cated in the previous paragraph, however, surjectivity is relevant for relationships
represented as foreign keys in relational databases, e.g., unitNo in relation Em-
ployee, and as object-based attributes in object databases, e.g., a Unit object-based
attribute in class Employee. ORN provides surjectivity for such attributes in gen-
eral, not just for those in associating classes, like Assignment.
As with referential integrity, an inserting restricted rule is automatic for surjectiv-
ity and is assumed when onto or owns is specified for an association component.
For example, if such is the case for the Unit component of an Assignment associa-
tion, then a Unit object x cannot be inserted into the Unit component class unless a
tuple referring to x exists in the Assignment association. The equivalent of surjec-
tivity in ORN is specified by a lower bound multiplicity of 1 for the associating
class. For example, if the relationship between units and assignments is 1-to-1..*,
then a Unit object cannot be inserted into a database unless it is linked to an As-
signment object.
In Albano et al. (1991), whether the onto or the owns clause is specified for a
component of an association indicates what should be done when a tuple is deleted
from an association.
Specifying onto indicates that the delete fails if the tuple deleted is the only one
referring to an object of the component class (unless this object is also removed in
the same transaction). For example, an onto specified for the Unit class component
of an Assignment association would mean that deletion of an Assignment tuple
referencing a Unit object x would fail if it is the only Assignment tuple referencing
x (unless x is also removed). In ORN the default implicit destructibility binding for
the associating class provides an equivalent constraint. For example, if the relation-
Comparing ORN to Similar Declarative Schemes 103
ship between units and assignments was <1-to-1..*>, then an Assignment object
whose related Unit is x cannot be deleted if it is the only Assignment object related
to x, i.e., if its deletion (actually, the required implicit relationship destruction) vio-
lates the 1..* multiplicity.
Specifying owns indicates that the delete of an association tuple causes the auto-
matic deletion of the component class object if the tuple deleted is the only one refer-
ring to the object. For example, an owns specified for the Unit class component of
the Assignment association would mean that deletion of an Assignment tuple ref-
erencing Unit object x causes the deletion of x if it is the only Assignment tuple ref-
erencing x. In ORN the |? binding for the associating class provides an equivalent
constraint. For example, if the relationship between units and assignments was <1-
to-1..*>|?, then the deletion of the only Assignment object related to an Employee
object x causes the deletion of x since the deletion violates the 1..* multiplicity.
As previously stated, the default implicit destructibility binding along with a lower
bound multiplicity of 1 for an associating class provides an equivalent in ORN to the
onto surjectivity constraint. The |- binding provides an additional and stronger sur-
jectivity rule for deletion. A <1-to-1..* >|- instead of a <1-to-1..*> association be-
tween units and assignments, for example, means that an assignment can never be
deleted. (A !<1-to-1..* >|- association would delete an assignment implicitly as a re-
sult of deleting the related unit or destroying the association between a unit and an
assignment.)
The constancy constraint proposed in Albano et al. (1991) makes a relationship
indestructible. In ORN, if the associations between units and assignments was <1-
to-* >- (i.e., <1-to-*>|-X-) and that between employees and assignments was <1-to-
0..1>-, then an Assignment object can never be deleted and the relationship be-
tween a unit and an employee via an Assignment object once established can never
be destroyed or changed.
In OR+ (see Chapter 7), an X- constraint is implemented for a class independent
of any association. (This X- is not the X- binding.) It indicates that class objects
once created cannot be explicitly destroyed, i.e., deleted. If X- was specified for the
Assignment class and if the associations between units and assignments was !<1-to-*
>X-) and that between employees and assignments was !<1-to-0..1>X-, then again
the relationship between an employee and a unit via an assignment object once estab-
lished can never be explicitly destroyed; however, it is now implicitly destroyed
when the related employee or project is deleted.
Suppose an employee was required to work for more than one unit. To make this
a bit more realistic, suppose an employee was required to be involved in at least
three projects. This many-to-many relationship is modeled in Fig. 5.3. The relation-
ship between assignments and employees is <3..-to-1>!. Here, the deletion of one of
only three assignments for an employee would fail. If the association was |?<3..-to-
104 ORN FOR DATABASE APPLICATIONS
1>!, then the deletion of one of only three assignments for an employee would delete
the employee. These types of surjectivity constraints are possible only when a de-
clarative scheme for specifying relationship semantics is based on multiplicities.
The "must have at least one" constraint for surjectivity as defined in Albano et al.
(1991) should be seen as just a special case of a more general surjectivity.
1 1
◄ is to a … 3..* is for an ►
Project ! Assignment ! Employee
Fig. 5.3 Class diagram for many-to-many relationship between projects and programmers
In Albano et al. (1991), different surjectivity constraints can be given for the sub-
classes of a component class in an association. For example, the Employee compo-
nent in the Assignment association could have no surjectivity constraint while a
Programmer, who “is a” Employee, could have an onto constraint. This would
implement a policy that allows an employee in general to have no assigned project
but requires a programmer to have at least one. This capability can be achieved us-
ing ORN by defining an association specifically for a subclass that has the desired
multiplicity and binding on the associationg class, e.g., a <1..*-to-1> association be-
tween Assignment and Programmer .
Finally, the semantics of the ' binding in ORN, although seemingly similar to the !
binding, are quite unique. These semantics, in combination with appropriate multi-
plicities and other bindings, facilitate shared “subordinate” objects among “prime”
objects from either the same or different classes and implement an automatic garbage
collection mechanism.
* 0..1
records ►
Employee ' |- Doctor
primaryPhysican
Fig. 5.4 Class diagram for association between employees and doctors
To illustrate, consider the relationship between employees and doctors in Fig. 5.4.
An employee optionally “records” a doctor as his or her primary physician. Re-
corded attributes for a doctor may be name, office address, and phone number. The
relationship is '<*-to-0..1>|-. The |' aspect of the ' binding means that if an employee
x is deleted, any association with a doctor is implicitly destroyed and an attempt is
made to implicitly delete the related doctor. If the doctor is also recorded for another
employee, i.e., if there exists an association between the doctor and another em-
ployee, the doctor is not deleted since the |- binding does not allow implicit destruc-
tion of this association. The deletion of employee x, however, is allowed since the
destruction of an association link with his/her doctor does not violate the * multiplic-
ity. A doctor is implicitly deleted only if the doctor is no longer recorded for any
employee. Similar semantics apply to the explicit destruction of the link between an
Comparing ORN to Similar Declarative Schemes 105
employee and a doctor, where the X' aspect of the ' binding is operative. In a sense,
the ' binding provides for the garbage collection of doctors! (A doctor can never be
explicitly deleted if recorded for any employee because of the |- binding.)
It is unclear how the semantics of this type of relationship can be described by the
other declarative schemes discussed in this section.
ORN may also be compared to extensions to the ER model that have been suggested
by others in order to specify or enforce association semantics, or structural integrity
constraints. These extensions, however, are less declarative and more procedural in
nature. Thus, while they are cited and briefly described below, no detailed compari-
sons are made with ORN.
Lazarevic and Misic (1991) extend entity and relationship types with constraints
concerning actions that can or should be associated with different update operations.
The actions indicate whether an update is to be restricted or should invoke more up-
dates to enforce cardinalities. The constraints are intended to be used for the algo-
rithmic design of integrity preserving update procedures.
Bouzeghoub and Metais (1991) allow the specification of more generalized integ-
rity constraints and behavioral rules on the ER model. The behavioral rules provide
for actions to be specified in the conclusion part that can enforce integrity rules. The
constraints and rules are translated into enforcement constraint methods within an
object database schema.
Finally, Balaban and Shoval (2000) build on these ideas by extending an en-
hanced ER model with structure methods to specifically enforce cardinality con-
straints. Templates for various structure methods are given that are built on top of
primitive update methods that perform all update transactions. A user specifies asso-
ciation semantics by deciding among various processing options at certain points
within the template code, e.g., reject an update or propagate an insert or delete to en-
force a cardinality constraint.
ORN capabilities. It then points out the importance of some ORN capabilities not
provided by these systems.
What is generally provided by existing ODBMSs and reflected in the ODMG 3.0
object database standard (Catel 2000) is support for one-to-one, one-to-many, and
many-to-many associations; referential integrity; and the automatic maintenance of
inverse attributes. In terms of ORN, this is equivalent to supporting <0..1-to-0..1>,
<0..1-to-*>, and <*-to-*> associations. Support for referential integrity means that
on object deletion, all references to that object are automatically set to null or re-
moved from object-based attributes, i.e., relationship traversal paths in ODMG 3.0.
This is equivalent to the DELETING NULLIFIES referential integrity rule of Date
(1981) and the default implicit destructibility bindings in ORN. The automatic main-
tenance of inverse attributes means that when changes are made to an object-based
attribute, the system automatically updates the inverse attribute to reflect the change.
This referential action is required to maintain the integrity of the representation of
associations in an object database and has nothing to do with relationship semantics.
Some of the ODBMSs cited above, though not the ODMG 3.0 standard, also sup-
port a simple delete propagation capability. This is specified as an option for an ob-
ject-based attribute, e.g. the macro parameter os_propagate_delete on the macro
that defines an object-based attribute in Object Store. The semantics of simple delete
propagation are that all objects referenced by the object-based attribute of an object
are automatically deleted when the object is deleted. Delete propagation may cas-
cade so that, for example, a whole part assembly is deleted when the main part is de-
leted. Delete propagation was added to ODBMSs to better support composite ob-
jects, i.e., the “is a part of” relationship. A variety of such relationships can be
specified in ORN by employing any of the cascade bindings: ~?, ~!, or ~', where the
~ symbol is optional. The binding equivalent to the simple delete propagation avail-
able in some ODBMSs is the !.
Fig. 5.5 illustrates the use of the ! binding in a !<0..1-to-*> association between
parts. Deleting a Part object results in the automatic deletion of the entire assembly,
i.e., subtree, of parts having the explicitly deleted part object as its root.
0..1 assembly
!
Part is a part of ▲
* component
Support for the more precise multiplicity constraints of class diagrams and ORN
is not available in most ODBMSs. These constraints are important in maintaining
database integrity. Without them, integrity is at the mercy of code that is developed
and maintained by database programmers. For example, in an object database, a <1-
to-*> specification for the “works for” association, would (if it could be given) en-
sure that an employee always belongs to a unit and would cause an exception when
Comparing ORN to Similar Declarative Schemes 107
Much effort has been devoted to understanding the “is a part of” relationships that
often exist between objects. These relationships are often referred to as whole-part
relationships. The aggregation and composition associations that can be defined in
UML class diagrams are whole-part relationships. There has been much discussion
and disagreement about what semantics, i.e., characteristics or properties, distinguish
whole-part associations from other associations, what properties categorize whole-
part associations into different types, and even what these properties mean (e.g., Al-
108 ORN FOR DATABASE APPLICATIONS
bert et al. 2003, Barbier et al. 2003, Civello 1993, Henderson-Sellers and Barbier
1999, Odell 1994, Saksena et al. 1998, Snoeck and Dedene 2001, Winston et al.
1987). Some have argued that the UML specifications are ambiguous in defining
aggregate and composition association types (e.g., Barbier et al. 2003, Henderson-
Sellers and Barbier 1999). While declarative schemes have not been proposed for
many of the semantics ascribed to whole-part associations, Albert et al. (2003) pro-
poses some declarative properties that can be specified in class diagrams to supple-
ment the white and black diamonds and better facilitate the generation of object-
oriented code tailored to implement the modeled associations.
In this section we briefly examine some of the many properties that have been at-
tributed to whole-part associations, many of which are applicable to all types of as-
sociations. The discussion for each property will:
• list within parentheses some of the different terms that have been used to describe
it or its inverse;
• define its meaning and values in as precise yet uncontroversial manner as is pos-
sible;
• indicate whether a specific property or property value has been proposed as a
primary characteristic for whole-part relationships (Saksena et al. 1998, Hender-
son-Sellers and Barbier 1999), which means that it along with other primary char-
acteristics distinguish a whole-part association from other associations;
• describe its relevancy to database implementation,
• indicate how the semantic described by the property relates to ORN and provide
an equivalent ORN representation if possible, and
• perhaps raise some issues.
More detail on each property is available in the above referenced papers.
I begin with the properties proposed in Albert et al. (2003), which are called associa-
tion dimensions. For these properties, I give the permissible values using the pro-
posed UML stereotype notation and give the required and default values intended to
better distinguish aggregation, composition, and normal associations in UML class
diagrams.
Multiplicity is the same as that defined by UML and ORN. In Albert et al. (2003),
the multiplicity defaults to and must be 1..1 for the composite end of a composition.
Interestingly, this requirement eliminates the possibility of a component ever existing
independent of a composite, which UML allows. There is no default multiplicity for
association ends that are not composite ends.
Reflexivity (inverse irreflexivity) indicates for an association whether an object
can be linked to itself, i.e., whether object a “relates” to object a is allowed. The
value «Reflexive» means it is allowed, and «Nonreflexive» means it is not. These
stereotypes are placed in a class diagram near an association name. The value de-
Comparing ORN to Similar Declarative Schemes 109
faults to and must be «Nonreflexive» for shared aggregation and composition, and
the default value is «Reflexive» for all other associations. Irreflexivity, i.e., a re-
flexivity of nonreflexive, is a commonly agreed upon primary characteristic of a
whole-part association. Irreflexivity imposes a database constraint. For associations
between objects of the same type (i.e., object instances of the same class), the DBMS
must check at runtime to ensure that an object is not linked to itself. For other asso-
ciations, type checking in the DML or programming language usually ensures such
linkage is not possible and so reflexivity is really not an issue. The reflexivity se-
mantic is orthogonal to and thus does not conflict with ORN semantics, which are
relevant only to multiplicities and the destructibility of links.
Antisymmetry indicates for an association whether object b “relates to” object a is
allowed when a “relates to” b. «Not Antisymmetric» means it is allowed, and «An-
tisymmetric» means it is not. These stereotypes are placed near an association
name. The value defaults to and must be «Antisymmetric» for shared aggregation
and composition, and the default for all other associations is «Not Antisymmetric».
Antisymmetry is another commonly agreed upon primary characteristic of a whole-
part association. Antisymmetry imposes a database constraint. For associations be-
tween objects of the same type and when link representation is supportive (which it
is often not), the DBMS must check at runtime to ensure that b is not related to a
when a relates to b. For other associations, type checking usually ensures this is not
possible and so antisymmetry is really not an issue. The antisymmetry semantic is
orthogonal to ORN semantics.
Visibility (inverse encapsulation) indicates for an association end whether objects
can be accessed independent of (i.e., are not encapsulated in) related objects. The
value «Visible» means objects can be accessed independent of related objects, and
«Not Visible» means they cannot. The stereotypes are placed near an association
end. The value defaults to and must be «Visible» for the composite end of a compo-
sition and «Not Visible» for the component end. The default value is «Visible» for
all other association ends. (It is problematic that the value must be «Visible» for a
composite since a composite may be a component in another composition.) This
property affects how the association is represented in a database and accessed in the
DML. The visibility semantic is orthogonal to ORN semantics.
Identity Projection (exclusiveness, nonshareability, inverse shareability) indicates
for an association end whether an object at that end projects its identity onto its re-
lated object (i.e., whether the related object cannot be shared with another object).
The value «Projected» means an object projects its identity (i.e., a related object
cannot be shared), and «Not Projected» means the opposite. The stereotypes are
placed near an association end. The value defaults to and must be «Projected» for
the composite end of a composition and «Not Projected» for the component end.
(Based on UML specifications, a white diamond implies «Not Projected» for the
aggregate end of a shared aggregation, i.e., implies that components are shareable;
however, Albert et al. (2003) apparently allows “shared aggregate” components to be
specified as nonshareable.) As defined in Albert et al. (2003), identity projection for
an association end imposes a database constraint, which in ORN can be specified by
an upper bound multiplicity of 1 for that end; however, this identity projection does
110 ORN FOR DATABASE APPLICATIONS
not include the “global exclusiveness” that is required by UML composition (OMG
2005, Barbier et al. 2003). Global exclusiveness means that not only can a compo-
nent object not be shared by objects of a specific composite class, it also cannot be
shared by objects of any related composite class. Such exclusiveness imposes an ad-
ditional database constraint, which cannot be specified by multiplicities.
Temporal Behavior indicates for an association end whether objects at that end
can be dynamically linked to or delinked from related objects. The value «Dy-
namic» means that they can throughout the whole life of an object, and the value
«Static» means that such linking and delinking can only occur during the creation of
an object. The stereotypes are placed near an association end. The value defaults to
and must be «Static» for the component end of a composition, which forces the
creation and linkage of components to be done via the composite class. The default
value is «Dynamic» for all other association ends. A value of «Static» seems to
impose a database constraint that disallows the creation and destruction of links by
the DBMS once an object is created; however, Albert et al. (2003) does not make
clear whether link destruction is altogether disallowed when one end of an associa-
tion is specified as «Static» and the other end is specified as «Dynamic». Temporal
behavior specifications may have more to do with which class controls link creation
and destruction, i.e., the ownership of objects, in an object-oriented implementation
rather than whether or not these operations are disallowed.
Equivalent semantics likely cannot be specified by ORN, although somewhat
similar semantics are available. For an association defined between a class (or role)
S and a related class (or role) (see Table 2.1), a 1-to-… association means that a re-
lated object, e.g., a component, must be linked to an S object within the transaction
in which the related object is created. A X-<1-to-… association means that once a
link is created, it cannot be explicitly destroyed, although the S object in the link can
be exchanged with another. A X-<1-to-…>X- association means that once a link is
created, it cannot be explicitly destroyed or changed in any way.
Delete Propagation indicates for an association end what actions, regarding links
to related objects, are required when an object at that end is deleted. The value
«Restrictive» means an object cannot be deleted if it has links to related objects,
«Cascade» means that existing links and related objects must be deleted, and
«Link» means that only existing links are deleted (but related objects remain). The
stereotypes are placed near an association end. The value defaults to and must be
«Cascade» for the composite end of a composition. The default value is «Link»
for all other association ends. The delete propagation property defines referential ac-
tions that must be done by the DBMS. For a class (or role) S in an association with
a related class (or role) (see Table 2.1), a «Restrictive» value given for delete
propagation is equivalent to a |-<m-to-… association in ORN where m is the multi-
plicity for S. A «Cascade» value is equivalent to a |!<m-to-… association, and a
«Link» value is equivalent to a <0..mU -to-… association where mU is some upper
bound multiplicity. «Link» cannot be specified for an association end if the lower
bound multiplicity at that end is not 0.
This completes our examination of the association properties and notation pro-
posed by Albert et al. (2003). Now, we turn our attention to some of the other prop-
Comparing ORN to Similar Declarative Schemes 111
erties that have been discussed by others in addressing aggregation, composition, and
whole-part relationships in general.
We begin with the properties that help set whole-part relationships apart from normal
associations. Hypothetically, if all primary characteristics are true for an association,
then the association is a whole-part association.
The whole-part property indicates for an association that it is a binary association
where one end of the association plays the role of a whole and the other the role of a
part (Barbier et al. 2003). Like all of the subsequent properties we examine, whole-
part is itself a characteristic in that its value is true or false. Of course, whole-part
can be specified in a class diagram by representing an association as a binary asso-
ciation and properly placing role names whole and part at the opposite ends of the
association. Alternatively, one could just place a diamond at the whole end of the
association, although Barbier et al. (2003) argues that aggregation as defined in
UML does not encompass all types of whole-part relationships. Obviously, whole-
part is a primary characteristic of a whole-part association. Independent of the other
primary characteristics, it provides the semantic that objects playing the role of part
are somehow “connected” to objects playing the role of whole to form an “aggregate
whole.” This semantic cannot be enforced by the DBMS and is orthogonal to ORN
semantics.
An emergent property characteristic means for an association that each whole ob-
ject has a property that emerges from its parts yet is independent of the properties of
its parts. All whole-part relationships must have at least one emergent property ac-
cording to Kilov and Ross (1994), Saksena et al. 1998, and Henderson-Sellers and
Barbier (1999). For example, an emergent property of a bicycle is that it can be rid-
den. This property stems from the assembly of its parts yet cannot be deduced or de-
rived from the properties of its individual parts. This semantic cannot be enforced by
the DBMS and is orthogonal to ORN semantics. It may likely be that there is no rea-
son to store an emergent property in the database.
A resultant property characteristic means for an association that each whole ob-
ject has a property that results from its parts and is dependent on the properties of at
least a subset of its parts and can be derived from these parts. All whole-part rela-
tionships must have at least one resultant property according to Kilov and Ross
(1994), Saksena et al. 1998, and Henderson-Sellers and Barbier (1999). For exam-
ple, a resultant property of a bicycle is its weight, which can be derived from the to-
tal weight of each of its parts. This semantic can be somewhat enforced by the
DBMS if it requires the database designer to define a derived attribute for each
whole whose derivation requires access to some of its parts; however, again it may
be that there is no interest in storing such an attribute in the database. This semantic
is orthogonal to ORN semantics.
112 ORN FOR DATABASE APPLICATIONS
means that an object a’s existence is dependent on its relation to an object b (e.g.,
Barbier et al. 2003) without indicating what should be done if b is deleted. This de-
pendency is simply represented by ensuring that the lower bound multiplicity is
greater than or equal to 1 at the b end of the association. This means that existential
dependency as a property is redundant and is simply a multiplicity constraint that the
DBMS should enforce. In ORN, this constraint is given as an …-to-mL..mU associa-
tion between a and b where mL ≥ 1, although mL..mU is usually 1..1.
Now, if a’s existence is dependent on a relationship with b, what should be done
when b is deleted? This is where delete propagation comes into play. A «Restric-
tive» value for delete propagation in Albert et al. (2003) would not allow the dele-
tion of b and a «Cascade» value allows the deletion of b but implicitly deletes a. A
«Link» value allows the deletion of b, destroys its link with a, and allows a to re-
main, and thus this value is incompatible with existential dependency. We have al-
ready seen the ORN equivalencies for these values.
We should note that Albert et al. (2003) does not provide for the case where an
object in an association can be related to multiple objects but is dependent on being
related to a minimum number for its existence—i.e., for a …-to-mL..mU association,
mL ≥ 1 and mL.>.mU. For example, a family must have at least two people but can
have more. If we do not want to allow the deletion of a person if the family’s exis-
tence is dependent on this person, i.e., a “«Restrictive»-like propagation,” then the
proper ORN for the relationship between families and persons is <…-to-2..*>. If we
want the family deleted when membership falls below two because of the deletion of
a person, i.e., a “«Cascade»-like propagation,” then the proper ORN is <…-to-
2..*>|?.
Separability, mutability (changeability, variance, inverse immutability and invari-
ance), and lifetimes are properties that are closely related. They are also related to
temporal behavior as defined in Albert et al. (2003) and existential dependency. Ex-
actly how these properties relate to each other and the clarity of their use in UML
specifications has been much discussed. These issues are not debated here and no
position is taken. Briefly, separability means that parts can be separated from the
whole and mutability means that the relationships between wholes and parts can be
changed. These properties have been applied to both associations and association
ends. The lifetimes property indicates how the lifetimes of the whole and its parts
overlap. As previously shown, the X- binding in ORN at one or both ends of an as-
sociation specifies the destructibility of association instances, i.e., separability, and
the changeability of association instances once created. Other bindings specify
whether related objects must live or die when attempts are made to kill objects or de-
stroy the links between them.
5.5 Conclusion
Based on the comparisons given in this chapter and the examples given in the previ-
ous chapter, ORN can be seen as a practical declarative scheme that facilitates the
114 ORN FOR DATABASE APPLICATIONS
ORN Additive
A Tool for Extending SQL Server with ORN
ORN Additive for Transact-SQL (T-SQL) adds ORN to Microsoft SQL Server (Mi-
crosoft 2005). The “additive” increases the productivity of developing database sys-
tems and improves data integrity in these systems. With ORN Additive, implemen-
tation is easier as database models more directly map to the required DDL statements
of T-SQL. More specifically, relationships can be defined in .sql files with the mul-
tiplicities and bindings given in UML class diagrams. These multiplicities and bind-
ings are then automatically enforced by the database system as database changes are
made using an ORN-extended T-SQL. ORN Additive was developed to show the
feasibility of defining associations to an RDBMS using ORN. SQL Server was cho-
sen because T-SQL provides INSTEAD OF triggers and transaction processing op-
erations within these triggers. These capabilities are crucial to implementing ORN.
Although ORN Additive was developed as a prototype, it can be a very produc-
tive tool for developing many relational database applications. Many lines of T-SQL
code, involving complex triggers and stored procedures, are automatically generated
by the tool. This code would otherwise have to be painstakingly implemented,
tested, and maintained by database developers. The complete ORN Additive tool,
including the ORN Additive for Transact-SQL User’s Guide, can be downloaded
from the author’s website at the URL given in the Preface. The user’s guide pro-
vides all of the technical details for installing and using the tool.
This chapter provides an overview of ORN Additive, first discussed in Ehlmann
(2007). It is partially based on this paper1 and the ORN Additive user’s guide. Sec-
tion 6.1 examines ORN Additive capabilities, operation, and architecture. Section
6.2 examines ORN Additive DDL statements, which extend the DDL type state-
ments of T-SQL. Section 6.3 examines ORN Additive DML statements, which ex-
tend the DML type statements of T-SQL. Section 6.4 concludes by summarizing the
benefits and limitations of the modeling and implementation approach made possible
by ORN Additive and by indicating how the limitations can be overcome.
The ORN Additive tool consists of a DDL utility and a DML utility. This section
briefly describes how these utilities essentially add ORN to SQL Server.
1Portions reprinted, with permission, from “ORN Additive: shrinking the gap between database
modeling and implementation,” Proc ICIS Conf, IEEE Computer Society, 555-560. © 2007 IEEE.
6.1.1 Capabilities
The DDL utility is a postprocessor that processes ORN Additive DDL statements,
i.e., --+<> statements, which supplement DDL-type T-SQL statements that define a
database. (The + indicates addition and the <> recalls the diamonds in an ER dia-
gram and the way relationships have been traditionally defined in data models.) The
--+<> statements may be interspersed as comments within T-SQL statements (see
Fig. 6.1) and are processed by the DDL utility after the T-SQL statements have been
executed. What results is a defined ORN-enhanced database, i.e., one where <as-
sociation>s have been given for foreign keys.
USE CompanyDB;
--+<> USE CompanyDB;
CREATE TABLE Carpool (
id VARCHAR(8) PRIMARY KEY,
...
);
CREATE TABLE Employee (
ssn CHAR(11) PRIMARY KEY,
...
carpoolid VARCHAR(8) CONSTRAINT belongsTo REFERENCES Carpool(id),
--+<> belongsTo ?<2..15-TO-0..1>;
);
GO
Fig. 6.1 Example of T-SQL query file including two ORN Additive DDL statements
The DML utility is a preprocessor that processes ORN Additive DML statements,
i.e., +<> statements. These statements extend DML-type T-SQL statements that
specify the USE of an ORN-enhanced database and provide explicit transaction
processing within queries that modify the database. The +<> statements are inter-
spersed with T-SQL statements as needed (see Fig. 6.2) and are processed and trans-
lated into T-SQL statements before the query file is executed.
The DDL utility generates T-SQL statements based on the given ORN Additive
statements and the metadata views that define the database. The generated T-SQL
statements when executed add objects to the database, e.g., triggers, which support
the enhanced capabilities provided by the ORN-defined relationships. These capa-
bilities become apparent when queries are executed that affect relationships—i.e.,
that insert rows, delete rows, and update primary and foreign keys.
ORN Additive: A Tool for Extending SQL Server with ORN 119
The steps in using ORN Additive to develop a database system are given below.
These steps can be seen in Fig. 6.3, which shows the architecture and data flow for
the use of ORN Additive with SQL Server.
1. Develop and execute the required DDL-type T-SQL statements to define the da-
tabase (or alter an existing database). For tables that are to be related by relation-
ships defined by ORN, i.e., ORN-related tables, ensure that:
• All foreign keys in the table are defined by named constraints.
• No ON DELETE or ON UPDATE clause is given for these constraints.
• No NOT NULL constraint is given for any foreign key column.
2. Once the database has been defined to SQL Server, develop a query file contain-
ing ORN Additive statements, i.e., --+<> statements, that provide the ORN, e.g.,
<*-to-1>, for the foreign key constraints. Process this query file using the ORN
Additive DDL utility (+ornddl). (Note that since the ORN Additive statements
are “structured comments,” they can be appropriately interspersed within, i.e.,
added to, a .sql file containing the T-SQL statements developed in Step 1.)
When no errors are found by the DDL utility, three query files are generated:
• an ORN primer file, ORN_Primer.sql
• an ORN additive file, ORN_AdditiveFor_database_name.sql
• an ORN header file, ORN_HeaderFor_database_name.sql
3. Execute the ORN primer file to “prime” SQL Server for ORN Additive. Execut-
ing this file defines ORN Additive error messages to SQL Server and stores ORN
system stored procedures in a database, which is referenced as the “ORN sp Data-
base” in Fig. 6.3 and is the master database by default. This step need only be
done once for an SQL Server instance.
4. Execute the ORN additive file to provide for subsequent database operations
based on your ORN-defined foreign keys. Executing this file adds metadata as
well as a number of triggers and stored procedures to the database.
5. When developing T-SQL queries that Insert rows into, Delete rows from, and/or
Update rows in ORN-related tables, i.e., IDU queries, do one of the following:
a) If the IDU query is a simple IDU query, i.e., it doesn’t use explicit transac-
tions on ORN-related tables and uses just one ORN-enhanced database, copy
& paste the ORN header file (from Step 2) to the beginning of the IDU query.
b) If the IDU query is not a simple IDU query, use appropriate ORN Additive
statements (+<> USE database, +<> BEGIN TRAN, +<> SAVE TRAN,
+<> COMMIT TRAN, and +<>ROLLBACK TRAN) in place of the corre-
sponding T-SQL statements. Save these IDU query files as .sql+ files and
process them using the ORN Additive DML utility (+orndml). This utility
creates a .sql file when no errors are encountered. This .sql file is the same
as the .sql+ file except that the ORN header is included and ORN Additive
120 ORN FOR DATABASE APPLICATIONS
Fig. 6.3 Architecture and data flow for the use of ORN Additive with SQL Server
ORN Additive: A Tool for Extending SQL Server with ORN 121
The +ornddl command executes the ORN Additive DDL (+ornddl) utility. This
utility “postprocesses” ORN Additive DDL statements, i.e., statements beginning
with --+<>, in order to add ORN notation to the referential constraints defined for an
SQL Server database. The input file is a query, i.e., .sql, file that usually also con-
tains T-SQL DDL-type statements that have been previously processed to create the
database. When +ornddl finds no errors, the ORN primer file, ORN additive file,
and ORN header file are generated in the directory of the input query file.
Table 6.1 summarizes the options that can be given in the +ornddl command.
More detail, including all option defaults, are given in the ORN Additive user’s
guide. Some examples of the +ornddl command are given below.
+ornddl –U MyUserId –P MyPassWrd
+ornddl –i create_tables.sql –np –dGB –sp globalSysProcsDB
+ornddl –U smithJB –P snoppy02 –S coServer\sys3 –i defineDB.sql -so
Option Description
-U Allows a user login id to be given in order to connect to the SQL Server. By de-
fault Microsoft Windows Authentication mode is used.
-P Allows a user password to be given.
-E Specifies that a trusted connection be used to log in to the SQL Server.
-S Specifies the instance of SQL Server to which to connect.
-i Identifies the input query file to be processed.
-so Specifies syntax only, meaning that no output files will be generated.
-np Specifies that no ORN primer file be generated.
-dGC Specifies debug Generated Code, meaning that Print statements will be in-
cluded in the ORN Additive file to allow tracing of generated code execution.
-sp Specifies the name of the sp database that will be used to store ORN system
generated stored procedures. By default this is the master database.
-v Specifies that the version number of +ornddl be displayed.
-? Specifies that the syntax of the +ornddl command be displayed.
The +orndml command executes the ORN Additive DML (+orndml) utility. This
utility preprocesses ORN Additive DML statements, i.e., statements beginning with
+<>, that are interspersed between T-SQL statements in a query file. These ORN
Additive statements are required to enforce the semantics of ORN-defined foreign
keys. More specifically, these statements must be used in IDU queries when explicit
transactions are used to insert into, delete rows from, or update rows within ORN-
related tables. They must also be used when ORN-related tables from multiple
ORN-enhanced databases are being changed within a transaction.
122 ORN FOR DATABASE APPLICATIONS
Table 6.2 summarizes the options that can be given in the +orndml command.
More detail, including all option defaults, are given in the ORN Additive user’s
guide. Some examples of the +orndml command are:
+orndml –U MyUserId –P MyPassWrd
+orndml –i updOrder.sql+ –sp globalSysProcsDB
+orndml –U smithJB –P snoppy02 –S coServer\sys3 –o test2.sql -so
Option Description
-U Allows a user login id to be given in order to connect to the SQL Server. By de-
fault Microsoft Windows Authentication mode is used.
-P Allows a user password to be given.
-E Specifies that a trusted connection be used to log in to the SQL Server.
-S Specifies the instance of SQL Server to which to connect.
-i Identifies the input query file, normally a .sql+ file, to be processed.
-o Identifies the output query file that is generated. The default, when the input file
is given as a .sql+ file, is the same file name but with a .sql suffix.
-so Specifies syntax only, meaning that no output file will be generated.
-sp Specifies the name of the sp database that contains the ORN system generated
stored procedures. By default this is the master database.
-v Specifies that the version number of +orndml be displayed.
-? Specifies that the syntax of the +orndml command be displayed.
ORN Additive DDL statements specify the ORN for relationships defined in a data-
base schema. Essentially, an <association> is provided for all foreign key con-
straints that implement relationships whose semantics are to be governed by ORN.
The <association> transfers to the database system the multiplicities and bindings
that have been specified for a relationship in an ORN-extended database model.
When modifications are made to a database schema that would add, remove, or
change relationships, appropriate modifications must be made to the ORN Additive
statements for the database and +ornddl must be rerun to process these statements.
Also, if required, appropriate changes should be made to the database so that the cur-
rent data is consistent with the new ORN specifications.
The USE statement specifies the database to the +ornddl postprocessor providing
the context for subsequent CONSTRAINT statements. An example of this state-
ment is:
--+<> USE companyDB;
ORN Additive: A Tool for Extending SQL Server with ORN 123
The CONSTRAINT statement provides the ORN for a relationship in the database,
the relationship being implemented as a foreign key, i.e., referential, constraint. The
name of the constraint along with the applicable <association> are given in the
statement. An ON UPDATE CASCADE clause can also be given to specify the
cascading of a primary key value change in a referenced table row to matching for-
eign keys in referencing table rows. Some examples of this statement are:
--+<> CONSTRAINT belongsTo ?<2..15-TO-0..1>;
--+<> belongsTo ?<2..15-TO-0..1>;
--+<> CONSTRAINT InventorySchema.isPartOf <*-TO-0..1>!
--+<> ON UPDATE CASCADE;
The DELETE statement provides for the archiving of information within a row be-
fore its deletion. The statement specifies an application-defined deletion stored pro-
cedure that is to be used to delete a row in a given ORN-related table. An example
of this statement is:
--+<> DELETE Employee USING HRS.usp_ArchiveAndDelete_Emp;
ORN Additive DML statements extend certain T-SQL DML-type statements to en-
force the ORN semantics for one or more ORN-enhanced databases. The statements
identify the databases to be manipulated; extend transaction processing capabilities
to facilitate implicit, recursive database processing for binding enforcement; and al-
low lower bound multiplicity constraints to be deferred until the transaction commit.
ORN Additive DML statements are only required in IDU queries that use explicit
transactions to modify an ORN-enhanced database or use multiple ORN-enhanced
databases. Explicit transactions are often required when inserting rows into the data-
base as ORN lower bound multiplicities are enforced on the commit of a transaction,
including the implicit transaction created for a single INSERT statement.
The USE statement is like the USE statement of T-SQL and substitutes for it when
updating an ORN-enhanced database. An example of a USE statement is:
+<> USE companyDB;
From +<> USE statements, the +orndml preprocessor determines the ORN-
enhanced databases that can be modified by transactions in a T-SQL query file. For
an ORN-enhanced database to be modified in a transaction, its name must appear in
a +<> USE statement somewhere in the query file.
126 ORN FOR DATABASE APPLICATIONS
* belongs to Ź 0..1
' Temporary Carpool
2..15
źis hired for ?
rider
includes Ź
Ż is assigned * Employee
0..1 ' 0..1 |! *
parent
|- 1
worker
*
Ƈ child
works for Ź 1
Assignment { An Assignment is related to at least Unit
one Temporary or Employee. }
USE CompanyDB;
--+<> USE CompanyDB;
CREATE TABLE Unit (
name VARCHAR(20) PRIMARY KEY,
...
);
CREATE TABLE Carpool (
id VARCHAR(8) PRIMARY KEY,
...
);
CREATE TABLE Assignment (
code CHAR(3) PRIMARY KEY,
...
);
CREATE TABLE Employee (
ssn CHAR(11) PRIMARY KEY,
...
carpoolid VARCHAR(8) CONSTRAINT belongsTo REFERENCES Carpool(id),
--+<> belongsTo ?<2..15-TO-0..1>;
unitName VARCHAR(20) CONSTRAINT worksFor REFERENCES Unit(name),
--+<> worksFor <*-TO-1>;
assignCode CHAR(3) CONSTRAINT isAssigned REFERENCES Assignment(code)
--+<> isAssigned '<*-TO-1> ON UPDATE CASCADE;
);
CREATE TABLE Temporary (
ssn CHAR(11) PRIMARY KEY,
...
assignCode VARCHAR(3) CONSTRAINT isHiredFor REFERENCES Assignment(code)
--+<> isHiredFor ‘<*-TO-0..1>|- ON UPDATE CASCADE;
);
ALTER TABLE Unit ADD
parent VARCHAR(20) CONSTRAINT includes REFERENCES Unit(name);
--+<> includes <*-to-0..1>|!;
GO
--+<> DELETE Employee ROW USING HRS.usp_ArchiveAndDelete_Emp;
--+<> SET ORN_MESSAGE_NUMBER_BASE 60000;
Fig. 6.5 T-SQL with ORN Additive statements implementing model in Fig. 6.4
ORN Additive: A Tool for Extending SQL Server with ORN 127
Unlike the T-SQL COMMIT statement, this statement checks deferred con-
straints, which for ORN are lower bound multiplicity constraints that may have been
violated because of database changes made within the transaction. When violated,
an error “Lower bound multiplicity was violated for ...” is raised. The error identi-
fies the applicable foreign key constraint and the related table for which the multi-
plicity was violated. The violation must be corrected before the transaction can be
committed, or the transaction must be rolled back.
The SET RXC_MODE statement changes the Relationship eXChange mode for
subsequent transactions. Examples of this statement are:
+<> SET RXC_MODE ON;
+<> SET RXC_MODE OFF;
If, however, RXC mode is set as below, the transaction will succeed since no im-
plicit deletion of carpool West is done. The lower bound multiplicity check to en-
sure that the carpool West has two employees is deferred until the +<> COMMIT
TRAN, at which time the carpool will have its required two employees.
ORN Additive: A Tool for Extending SQL Server with ORN 129
If carpool East had fifteen riders before the above transaction, the transaction
would fail. This is because the first UPDATE would result in an upper bound multi-
plicity violation. Setting RXC mode defers lower bound multiplicity checking but
not upper bound checking. The transaction below, however, would succeed.
SET RXC_MODE ON;
+<> BEGIN TRAN;
UPDATE Employee SET carpoolid = 'West' WHERE ssn = '999-99-9999'
UPDATE Employee SET carpoolid = ‘East’ WHERE ssn = '222-22-2222';
+<> COMMIT TRAN;
SET RXC_MODE OFF;
Despite the fact that this operation entails destroying the reference between the Em-
ployee row with ssn of 111-11-1111 and the Unit row with name of Accounting,
the 1 multiplicity for the Unit table will not be violated in the end. The UPDATE is
done within an implicit ORN-extended transaction.
Doing the above relationship change as a two-step process, however, as shown
below, would result in a lower bound violation error if RXC_MODE was not ON.
+<> BEGIN TRAN;
UPDATE Employee SET org = NULL WHERE ssn = '111-11-1111'
UPDATE Employee SET org = 'Personnel' WHERE ssn = '111-11-1111';
+<> COMMIT TRAN;
Disabling ORN triggers means that the constraints and actions associated with
ORN-defined foreign keys will not be enforced. This can result in a database being
in an inconsistent state in regard to the multiplicity constraints given in the <asso-
ciation>s defined for one or more foreign keys. For efficiency reasons, it is safe to
disable ORN triggers when doing any operation that does not violate any multiplicity
constraint or invoke any non-default binding action, e.g., updating columns in ORN-
related tables that are not columns in a primary key or ORN-defined foreign key.
Fig. 6.7 shows a query (.sql+) file that includes ORN Additive DML statements.
The query is based on the database defined in Fig. 6.5. Comments within the code
indicate actions that may result from enforcing ORN semantics. The first comment
makes sense when one considers that employee 444-44-4444 may be one of just
two employees in the Bristol carpool. The second comment makes sense when one
considers that employee 777-77-7777 may not exist in the database.
+<>USE CompanyDB;
GO
+<>BEGIN TRAN;
INSERT INTO Carpool VALUES (′Airport′, ...);
UPDATE Employee
SET carpoolId = ′Airport′ WHERE ssn = ′444-44-4444′ OR ssn = ′777-77-7777′;
-- Will implicitly delete any carpool if reassignment of an employee to the ‘Airport’ carpool
-- results in less than two employees.
BEGIN TRY
+<> COMMIT TRAN;
-- Will raise exception if two employees have not been assigned to the ′Airport′ carpool.
PRINT 'Transaction committed.';
END TRY
BEGIN CATCH
+<> ROLLBACK TRAN;
Print 'Database transaction rolled back';
END CATCH
GO
Fig. 6.7 Query (.sql+) file with ORN Additive DML statements for database defined in Fig. 6.5
Fig. 6.8 shows the output query (.sql) file that results from the processing of this
file by +orndml. An ORN header, which declares and initializes ORN Additive sys-
tem objects, has been included at the beginning of the query file. Also, ORN Addi-
tive DML statements have been replaced with corresponding T-SQL DML state-
ments and statements that execute ORN Additive system stored procedures.
ORN Additive: A Tool for Extending SQL Server with ORN 131
-- This code must be included at the beginning of a query at the outermost level
-- and executed before any INSERT, DELETE, or UPDATE statements are executed on
-- ORN-related tables and before any +<> statements are executed. If this code
-- is generated by +ornddl, it supports changes to only a single database. If
-- generated by +orndml, it supports changes to all databases referenced in the
-- +<> USE statements given within the preprocessed .sql+ file.
...
-- End +<> (ORN Additive Code)
-- Begin +<>
EXEC @ORN_Error = master.dbo.usp_ORN_PreBeginTran;
IF @ORN_Error = 0
BEGIN
BEGIN TRAN;
EXEC master.dbo.usp_ORN_PostBeginTran '';
END;
-- End +<>
INSERT INTO Carpool VALUES ('Airport', ...);
UPDATE Employee
SET carpoolId = 'Airport' WHERE ssn = '444-44-4444' OR ssn = '777-77-7777';
-- Will implicitly delete any carpool if reassignment of an employee to the ‘Airport’ carpool
-- results in less than two employees.
BEGIN TRY
-- Begin +<>
EXEC @ORN_Error = master.dbo.usp_ORN_PreCommitTran;
IF @ORN_Error = 0
BEGIN
COMMIT TRAN;
EXEC master.dbo.usp_ORN_PostCommitTran;
END;
-- End +<>
-- Will raise exception if two employees have not been assigned to the ‘Airport’ carpool.
PRINT 'Transaction committed.';
END TRY
BEGIN CATCH
-- Begin +<>
EXEC @ORN_Error = master.dbo.usp_ORN_PreRollbackTran '';
IF @ORN_Error = 0
BEGIN
ROLLBACK TRAN;
EXEC master.dbo.usp_ORN_PostRollbackTran '';
END;
-- End +<>
Print 'Database transaction rolled back';
END CATCH
GO
Fig. 6.8 Query (.sql) file resulting from +orndml processing of query (.sql+) file shown in Fig. 6.7
132 ORN FOR DATABASE APPLICATIONS
6.4 Conclusion
Object Relater Plus (OR+) adds ORN to ObjectStore (Progress 2006) but does so via
two new languages, the Object Database Definition Language (ODDL) and the Ob-
ject Database Manipulation Language (ODML). These languages extend and imitate
an ODMG standard for object databases (Cattel et al. 2000, 1997). Adding ORN to
ObjectStore increases the productivity of developing object database systems and
improves data integrity in these systems. Implementation is easier as database mod-
els more directly map to the required ODDL statements of OR+. More specifically,
relationships can be defined with the multiplicities and bindings that are defined in
UML class diagrams. These multiplicities and bindings are automatically enforced
by the database system as database changes are made using ODML. OR+ was de-
veloped to show the feasibility of defining associations to an ODBMS using ORN.
Although OR+ was developed as a prototype, it can be a very productive tool for
developing many object database applications. Many lines of C++ code, involving
complex class methods, are automatically generated by the tool. This code would
otherwise have to be painstakingly implemented, tested, and maintained by database
developers. The complete OR+ tool, including the OR+ ODDL User’s Guide and
the OR+ ODML User’s Guide can be downloaded from the author’s website at the
URL given in the Preface. The user’s guides provide the technical details for install-
ing and using the tool.
This chapter provides an overview of OR+, first discussed in Ehlmann and Ric-
cardi (1997b). It is partially based on this paper1 and the OR+ user’s guides. Section
7.1 examines OR+ capabilities and explains its level of compatibility with the
ODMG standard. Sections 7.2 and 7.3 provide detailed overviews of ODDL and
ODML, respectively. Section 7.4 discusses system architecture, implementation,
and extensibility. Section 7.5 concludes by summarizing the benefits and limitations
of OR+, giving its status, and indicating how its limitations can be easily overcome.
The capabilities of OR+ are provided by the ODDL processor and the ODML appli-
cation program interface (API), which is implemented as a layer on top of Object-
1Portions reprinted, with permission, from “Object Relater Plus: a practical tool for developing en-
hanced object databases,” Proc Data Eng Conf, IEEE Computer Society, 412-421. © 1997 IEEE.
Store. This section briefly describes how ODDL and ODML essentially add ORN to
ObjectStore and extend the ODMG standard with some additional capabilities.
ODDL was developed as a compatible extension of the ODMG 2.0 C++ Object
Data Language (ODL), though its relationship declarations reflect the higher-level,
language-independent ODMG 2.0 ODL. ODDL, like ODL, is an object DDL be-
cause it allows object behavior to be specified as C++ class member functions (or
methods). ODML is a compatible extension of ODMG 2.0 C++ Object Manipula-
tion Language (OML) (Future Binding, Release 1.1) and provides database manipu-
lation based on an ODDL-defined database. ODDL and ODML provide a “facade”
for database development that is ODBMS vendor-independent. ObjectStore is the
structure beneath this facade, supplying much of the basic ODBMS capability.
ODDL primarily describes an object database at a conceptual level in an ANSI-
SPARC sense (ANSI 1975). Footnotes, however, allow implementation details, i.e.,
an internal schema, to be given. Sidebars facilitate the specification of an external
schema and extended capabilities for a specific application domain, e.g., scientific
databases. The separation of internal, conceptual, and external schema and ODBMS
extensibility via sidebars are not capabilities found in the ODMG standard.
The most important capability, however, that OR+ adds to the ODMG standard
(and ObjectStore) is ORN. ODDL allows an <association> to be given for a rela-
tionship, represented as an object-based attribute pair, e.g., carpool and riders in
Fig. 7.1. The ODML API extends ODMG OML to support ORN. This means that
ORN semantics are automatically maintained by the ODBMS, which in turn means
that ODML operations are not primitive object operations but are complex object
operations. Fig. 7.2 shows a C++ program segment that uses ODML types Data-
base, Transaction, and d_Iterator and operations open, begin, lookup_object,
next, Delete, commit, and close to delete an employee (and possibly a carpool)
from the CompanyDb database.
Database CompanyDb { …
class Carpool;
class Employee {
d_String ssn; // Social Security Number
...
Carpool carpool inverse riders ?<2..15-to-0..1>;
$C++
void RaiseSalary(int percentage);
$.
};
extent Set<Employee> Employees;
…
class Carpool {
d_String id;
...
Set<Employee> riders inverse carpool;
};
extent Set<Carpool> Carpools;
…
};
Fig. 7.1 Example of a partial ODDL specification for a company database
Object Relater Plus (OR+): An ORN-extended Object DBMS 135
…
Database CompanyDb;
Transaction t;
CompanyDb.open("co_db");
t.begin();
Employees_Ptr = (d_Set<Employee*>*)CompanyDb.lookup_object("Employees");
Employee* pE;
d_Iterator<Employee*> iE(*Employees_Ptr);
while (iE.next(pE))
if (pE->ssn == "555-55-5555") {
pE->Delete(); // Results in deletion of a Carpool object if lowerbound 2 is violated.
break;
};
t.commit();
CompanyDb.close();
…
Fig. 7.2 Example of a C++ code using the ODML API to update database CompanyDb
7.2 ODDL
The next two pages include figures referenced in the remainder of this chapter. Fig.
7.3 shows an example of a database model for a company database. The partial
ODDL specification that was given in Fig. 7.1 was developed based on this model,
and an expanded version of this specification is given in Fig. 7.4. Fig. 7.5 shows an
example of a database model that is part of a nuclear physics experiments database.
The partial ODDL specification in Fig. 7.6 is based on this database model.
belongs to Ź 0..1
Carpool
2..15
rider
?
* Ż has 1..2
Child ? Employee
*
worker works for Ź 1
Unit
Fig. 7.4. Partial ODDL specification for the database model in Fig. 7.3
Comments can be given in ODDL at specific places for each metaobject⎯the da-
tabase, a class, an extent, or an attribute⎯e.g., in Fig. 7.4, // Soc. Sec. No. for at-
tribute ssn in class Employee. Unlike comments in ODMG ODL, these comments
become part of the ODDL metadatabase and provide valuable information to a user
who wishes to browse the metadatabase to discover database contents.
References can be attached to metaobjects. They reference footnotes, e.g., [1] for
attribute subtracks within class Track in Fig. 7.6, or they reference sidebars, e.g., |1
for numberOfOffshoots within class Root. Footnotes and sidebars are discussed in
Section 7.2.3.
Object Relater Plus (OR+): An ORN-extended Object DBMS 137
Root
1
2..8 forms ► 0..1
!
SubTrack Track Root-
? decays to ▼
Offshoot
1..*
Offshoot
Database Experiments // for nuclear physics class Root isa Track { //or :public track
{ Collection<Offshoot> Offshoots
$sidebar 1 inverse Root
derived !<1-to-1..*>; [2]
$. int numberOfOffshoots; |1
... ...
class Track; };
class Root; class Offshoot isa Track { // track from a
class Offshoot; // decaying particle
class Subtrack { // particle subtrack in a Root root inverse Offshoots;
// detector device ...
Device device; };
Track track inverse subTracks class RootOffshoot isa Root, Offshoot {
?<2..8-to-0..1>; ...
... };
}; ...
class Track { // particle track within a $footnotes
// sector of the detector [1] List
Sector sector; [2] Set
Collection<subtrack> subTracks $.
inverse track; [1] };
...
};
Fig. 7.6 Partial ODDL specification for the database model in Fig. 7.5
Attributes serve to describe objects and within a class specify attributes common
to all objects of the class. Attributes are value-based or object-based.
A value-based attribute, e.g., name within class Employee in Fig. 7.4, stores
values that have no value-independent identity in the database. The attribute can be
single-valued or multi-valued. Its type can be a C++ primitive type (e.g., int), a type
defined by ObjectStore or OR+ (e.g., d_String), or a type previously defined in the
ODDL specification via C++ code (e.g., an enum, a typedef, or a class like Date in
Fig. 7.4).
An object-based attribute, e.g., unit within class Employee in Fig. 7.4, may ref-
erence one or more objects in the database. A pair of object-based attributes that are
inverses of each other represent an association in ODDL. Each attribute represents
one direction of a bi-directional association. (In the ODMG standard these object-
based attributes are called relationship traversal paths and are preceded by the key-
138 ORN FOR DATABASE APPLICATIONS
7.2.2 <association>
An <association>, e.g., <*-to-1> for unit in class Employee in Fig. 7.4, describes
the semantics of an association as represented by an object-based attribute and its in-
verse attribute. The multiplicities and bindings of an <association> can be mapped
directly from an ORN-extended class diagram. The syntax of an <association> is,
of course, that defined in Fig. 2.1. Table 7.1 defines the semantics in the context of
the object model as defined by ODDL. The bindings and multiplicities in an <asso-
ciation> define the semantics of the association, which in turn determine the scope
of complex and composite objects.
An <association> may be given for one, both, or neither attribute of an inverse
attribute pair. If given for just one, the inverse of the given <association> is im-
plicitly assumed for the other⎯e.g., in Fig. 7.4, <0..1-to-2..15>? is assumed for
riders in class Carpool. If given for both attributes, each <association> must be
the inverse of the other—e.g., in Fig. 7.4, <*-to-1..2>? and ?<1..2-to-*> for the par-
ents and children attributes, respectively, are inverses of each other. If not given for
either attribute, a default <association> is assigned to each based on whether the at-
tributes are single-valued or multi-valued. If single-valued, the default <associa-
tion> is <...-to-0..1>. If multi-valued, it is <...-to-*>.
Object Relater Plus (OR+): An ORN-extended Object DBMS 139
7.3 ODML
ODML provides a C++ API for an object database defined by ODDL. It is a collec-
tion of C++ macros, classes, and functions. Fig. 7.7 shows a sample program that
uses ODML to access and manipulate the database defined by the ODDL specifica-
tion given in Fig. 7.4. The discussion below focuses on this sample program.
The program adds a public relations unit to the company database and a new em-
ployee, who is to work for this new unit. In addition, it deletes all temporary em-
ployees and reassigns all employees in the customer support unit to the public rela-
tions unit. It then prints all units, including their employees. The following
paragraphs explain and comment on segments of the program.
1 // sample_prog.C
2
3 #include <iostream.h>
4 #include "CompanyDbOR+.h"
5
6 void PrintUnits() // Print all units, including the employees working for each unit.
7 {
8 cout << "Company Employees by Unit:" << endl;
9 d_Iterator<Unit*> iU(*Units_Ptr);
10 unit* pU;
11 while (iU.next(dp)) pU->Print();
12 }
13
14 void main()
15 {
16 Database db;
17 Transaction t;
18 db.open("co_db");
19 t.begin();
20 Units_Ptr = (d_Set<Unit*>*)db.lookup_object("Units");
21 Employees_Ptr = (d_Set<Employee*>*)db.lookup_object("Employees");
22
23 Unit* pU = NEW(db, Unit)("Public Relations");
24 pU->location = "205 Building B";
25 Employee* pE = NEW(db, Employee)("Doe, John Q.");
26 pE->unit = pU; // or pU->Employees.insert_element(pE);
27 ... // Set additional employee attributes.
28
29 d_Iterator<Employee*> iE(*Employees_Ptr);
30 while (iE.next(pE))
31 if (pE-> type == 2)
32 pE->Delete() // May result in the deletion of carpool and child objects.
33 else
34 if (pE->unit->name == "Customer Support") pE->unit = pU;
35
36 PrintUnits();
37
38 t.commit();
39 db.close();
40 }
Fig. 7.7 Sample program that uses ODML to modify the database defined by the ODDL in Fig. 7.4
142 ORN FOR DATABASE APPLICATIONS
The Units_Ptr and Employees_Ptr (lines 20 and 21) are declared in Com-
panyDbOR+.h, which is generated by ODDL. These pointer variables are set to
reference the extents Units and Employees, respectively, which are named objects
in the database. Named objects provide entry points into the database, i.e., objects
through which other persistent objects can be accessed.
The NEW macro (line 23) calls an ODML overloaded new operator that creates a
persistent object of the given type in the given database and calls a constructor. The
constructors for classes Employee and Unit are not shown in Fig. 7.4.
Assigning John Q. Doe to public relations (line 26), i.e., creating a relationship
between the new Employee object and the public relations Unit object, can be done
by either setting the attribute unit for the new Employee object to reference the pub-
lic relations object or by inserting a reference to the new Employee object into the
attribute employees for the public relations object. To reflect changes made to an
object-based attribute, OR+ automatically makes corresponding changes to the in-
verse attribute. The choice of perspective for making changes is the programmer's.
Iterators (line 29) are provided by ODML to sequentially access the elements of a
collection. In the sample program, the d_Iterator named iE provides such access to
all objects of the Employees extent.
Deletion of a temporary employee via pE->Delete() (line 32) causes more than
just the deletion of the employee object. All relationship semantics associated with
an employee, i.e., those modeled in Fig. 7.3 and defined in Fig. 7.4, are enforced.
This means that relationship references are implicitly destroyed⎯perhaps, for exam-
ple, the employee object's reference to a carpool⎯and other objects are implicitly
deleted⎯perhaps one or more child objects and/or a carpool object.
The assignment pE->unit = pU (line 34) performs a relationship change from the
perspective of an employee, i.e., it transfers an employee from customer support to
public relations. Again, the inverse attribute employees for both the customer sup-
port and public relation objects is automatically updated.
The function PrintUnits() (lines 36 and 6) iterates through the Units extent call-
ing the Print() method of class Unit on each Unit object (line 11). This method (de-
clared in Fig. 7.4) iterates through the employees attribute, invoking the Print()
method of class Employee on each employee referenced by the attribute. The defi-
nitions of these methods must of course be linked to the sample program.
The call to t.commit() (line 38) commits the changes made by the program. The
commit() method ensures that all lower bound multiplicities are met for objects cre-
ated during the transaction, e.g., that unit for the John Q. Doe object is not 0.
With ORN it is sometimes necessary to temporarily suspend lower bound multi-
plicity checks to allow relationships among objects to be reshuffled. For example,
assume in Fig. 7.3 a new |~<1-to-1>, “is assigned” association between the class
Employee and a new class OfficeKey. This new class defines objects that corre-
spond to a physical key and also record information about the assignment of an of-
fice to an employee. In the ODDL of Fig. 7.4, an object-based attribute officeKey is
added to the Employee class to reference an OfficeKey object. Now, suppose that a
decision is made to reshuffle the offices assigned to three employees. Employee
(referenced by) e1 currently has office key (referenced by) k1, e2 has k2, and e3
Object Relater Plus (OR+): An ORN-extended Object DBMS 143
has k3. k1 must be reassigned to e2, k2 to e3, and k3 to e1. This can be done by
the code in Fig. 7.8 placed within a Transaction t. The function SetRXCmode()
sets the Relationship eXChange (RXC) transaction mode. ResetRXCmode() resets
this mode. When RXC mode is set, lower bound multiplicity checks are not per-
formed as usual on completion of complex relationship destruction (e.g.,
e1.officeKey = 0;) and change operations and binding actions that might result from
such checks are not taken. Instead, relevant attributes, e.g., officeKey above, are
checked on commit of the application-specified transaction to ensure that lower
bound multiplicity constraints are satisfied. Exceptions result if they are not. With-
out the RXC mode, certain manipulations on some associations types could not be
done without violating multiplicities.
t.SetRXCmode();
e1.officeKey = 0;
e2.officeKey = 0;
e3.officeKey = 0;
e1.officeKey = &k3;
e2.officeKey = &k1;
e3.officeKey = &k2;
t.ResetRXCmode();
This section provides insight into OR+’s architecture, implementation, and how it
can be extended by a user. OR+ was developed for two types of users⎯one who
uses ODBMS for a specific database application and the other who uses it as a tool
to develop an extended ODBMS, often adding capabilities for a particular applica-
tion domain. OR+ has been compiled with multiple C++ compilers and run on mul-
tiple Unix platforms, although currently only one compiler and platform is sup-
ported, which is the Sun C++ compiler and the Sun Solaris platform. (Source code
may be obtained on request, and the system can be ported to other Unix platforms.)
7.4.1 Architecture
Fig. 7.9 shows the architecture of the OR+ system. It indicates the processes and
files needed to create an ORN-enhanced ObjectStore database and run a database
application program that accesses and/or updates it. What is provided by OR+ is
shown in bold. What must be developed by the OR+ user is shown in italics. What
must be acquired by the OR+ user is ObjectStore.
144 ORN FOR DATABASE APPLICATIONS
ODDL
ODDL Specification ODDL
Processor Metadatabase
ObjectStore
included Headers
ODML
included Header ObjectStore Schema
Source File
included
Application
C++ Compiler
Program Application Schema
Source Files Source File
OR+
C++ Compiler Object Files C++ Compiler
ODML
Library Application
Application Schema Database
Program
System, ObjectStore,
and Application
Libraries
ORN-Enhanced
ObjectStore Database
The ODDL processor of OR+ is invoked by the oddl command, which includes a
number of options. Typical processing verifies proper syntax and semantics of the
ODDL specification, checks for inconsistencies in the <association>s given for re-
lationships (see Section 9.1), and assigns default <association>s as required. The
ODDL processor builds a metadatabase, which can optionally be saved as an Ob-
jectStore database and later processed by ODDL, the ObjectStore browser, or pro-
Object Relater Plus (OR+): An ORN-extended Object DBMS 145
grams and queries written by the OR+ user. An error-free specification normally re-
sults in the generation of a number of C++/ObjectStore source files. The database-
specific OR+.h and OR+.C files implement ODML when included in application
program source files that are compiled and linked with the database-independent
ODML library and ObjectStore libraries. The ODDL-generated ObjectStore schema
source file is (as prescribed by ObjectStore) processed by the ObjectStore Schema
Generator (ossg) to create the ObjectStore application schema database and the ap-
plication schema source file. This latter file is compiled to create the application
schema object file, which must be linked with the application program. Makefiles
supplied by OR+ and ObjectStore automate the required processing.
7.4.2 Implementation
based attribute, passing to it the encoded <association> for the specific object-
based attribute. For each existing reference in the attribute, this method removes it
and calls an inherited library method on the relationship class for the inverse attrib-
ute, here riders, in the referenced (or related) object, here a Carpool object, to re-
move from the attribute the reference to the Employee object. It then calls yet an-
other inherited method to check the multiplicity and implicit destructibility binding
for the Employee class in the <association>. Actions are taken as described in Ta-
ble 7.1. If, for instance, the binding is |-, an exception is raised. If, however, it is |?,
as for Employee in the “belongs to” association, and the lower bound cardinality,
here 2, is violated, then an implicit form of Delete() is called on the related object,
here a Carpool object, and this whole process begins anew for this object.
Before addressing ODDL extensibility, a few additional details about the imple-
mentation of ORN are important to note. First, this implementation does not affect
user-written constructors and destructors for ORN-related classes. Multiplicity
checks and implicit relationship destructions and object deletions are not done within
constructors and destructors (unless they result from explicit relationship destruc-
tions and object deletions done by the application within constructors). Second, as-
sociation semantics are maintained by run-time interpretation of encoded <associa-
tion> objects, which are instantiated as global variables within ODDL-generated
header files included in the application program. Third, certain sets of object refer-
ences are maintained by the system during the processing of a transaction. These
sets are used to detect circularities that can result when implicit object deletions are
propagated. They are also used to keep tabs on all newly created objects and refer-
ence destructions requiring deferred lower bound multiplicity checks so that these
checks can be done on transaction commit. Finally, the actual removal of references
from collections and the deletion of primitive objects are done by ObjectStore.
More information on the implementation of ORN in OR+ can be gleaned from the
algorithms given in Chapters 10 and 12.
7.4.3 Extensibility
An option on the oddl command and a number of ODDL supplied “tools” facilitate
the extension of OR+ into an even more enhanced ODBMS. When the -g option is
specified, user-written code in OR+ assumes control of ODDL code generation. The
tools supplied to the user for extending ODDL are a scanner, hooks in the metadata-
base, a code generation facility, public member functions and iterators that facilitate
access to metadatabase objects, and a class representing the ODDL provided data-
base system layer.
As previously indicated in Section 7.2.3, the scanner is provided for parsing side-
bars. The sidebars are initially stored in the ODDL metadatabase as text. The first
step in generating a user-enhanced object database system is to parse these sidebars,
appropriately issuing errors, if any, and updating an extended ODDL metadatabase.
Object Relater Plus (OR+): An ORN-extended Object DBMS 147
The public member functions of an ODDL defined class, dbs_layer, enable the
OR+ user to generate all portions of the ODDL-provided database system layer.
This is the layer of software that the user is extending and essentially includes
ODMG capabilities enhanced with ORN. The member functions of dbs_layer give
the user the flexibility to generate portions of the database system layer into user-
specified source files and to mix in user generated code at strategic points.
7.5 Conclusion
This chapter has described OR+ and emphasized features that make it a useful tool
for developing enhanced object databases and extending ODBMSs with additional
enhancements. The features of OR+ are summarized as follows:
• the facilitation of an object database development methodology where a database
model represented by a UML class diagram is more directly mapped into an ob-
ject DDL, e.g., ODDL (The precise rules for this mapping are given in Section
8.2.)
148 ORN FOR DATABASE APPLICATIONS
• a means, ORN, to better describe associations during analysis and design and de-
fine them to an ODBMS so that their semantics can be automatically maintained
• compatibility with a standard for ODBMSs and thus a degree of vendor-
independence
• separation of external, conceptual, and internal ODB schemata via footnotes and
sidebars
• extensibility via sidebars and supporting tools that facilitate generic and domain-
specific enhancements
All of the OR+ capabilities described in this chapter have been implemented ex-
cept for the following two:
• the derived sidebar, which was given in Fig. 7.6 as an example of a user-defined
ODDL extension
• footnotes that specify keys, which were mentioned in Section 7.2.3
Implementing these capabilities would not be difficult.
They were not implemented, however, because OR+ is a prototype, originally de-
veloped to experiment with enhanced ODBMS features. Implementation is con-
strained by the user capabilities and architecture of the commercial ODBMS upon
which it is built (which can be changed). In addition, some ODBMS capabilities are
only available at the level of its underlying ODBMS, e.g., concurrency control and
database schema migration. Obviously, overall implementation would be improved
if all OR+ features were well integrated into a non-prototype ODBMS.
OR+ was first employed at the Supercomputer Computations Research Institute
(SCRI) at Florida State University in the early 1990’s to research enhanced object
database capabilities and methodologies for scientific databases. Specifically, it was
used to design a nuclear physics experiments database (Riccardi and Ehlmann 1991,
Ehlmann 1992, Ehlmann et al. 1992, Ehlmann et al. 1993). Since then, it has been
used for student database projects in graduate-level, DBMS courses. OR+ is the
ODBMS that was used to implement the ORN Simulator (Chapter 3); therefore, its
implementation of ORN is well tested.
Object database users, researchers, and vendors are encouraged to download
OR+, experiment with it, and employ it to develop object database systems or
ODBMSs. Any feedback will be much appreciated.
Chapter 8
Chapter 6 described ORN Additive, which extends the SQL Server RDBMS with
ORN. Chapter 7 described OR+, which extends the Object Store ODBMS with
ORN. Both chapters presented an example of an ORN-extended class diagram that
modeled a company database. Chapters 6 and 7 also gave DDLs that implemented
the model as an ORN-extended RDBMS and ORN-extended ODBMS, respectively.
This chapter shows precisely how such DDLs are obtained, or mapped, from a da-
tabase model. Section 8.1 shows how classes and associations in a database model
along with ORN-defined association semantics are easily mapped to an ORN-
extended SQL. Section 8.2 shows how such classes, associations, and semantics are
easily mapped to an ORN-extended DDL for an ODBMS. Section 8.3 concludes
with a brief summary remark.
This section provides directions for mapping a database model given by an ORN-
extended class diagram to an ORN-extended SQL. Here, the examples given use T-
SQL with ORN Additive DDL statements. Chapter 11 describes another ORN-
extended SQL, based on an SQL standard (ANSI 2008), for which the directions be-
low also apply; the T-SQL given in examples can be easily translated.
The basic steps in the mapping process, which are given in greater detail in the
subsections that follow, are:
1. Transform the database model, if necessary, into a model more compatible with
the relational model by using appropriate association patterns.
2. Map classes to tables declaring appropriate attributes and primary keys.
3. Map associations to foreign keys declaring for each the same ORN as defined for
the modeled association.
To simplify the mapping of the class diagram model to SQL, we first transform the
model to make it more compatible to the way attributes and relationships must be
implemented in a relational database.
Using the “is associated by” association pattern, given in Section 4.2.4, transform
each many-to-many binary and each n-ary association where n ≥ 3 into appropriate n
one-to-many associations. Each one-to-many association is between one of the re-
lated classes and an associating class. This class is similar to and replaces the asso-
ciation class if one is given in the model for the original association. If not, create a
new associating class, appropriately naming it to represent the original association.
Each object of this associating class represents an instance of the original association
and is associated with exactly one object from each of the related classes. Ensure
that this set of related objects is unique for the associating class (as it was for the
original association) by adding an appropriate constraint to the class diagram. Place
any attributes for the original association into the associating class.
For example, transform the many-to-many association in Fig. 8.1 into an associat-
ing class Assignment; two one-to-many, “is associated by” association types; and
an appropriate constraint as given in Fig. 4.6 (b). Section 4.3 gives an example of
the transformation of another many-to-many association, between songs and CDs,
into an associating class, two “is associated by” associations, and a constraint. The
multiplicities and bindings of the original association are mapped to the new associa-
tions as shown in Fig. 4.17.
* is assigned to ► 1..*
Employee Project
Fig. 8.1 Many-to-many association transformed into two one-to-many associations in Fig. 4.6 (b)
Fig. 8.2 shows the transformation of yet another many-to-many association, an in-
tra-class association. The attribute relation indicates mother, stepmother, father,
etc.. The ' and |- bindings included in the original association again show how bind-
ings are transformed along with multiplicities.
takes on ►
1 |-
Person guardian
! *
Guardianship
Person
0..2 * relation
guardian ' |- dependent
dependent
relation ! ' 0..2
1
is responsible for ► ◄ for a
{ A Person cannot be both a guardian { (guardian, dependent) for a Guardianship is unique and
and dependent. } a Person cannot be both a guardian and dependent }
(The “is responsible for” association in Fig. 8.2 can be seen as an intra-class asso-
ciation example of a Case 2 “is recorded for” pattern, given in Section 4.2.2.2, where
Mapping Database Models to DDLs 151
the primary class and supporting class are the same. Here, deleting a guardian im-
plicitly deletes all dependents who do not have a second guardian. A dependent
Person object or a Guardianship object cannot be explicitly deleted. A Guardian-
ship object is deleted by deleting its related guardian Person object or by explicitly
destroying its link to this object.)
Fig. 8.3 shows the transformation of a ternary association, the classic association
where vendors supply parts to projects. Many vendors can supply a part to a project,
many parts can be supplied by a vendor to a project, and many projects can be sup-
plied a part by a vendor—thus the many-to-many-to-many association.
from a ► 1
Vendor Part Vendor
!
*
* *
for a ► 1
Procurement *
! Part
quantity
quantity
*
*
to a ► 1
Project ! Project
In an n-ary association where n ≥ 3, it is possible, though rare, that one of the re-
lated class multiplicities is 1. For example, in Fig. 8.3 the multiplicity for Vendor
could be 1 meaning that given a particular part and project, only one vendor is al-
lowed to supply the part to the project. In this case, the mapping would not result in
a uniqueness constraint that included the related class with multiplicity 1. In Fig 8.3,
if the multiplicity for Vendor was 1 in the original model, the uniqueness constraint
in the resultant model would be { (Part, Project) for Procurement is unique }.
We note that an associating class represents a weak entity type. Each associating
object is dependent on each of the related objects for its existence and often its iden-
tity. This will be important later when we map an associating class to a table.
Employee Student
{ optional } {mandatory}
Fig. 8.4 Optional “is a” relationships Fig. 8.5 Mandatory “is a” relationships
A subclass in the “is a” association represents a weak entity type. The subclass
object is dependent on its related superclass object for its existence and identity.
Using the Case 1 “is recorded for” pattern, given in Section 4.2.2.1, transform each
multi-valued attribute in a class into an appropriate supporting class and a one-to-
many association. For example, as shown in Fig. 8.6, transform the attribute de-
pendent[12] in a class Employee into the supporting class Dependent and the
one-to-many “supports” association. This association is similar to the “claims” (or
inverse “is recorded for”) association given in Fig. 4.2 (b). Each element of de-
pendent is a string representing the name of an employee’s dependent.
Employee Employee 1
supports ► 0..12 Dependent
ssn {PK} ssn {PK} !
… … name
dependent[12]
As shown in Fig. 8.7, transform the attribute prevAddr[3] in the class Applicant
into the supporting class prevAddr and one-to-many association “has lived at.”
Each prevAddr element is a string representing an applicant’s previous address.
Mapping Database Models to DDLs 153
Applicant Applicant 1
has lived at ► 0..3 PrevAddr
ssn {PK} !
ssn {PK}
… address
…
prevAddr[3]
The supporting classes created by the types of transformation shown above are
always weak entity types.
After transforming the database model, we map each class to a table definition.
More specifically, for each class create a table that includes all attributes of the class.
For any composite attributes, include only the constituent simple attributes. Define
for each attribute an appropriate type. If the class represents a weak entity type, in-
clude one or more primary key attributes from each owner class—e.g., an associated
class, superclass, or primary class—to uniquely identify the rows of the created table.
Declare a primary key for the relation.
Fig. 8.8 shows how classes Employee, a strong entity type, and Manager, a
weak entity type, both modeled in Fig. 4.15 (b), are mapped to Employee and Man-
ager tables, respectively. It also shows how class Dependent, modeled in Fig. 8.6
as a weak entity type, is mapped to table Dependent. Here, the ssn from the Em-
ployee table is included in Manager and Dependent tables to form primary keys.
Fig. 8.8 Mapping classes representing strong and weak entity types to tables
154 ORN FOR DATABASE APPLICATIONS
Fig. 8.9 shows how the Guardianship class, shown in Fig. 8.2, is mapped to a
Guardianship table. Fig. 8.10 shows how the Procurement class, shown in Fig.
8.3, is mapped to a Procurement table.
After mapping classes to tables, we map each association to a foreign key declara-
tion, which includes an <association>.
For each one-to-many association, place a copy of the primary key attribute(s) of the
table representing the class (or role) at the one-end of the association into the table
Mapping Database Models to DDLs 155
representing the class (or role) at its many-end to act as a foreign key. Do not in-
clude an attribute if it is already present in the table (for instance, if already included
by step 2). If appropriate and not yet done, rename the foreign key attribute(s) to re-
flect the role that the referenced object plays in the association.
Declare the foreign key contraint, and define for it the many-to-one, syntactic
<association> corresponding to its graphical representation in the database model.
Fig. 8.11 shows how the one-to-many association between units and employees,
given in Fig. 6.4, is mapped to a foreign key declaration. The declaration is given
using T-SQL/ORN Additive and must be a named foreign key constraint. Integra-
tion of ORN into the SQL standard, as discussed in Chapter 11, would require only
an “unnamed” REFERENCES clause that includes the <association>.
Unit
CREATE TABLE Unit (
name {PK}
…
name VARCHAR(20) PRIMARY KEY,
...
1 );
Fig. 8.12 shows how the two one-to-many associations between classes Person
and Guardianship, given in Figs. 8.2 and 8.9, are mapped to foreign key declara-
tions. Here, since Guardianship is a weak entity type, the needed ids from the table
at the one-end, i.e., Person, have already been included into the Guardianship ta-
ble. This was done in Step 2 of the mapping process (see Fig. 8.9).
For each one-to-one association, place a copy of the primary key attribute(s) of the
table representing the class (or role) at one end of the association into the table repre-
senting the class (or role) at the other end to act as a foreign key. (We assume here
that there is no reason to combine these tables, an option when the association is not
intra-class.) Do not include an attribute if it is already present in the table (for in-
stance, if already included by step 2). Use the following guidelines to select the table
that will contain the foreign key.
• If the association is 1-to-1, select the table having the largest primary key since
this results in the smallest foreign key and thus less storage.
• If the association is 1-to-0..1, select the table representing the 0..1 end of the as-
sociation since this results in no foreign keys that are null.
• If the association is 0..1-to-0..1, select the table likely to have the fewest number
of rows since this generally results in less storage.
If appropriate and not yet done, rename the foreign key attribute(s) to reflect the role
that the referenced object plays in the association.
Declare the foreign key constraint and define for it the syntactic <association>
that corresponds to its graphical representation in the database model. The direction
of this <association> must be from the class represented by the referencing table to
the class represented by the referenced table.
Fig. 8.13 shows how a one-to-one association between company credit cards and
employees is mapped to a foreign key declaration. Very few employees are issued
company credit cards. An employee cannot be deleted without first “retrieving the
card” and explicitly destroying the “is issued” link, i.e. setting cardHolder to NULL.
Employee
CREATE TABLE Employee (
ssn {PK}
ssn CHAR(11) PRIMARY KEY,
…
…
0..1 cardHolder );
|-
CREATE TABLE CreditCard (
is issued ▼ cardNo CHAR(16) PRIMARY KEY,
...
0..1 cardHolder VARCHAR(11)
CONSTRAINT isIssued REFERENCES Employee(ssn)
CreditCard --+<> isIssued <0..1-TO-0..1>|-;
cardNo {PK} );
…
Fig. 8.14 shows the mapping of the “is a” associations shown in Fig. 4.15 (b) to
foreign key declarations. Since Manager and SalesPerson are weak entity types,
the needed ssn primary key attributes from the table representing the 1 ends of each
association, i.e., Employee, have already been included into the Manager and
SalesPerson tables. This was done in Step 2 of the mapping process (see Fig. 8.8).
Mapping Database Models to DDLs 157
When a foreign key is part of a primary key, it cannot be set to null. This means that
an association link, as represented by a non-null foreign key value, cannot be explic-
itly destroyed. If such link destruction is required, then another primary key must be
declared for the referencing table. This could be a different candidate key or an
IDENTITY column.
This section provides directions for mapping a database model given by an ORN-
extended class diagram to an ORN-extended object DDL. Here, the examples given
use ODDL, which was discussed in the previous chapter. Chapter 12 describes an-
other ORN-extended object DDL, namely the Object Definition Language (ODL),
which is defined by the ODMG 3.0 standard (Cattel et al. 2000). The directions be-
low also apply to ODL; the ODDL given in examples can be easily translated.
The basic steps in the mapping process, which are given in greater detail in the
subsections that follow, are:
1. Transform the database model, if necessary, into a model more compatible with
an object database model by using appropriate association patterns.
2. Map classes in the model to class definitions and extents in the object DDL de-
claring appropriate value-based attributes for each class.
3. Map associations to object-based attributes declaring for each the same ORN as
defined for the modeled association.
158 ORN FOR DATABASE APPLICATIONS
To simplify the mapping of the class diagram model to the object DDL, we first
transform the model to make it more compatible to the way associations must be im-
plemented in an object database.
Using the “is associated by” association pattern, given in Section 4.2.4, transform
each many-to-many binary association having association attributes and each n-ary
association where n ≥ 3 into appropriate n one-to-many associations. Many-to-many
associations not having association attributes may also be transformed into one-to-
many associations to facilitate future association attributes. The directions for doing
these transformations are given in Section 8.1.1.1 and are not repeated here except
for providing the following example, which slightly revises the Employee-Project
example given in Section 8.1.1.1, Fig. 8.1.
Fig. 8.15 shows the transformation of the many-to-many association between
classes Employee and Project into an associating class Assignment; two one-to-
many, “is associated by” association types; and an appropriate constraint.
* is assigned to ► 1..*
Employee Project
dateAssigned
1 has ► 1..*
Employee !
(is associated by 1 ►)
Assignment
dateAssigned
1 ◄ is for *
Project !
(is associated by 2 ►) { The combination of an Employee
and a Project associated by an
Assignment is unique. }
After transforming the database model, we map each class to a class definition.
More specifically, for each class create a class definition that includes all attributes
of the class. If the class is a subclass, include the appropriate isa specification to
identify its superclass.
If the database objects (or persistent objects) of a class must be accessed directly,
create an extent for the class. A class that represents a strong entity type usually re-
quires an extent. An appropriate collection type may be specified for the extent. Al-
though not currently implemented in ODDL, some collection types allow keys to be
specified, e.g., Dictionary in the ODL of ODMG 3.0. Primary keys may be imple-
mented in this manner.
Fig. 8.16 shows how classes Employee, a strong entity type; Manager, a sub-
class; and Dependent, a weak entity type, are mapped to ODDL. Composite at-
tributes, like name, and multi-valued attributes, like dependent in Fig. 8.6, can be
defined as C++ user-defined types. Here, however, the attribute dependent has
been transformed into the class Dependent and a one-to-many association.
1 class Dependent {
Employee supports ► 0..12 Dependent
d_String name;
ssn {PK} ! name };
name supporter
last $C++
first struct nameType {
middle d_String last;
address d_String first;
… d_String middle;
};
$.
class Employee {
d_String ssn;
Manager nameType name;
d_String address;
bonus …
};
extent Set<Employee> Employees;
After mapping classes to class definitions and extents, we map each association to a
pair of object-based attribute declarations, one of which includes an <association>.
We first focus on inter-class associations, then address intra-class associations.
For each one-to-one association between classes A and B, add a single-valued, ob-
ject-based attribute (a reference) to class A to reference an object of type B and a sin-
gle-valued, object-based attribute to class B to reference an object of type A. If ap-
propriate, name the attributes to reflect the role that the referenced (related) object
plays in the association. Define the attributes as inverses of each other.
Define for one of the attributes the one-to-one, syntactic <association> that cor-
responds to its graphical representation in the database model. The direction of this
<association> is from the referencing class to the referenced class.
Fig. 8.17 shows how a one-to-one association between employees and company
credit cards is mapped to a pair of references. (An employee [Employee object]
cannot be deleted without first “retrieving the card” from the employee and explicitly
destroying the “is issued” link, i.e., setting creditCard [or cardHolder] to 0.)
For each one-to-many association between classes A and B, add a multi-valued, ob-
ject-based attribute (a collection of references) to class A to reference objects of type
B and a single-valued, object-based attribute (a reference) to class B to reference an
object of type A. Define the desired type, such as a Set<B>, for the collection. If
Mapping Database Models to DDLs 161
appropriate, name the attributes to reflect the role that the referenced (related) ob-
ject(s) play(s) in the association. Declare the attributes as inverses of each other.
Define for the collection attribute the one-to-many (or for the reference attribute
the many-to-one), syntactic <association> that corresponds to its graphical repre-
sentation in the database model.
Fig. 8.18 shows how a one-to-many association between employees and depend-
ents (shown previously in Fig. 8.16) is mapped to a pair of object-based attributes.
(If an Employee object is deleted, all Dependent objects referenced by the de-
pendents are implicitly deleted. Also, if a Dependent object reference is removed
from dependents [or if supporter in a Dependent object is set to 0], the De-
pendent object is implicitly deleted.)
For each many-to-many association between classes A and B, add a multi-valued, ob-
ject-based attribute (a collection of references) to class A to reference objects of type
B and a multi-valued, object-based attribute (a collection of references) to class B to
reference objects of type A. Define the desired types, such as a Set<B> and a
List<A>, for the collections. If appropriate, name the attributes to reflect the role
that the referenced (related) objects play in the association. Declare the attributes as
inverses of each other.
Define for one of the attributes the many-to-many, syntactic <association> that
corresponds to its graphical representation in the database model. The direction of
this <association> is from the referencing class to the referenced class.
Fig. 8.19 shows how a many-to-many association between employees and pro-
jects is mapped to a pair of object-based attributes. Unlike the employees and pro-
jects association shown in Fig. 8.15, this association has no association attribute, and
it can never have association attributes if modeled and defined as shown in Fig. 8.19.
162 ORN FOR DATABASE APPLICATIONS
For each intra-class association within a class A, add appropriate object-based attrib-
utes to reference related objects of type A as prescribed for inter-class associations
treating each end of the association as if A was a distinct class. Two caveats to this
directive are 1) for each one-to-one or many-to-many association that is symmetric,
add only one object-based attribute making it an inverse of itself and 2) always use
appropriate role names to name the attributes.
Fig. 8.20 shows how a one-to-many, intra-class, “is a part of” association between
parts is mapped to a pair of object-based attributes. (If a Part object is deleted, all
Part objects referenced by the attribute components are implicitly deleted.)
ans attribute in this object references another Person object. A Person object can-
not be deleted if its guardian attribute contains an existing reference.)
Person
class Person {
ssn d_String ssn;
… …
0..2 * Set<Person> dependents inverse guardians
guardian ' |- dependent '<0..2-TO-*>|-;
Set<Person> guardians inverse dependents;
};
is responsible for ►
{ A Person cannot be both a
guardian and dependent. }
Fig. 8.22 shows how another many-to-many, intra-class association between peo-
ple is mapped to an object-based attribute. Only one attribute is required since the
association is symmetric.
Fig. 8.23, on the following page, shows how two different one-to-one, intra-class
associations between people, which both record marriages, are mapped to object-
based attributes. It provides another example showing that the symmetry of an asso-
ciation affects the number of object-based attributes required. Fig. 8.23 (a) models
the association as non-symmetric and shows its mapping. Fig. 8.23 (b) models the
association as symmetric and shows its mapping.
8.3 Conclusion
As shown in this chapter, the most difficult tasks in mapping associations from a da-
tabase model to a DDL are transforming the model and mapping the associations into
their logical structural representations—foreign keys or object-based attributes. The
easy task, when both the model and DDL include ORN, is mapping the association
semantics.
164 ORN FOR DATABASE APPLICATIONS
class Person {
Person d_String ssn;
ssn …
… Person wife inverse husband
0..1 0..1
<0..1-TO-0..1>;
husband wife Person husband inverse wife;
};
is husband to ►
(a)
class Person {
Person d_String ssn;
ssn …
… Person spouse inverse spouse
0..1 0..1
<0..1-TO-0..1>;
spouse spouse };
is married to ►
(b)
Fig. 8.23 Mapping a one-to-one, intra-class association that is modeled (a) as non-symmetric and
(b) as symmetric
Chapter 9
Association Semantics
Dealing with the Subtleties, Inconsistencies, and Ambiguities
9.1 Inconsistencies
1 This work is based on an earlier work: “Relationship behavior in object databases: subtleties and
inconsistencies,” in Proc. ACM Southeast Regional Conf., 0-89791-826-6 © ACM, 1996.
To describe both types of inconsistencies, some variables are needed. Let us as-
sume an association A between a subject class S and related class R. An <associa-
tion> specification for this association can be described as
bS|bSX<mSL..mSU-to-mRL..mRU>bRXbR|
where bS| is the subject class implicit binding, bSX is the subject class explicit bind-
ing, mSL is the subject class lower bound, mSU is the subject class upper bound, mRL
is the related class lower bound, mRU is the related class upper bound, bRX is the re-
lated class explicit binding, and bR| is the related class implicit binding. In using
these variables to describe associations we must be mindful of the following:
• The class R may be class S with related objects playing a different role in an in-
tra-class association.
• The values of the binding variables may be explicitly or implicitly specified in an
<association>. For example, !<1-to-*>|- explicitly specifies that bR| = |- and
implicitly specifies that bS| = |!, bSX = |!, and bRX = nil.
• mSU > mSL and mRU > mRL when mSU = * and mRU = *, respectively.
• Where two associations are being considered, the variables must be qualified, e.g.,
A.mSL and A'.mSL.
• Inconsistent associations are described from the subject class perspective. Thus,
even though an association A may appear consistent from this perspective, its in-
verse A-1, i.e., the association from the perspective of the related class being the
subject class, may be inconsistent.
Here, inconsistencies are described that can be identified by simply examining a sin-
gle <association>.
9.1.1.3 Involving required deletion of a related object and its implicit bindings
The remaining association inconsistencies discussed in this subsection and the next
are more esoteric and more difficult to describe. Two additional variables will be
useful. The variable SODrROD, meaning Subject Object Deletion requires Related
Object Deletion, is defined as:
SODrROD: bS| = |! or (mSL = mSU and (bS| = |? or bS| = |'))
This condition guarantees for an association that an implicit deletion of any related
object is required when a subject object is deleted.
A similar variable, ELDrROD, meaning Explicit Link Destruction requires Re-
lated Object Deletion, is defined as:
ELDrROD: bSX = X! or (mSL = mSU and (bSX = X? or bSX = X'))
168 ORN FOR DATABASE APPLICATIONS
This condition guarantees for an association that an implicit deletion of the related
object is required when a link is explicitly destroyed.
Using the above variables, the remainder of this subsection and the next subsec-
tion give conditions that describe <association>s that are likely inconsistent. Since
inconsistency is not a certainty, these associations should not be unequivocally disal-
lowed. In certain, unusual circumstances, link cycles together with other associa-
tions can render normally inconsistent associations consistent. More specifically, de-
letion of a subject class object or the implicit deletions of related objects may cause
the implicit deletion of other subject class objects, possibly negating a lower bound
multiplicity violation or the processing of a |- binding that would have otherwise oc-
curred. A simple example to illustrate such a situation is given later in this subsec-
tion. Link cycles occur when an object is indirectly related to itself and are discussed
further in Section 9.3 and more fully in Chapter 10.
The condition IA3 given below describes associations that are likely inconsistent
because on deletion of a subject object or explicit destruction of an A link, a related
R object must be implicitly deleted but cannot be deleted because of the related class
multiplicity and/or implicit binding and the related object’s A links with other sub-
ject class objects.
IA3: (SODrROD or ELDrROD) and mSL > 1 and
((mRL = mRU and bR| = nil) or bR| = |-)
The condition mSL > 1 ensures that another A link involving the related R object ex-
ists besides the one being implicitly destroyed.
Some examples of such associations are given below.
|!<2..*-to-1> !<2..*-to-1>|- |?<3..3-to-0..1>|- '<2..2-to-3..3>
X!<2..*-to-1> !<2..*-to-0..1>|- X?<3-to-1> X'<2-to-*>|-
Fig. 9.1 shows a model and database that can be used to easily illustrate the in-
consistency of the |!<2..*-to-1> association. The deletion of x1 results in the de-
struction of the x1↔y1 link and requires the deletion of y1 (see Table 2.1). y1 is
deleted and the x2↔y1 link is implicitly destroyed, but at the end of the complex
object operation, a lower bound violation results since x2 is not related to a Y object.
So, the deletion of x1 fails.
2..* 1
A1 ►
X |! Y
x1 x2 x1↔y1 y1
x2↔y1
Fig. 9.1 Initial database for a !<2..*-to-1> association
Fig. 9.2 shows the same model and database as that shown in Fig. 9.1 except that
another association A2 has been added along with an A2 link between objects x1
and x2. The added association and link creates a link cycle. Now, the deletion of
Association Semantics: Dealing with the Subtleties, Inconsistencies, and Ambiguities 169
x1 results in the same scenario as that discussed for Fig. 9.1 except that the deletion
of x1 also results in the implicit deletion of x2. So, at the end of the complex object
operation, no lower bound violation results, and the deletion of x1 succeeds. Such
cases are why a likely inconsistent association should not be disallowed.
2..* A1 ► 1
X |! Y
x1 x2 x1↔y1 y1
x2↔y1
0..1 0..1
!
A2 ►
x1↔x2
Fig. 9.2 Initial database for a !<2..*-to-1> association with link cycle y1↔x1, x1↔x2, x2↔y1
9.1.1.4 Involving required deletion of a related object and its explicit bindings
The condition IA4 given below describes associations that are likely inconsistent be-
cause on explicit destruction of an A link, a related R object must be implicitly de-
leted but cannot be deleted because of the related class multiplicity and/or explicit
binding.
IA4: ELDrROD and ((mRL = mRU and bRX = nil) or bRX = X-)
Some examples of such associations are given below.
X!<1-to-1> !<1-to-0..1>X- X?<3..3-to-1> '<1-to-3..3>
Although explicit link destruction may be impossible with these associations, link
changes involving replacement of the related object may still be valid, which is an-
other reason for not disallowing them. For example, assume the model and database
shown in Fig. 9.3. Attempting to destroy the link x1↔y1 results in a lower bound
multiplicity exception since y1 would be implicitly deleted (because of X!) and thus
x1 would not be linked to a Y object. (The link x1↔y1, however, can be changed
in a single operation that replaces y1 with another Y object, such as y2, an object
created within an as yet uncommitted transaction. The y1 object is implicitly de-
stroyed and no exception results since x1 has its required Y object, y2).
1 A1 ► 1
X X! Y
x1 x1↔y1 y1
1 1
A1 ►
X |! Y
x1 x1↔y1 y1
y1↔z1 A2 ▼
Z
z1
The algorithm given in Fig. 9.5 verifies the consistency of ORN specifications given
for all associations in a database. It has been implemented in C++ and integrated
into the analysis phase of the ODDL processor of OR+. It traverses through all asso-
ciation descriptions in the meta-database analyzing multiplicities and bindings.
When an inconsistency is detected, an appropriate error or warning message is out-
put.
The algorithm results in all associations being checked for inconsistencies from
the perspective of each class (or role) serving as the subject class (or role). All com-
binations of associations sharing a common class are also checked for inconsisten-
cies. The checks for inconsistencies within a single association can be done immedi-
ately after an <association> is specified (or parsed), while the checks for
inconsistencies involving association combinations can be deferred until all <asso-
ciation>s have been specified.
As shown in Chapter 3, the ORN Simulator allows users to define associations us-
ing ORN and observe association semantics as objects are created and deleted and
association links are created, destroyed, and changed. Association inconsistencies
are detected by the algorithm given in Fig. 9.5 and messages that flag these inconsis-
tencies as errors or warnings appear on the ORN Simulator screen when the user en-
ters the <association> for a relationship. For example, the screen shown in Fig. 9.6
shows the warning message that appears after the user defines the <association> for
the R2 relationship as 1-to-1. Here, the ORN Simulator has detected the inconsistent
combination of associations that was discussed in Section 9.1.2 and illustrated using
Fig. 9.4.
172 ORN FOR DATABASE APPLICATIONS
Fig. 9.6 Screen showing detection of association inconsistency in the ORN Simulator.
9.3 Ambiguities
erative. For example, in Fig. 9.7, assume an attempted deletion of object z1. If the
y2↔z1 link of A1 is processed first, the |- is inoperative (since the y2↔z1 link of
A2 is destroyed on the implicit deletion of y2) and the deletion succeeds; however,
if the y2↔z1 link of A2 is processed first, the |- binding is operative and the dele-
tion fails. Which is it? (The reader can verify these outcomes based on Table 2.1 or
see Section 10.2.2.1, Case 1 for a more detailed explanation of this example.)
A1 ►
|!
* y2↔z1 0..1
Y Z
y2 z1
A2 ►
* |- 1
y2↔z1
Fig. 9.7 Database model with one-ended |- and database with link cycle z1↔y2, y2↔z1
The second ambiguous specification is a cyclic non-dependent |' with partly sacri-
ficial siblings. Again, using the variables defined in the previous sections for de-
scribing an <association>, the following condition describes this specification for
an association A and an association A', where here A' is an association involving a
class related to class S directly by the association A (which may be an intra-class as-
sociation) or indirectly via A and other associations having a subject class implicit
cascade binding of |? or |!.
(A.bS| = |! and A.mSL ≠ A.mSU and A'.bS| = nil and A'.mSL ≥ 1 and A'.mSU > A'.mSL)
and a link cycle exists including A and A' links
If the related class described above is directly related to the subject class S of A,
i.e., it is the related class R of A, then A' may be A-1.
The above condition may or may not result in an ambiguous outcome on an object
deletion, explicit link destruction, or link change. Such an outcome will most likely
result when the link cycle makes it unclear which object in the related class, i.e., the
subject class of A', will be the “surviving sibling,” i.e., the one needed to satisfy
A'.mSL, and which will be a “sacrificial sibling,” i.e, the one not needed to satisfy
A'.mSL.
For example, in Fig. 9.8, assume an attempted deletion of object x1. If the
x1↔y1 link is processed first, the y1 object is implicitly deleted, y1↔z1 is the
sacrificial link, the y2 object survives, and the deletion of x1 succeeds; however, if
the x1↔y2 link is processed first, the y2 object is implicitly deleted, y2↔z1 is the
sacrificial link, the y1 object survives, and again the deletion of x1 succeeds. So,
which Y object survives? (Again the reader can verify these outcomes based on Ta-
ble 2.1 or see Section 10.2.2.2 for a more detailed explanation of this example.)
174 ORN FOR DATABASE APPLICATIONS
0..1 *
A1 ►
X |' Y
x1 x1↔y1 y1 y2
x1↔y2
1..*
y1↔z1
A2 ▼
y2↔z1
0..1
Z
z1
Fig. 9.8 Database model with cyclic non-dependent |' with partly sacrificial siblings and database
with link cycle x1↔y1, y1↔z1, z1↔y2, y2↔x1
Modeling tools can check for the possibility of link cycles in the modeled data-
base, detect <association> specifications that may result in ambiguous outcomes,
and display appropriate warnings. This capability is planned for a future version of
the ORN Simulator.
domain there is an object x in the domain such that f(x) = y. A single-valued function
f is bijective if and only if it is both injective and surjective.
The definitions of terms given in the previous paragraph are also applicable to the
function g with S everywhere replaced by R and R by S.
To show that 0..1-to-1, 0..1-to-1..*, and 1-to-1..* associations are not valid as in-
tra-class associations, let X be a set of objects {x1, x2, ..., xn} representing the set of
all of the instantiated objects of class X, i.e., the extension of class X.
First, assume that a 0..1-to-1 association exists between the objects of X. Let f: X
→ X be the single-valued, total, injective function and g: X' → X, where X' ⊆ X, be
the single-valued, partial, bijective function corresponding to the association and in-
verse association, respectively. Let g(xi) be undefined for some xi ∈ X. Then for all
x ∈ X, f(x) ≠ xi, otherwise g(xi) = x and g(xi) would be defined. Since f is total, the
pigeonhole principle requires that for some xl ≠ xi and xj, xk, xl ∈ X, f(xj) = f(xk) = xl.
But this contradicts the fact that g is single-valued (or that f is injective). Therefore,
a 0..1-to-1 association between the objects of X is invalid.
The proof for 0..1-to-1..* is similar. Assume that a 0..1-to-1..* association exists
between the objects of X. Let f: X → P(X) - Ø be the set-valued, total function and g:
X' → X, where X' ⊆ X, be the single-valued, partial, surjective function correspond-
ing to the association and inverse association, respectively. Let g(xi) be undefined
for some xi ∈ X. Then for all x ∈ X, xi ∉ f(x), otherwise g(xi) = x and g(xi) would be
defined. Since f is total, the pigeonhole principle requires that for some xl ≠ xi and xj,
xk, xl ∈ X, xl ∈ f(xj) and xl ∈ f(xk). But this means that g(xl) = xj and g(xl) = xk, which
contradicts the fact that g is single-valued. Therefore, a 0..1-to-1..* association be-
tween the objects of X is invalid.
Finally, assume that a 1-to-1..* association exists between the objects of X. Let f:
X → P(X) - Ø be the set-valued, total function and g: X → X be the single-valued, to-
tal, surjective function corresponding to the association and its inverse, respectively.
Let the cardinality of f(xi) be greater than one for some xi ∈ X. Then, since f is total,
176 ORN FOR DATABASE APPLICATIONS
there is at least one xl ∈ X such that xl ∈ f(xj) and xl ∈ f(xk) for some xj, xk ∈ X. But
this means that g(xl) = xj and g(xl) = xk, which contradicts the fact that g is single-
valued. Therefore, a 1-to-1..* association between the objects of X is invalid.
The validity of the other <multiplicities> descriptions as intra-class associations
can be shown by simple examples. These are given in Fig. 9.9, where X is assumed
to contain objects x1, x2, and x3 and the functions f and g are as defined in Table 9.1.
A “--” denotes that the function is undefined for a particular object.
*-to-1 *-to-*
x f(x) g(x) x f(x) g(x)
−−− −−−− −−−−−−−−−− −−− −−−−−−−− −−−−−−−−−−
x1 x2 -- x1 {x2,x3} --
x2 x3 {x1,x3} x2 {x3} {x1}
x3 x2 {x2} x3 -- {x1,x2}
*-to-1..* 1..*-to-1..*
x f(x) g(x) x f(x) g(x)
−−− −−−−−−−−−− −−−−−−−−−− −−− −−−−−−−−− −−−−−−−−−−
x1 {x2,x3} -- x1 {x2,x3} {x3}
x2 {x3} {x1,x3} x2 {x3} {x1}
x3 {x2} {x1,x2} x3 {x1} {x1,x2}
Real associations can be ascribed to each of the examples in Fig. 9.9. For ex-
ample, an “is a guest of” relationship between persons at a party in which everyone
can bring at most one guest is an example on a 0..1-to-0..1 intra-class association.
An example of a 1..*-to-1..* intra-class association is an “is reviewed by” associa-
tion between a class of students where each student must have their work reviewed
by at least one other student and each student must review the work of at least one
other student.
0..1-to-0..1, 1-to-1, *-to-*, and 1..*-to-1..* intra-class associations may be sym-
metric. For example, the 0..1-to-0..1 “is a spouse of” association is a symmetric as-
sociation. For such relationships, f and g are the same function.
Association Semantics: Dealing with the Subtleties, Inconsistencies, and Ambiguities 177
9.5 Conclusion
This chapter has used ORN to describe inconsistencies and ambiguities that can oc-
cur when defining the semantics for an association and for combinations of associa-
tions involving common classes. These inconsistencies and ambiguities can occur
when using other notations to define association semantics—like the ON DELETE,
NOT NULL, and UNIQUE clauses in SQL—or when association semantics are “de-
fined” only by their implementations in application programs, class methods, or SQL
constraints and triggers.
The SQL depicted in Fig. 9.10 illustrates this. A foreign key, which must be
NOT NULL, in the table Y references table X. An ON DELETE CASCADE is
given for this foreign key. Another foreign key, which must be NOT NULL, in table
Z references table Y. An ON DELETE NO ACTION is the default for this foreign
key. CHECK constraints given for tables X and Y ensure that for both foreign keys
every row in the referenced table has at least one matching row in the referencing ta-
ble. These notations define associations that are likely inconsistent. Deletion of a
row in table X causes the deletion of all matching rows (via Y.fk) in table Y, but this
likely causes a referential integrity exception since all of the rows in table Y have at
least one matching row (via Z.fk) in table Z. So, unless things are somehow “fixed
up” by other referential actions, at least one Z.fk value exists that does not reference
any row in table Y.
…
CREATE TABLE X (
pk … PRIMARY KEY,
…
CONSTRAINT C1 CHECK ((SELECT COUNT(*) FROM Y WHERE Y.fk = X.pk) >= 1)
);
CREATE TABLE Y (
pk … PRIMARY KEY,
...
fk … NOT NULL REFERENCES X ON DELETE CASCADE,
CONSTRAINT C2 CHECK ((SELECT COUNT(*) FROM Z WHERE Z.fk = Y.pk) >= 1)
);
CREATE TABLE Z (
pk … PRIMARY KEY,
...
fk … NOT NULL REFERENCES Y
);
Fig. 9.10 Likely inconsistent associations implemented in SQL
With ORN, database designers can craft association semantics during database
modeling, thereby permitting problematic semantics to be detected before any coding
or even database definition commences. In the above SQL example, the association
between the objects represented by tables X and Y is |!<1-to-1..*>, and that between
Y and Z is <1-to-1..*>, although it is very hard to tell. When using an ORN-
extended modeling tool, like the ORN Simulator, these <association>s properly re-
sult in a warning of inconsistent associations.
Chapter 10
This chapter presents algorithms that implement ORN semantics. The algorithms are
given at a conceptual level in terms of classes, objects, associations, and links. They
provide context for and more detail on the system actions given for each binding in
Table 2.1, thus providing a very precise algorithmic description of ORN semantics.
Moreover, the algorithms outline the code that translation tools must generate to
implement ORN in a database system. In OR+, discussed in Chapter 7, this code is
implemented as methods on abstract, persistent classes that are defined to an
ODBMS. In ORN Additive, discussed in Chapter 6, this code is implemented as
stored procedures and triggers on ORN-related tables that are defined to a RDBMS.
Chapter 12 recasts the algorithms given here in terms compatible for their implemen-
tation in a standard ODBMS (Cattel 2003). The algorithms can also be recast for
implementation within an RDBMS to support the integration of ORN into SQL as
discussed in Chapter 11. This task is left to RDBMS developers and would provide
a much more efficient implementation than that provided by ORN Additive.
Besides presenting algorithms that implement ORN, this chapter shows that these
algorithms terminate despite processing cyclically linked data and that their results
are deterministic, with two exceptions. The former characteristic ensures that ORN
semantics are non-circular and the later ensures they are mostly unambiguous.
We examine both characteristics in the context of link cycles within a database.
A link cycle occurs when an object is related to itself indirectly—i.e., x0↔x1, x1↔x2,
..., xn↔x0 where n ≥ 1. The potential problems posed by such cycles to ORN seman-
tics⎯infinite and alternative processing paths, resulting in circularity and ambigu-
ity⎯are inherent in any scheme that defines association semantics recursively, as
does ORN.
This chapter significantly improves on the algorithmic description of ORN and re-
lated discussions on link cycles, circularity, and ambiguity first given in Ehlmann et
al. (2002).1 It is organized as follows. Section 1 presents and explains the high-level
algorithms. Section 2 explores their operation in the context of link cycles, provid-
ing examples of ORN-defined associations and sample databases that demonstrate
algorithm termination and two kinds of problematic ORN specifications that can re-
sult in nondeterministic results. Possible solutions are discussed, and a theorem with
proof is given that ORN semantics are unambiguous in the absence of the two prob-
lematic specifications. Section 3 concludes with some summary remarks.
1 Portions reprinted, with permission, from “Specifying and enforcing association semantics via
ORN in the presence of association cycles,” IEEE Trans on Knowl and Data Eng 14, 6:1249-1257.
© 2002 IEEE.
10.1 Algorithms
The implementation of ORN semantics is described by the algorithms that create ob-
jects and association links, delete objects, and destroy and change association links
in a database. These operations become complex object operations in the context of
ORN. In this section, we describe these algorithms.
The conceptual nature of the algorithms makes them independent of a particular
implementation, object or relational. A link between objects x and y, mathematically
an ordered pair (x, y), is represented in the algorithms as x↔y where x is the subject
object and y is the related object. The type of a link is the association of which it is
an instance. The objects of a link, along with its type, make it unique. Every asso-
ciation A has an inverse association, A-1, where the roles of subject and related class
are reversed. If x↔y is a link of type A, y↔x is a link of type A-1.
This section indicates how the conceptual algorithms can translate into an actual
relational or object database implementation. In an object database, an association is
represented by an object-based attribute, e.g., customer in the class Order (Fig.
1.18), and the inverse association by an inverse object-based attribute, e.g., orders in
class Customer. In a relational database, an association is represented by a foreign
key attribute, e.g., custNo in table Order (see Fig. 1.8), and the inverse association
is represented only implicitly by the rows in the referencing table having matching
foreign key values to the primary key value in each row of the referenced table.
In addition to providing a conceptual view of the actual implementation of ORN
in OR+, which is discussed in Chapter 7, the algorithms provide a simplified, ab-
stract view of this implementation. For instance, they do not show the details of
handling all types of errors, e.g., improper transaction operations. They also do not
show all of the details needed to properly handle association inheritance.
The algorithms are given in a pseudocode where compound statements within
control structures are indicated by indentation. Also, the input, output, and in-
put/output nature of parameters is implicit from the comments describing the algo-
rithm. Comments are prefaced by a //. Finally, the function type(x) is used, which
when x is an object, returns the most specific class in any class hierarchy for which x
is an instance, and when x is a link, returns the association for which x is an instance.
ject that has a lower bound multiplicity constraint for the related class. LbChecks is
associated with the current application-defined transaction, whose existence is as-
sumed by CreateObject and referenced by t. Creation and modification of relat-
able objects must take place within such a transaction. When it commits, checks are
made on each existing object and association referenced in LbChecks to ensure that
lower bound multiplicities for related classes are not violated.
Algorithms for the transaction commit operation as well as those for transaction be-
gin and transaction abort are given in Figure 10.2. These operations perform the
standard database functions required for beginning, aborting, and committing a
184 ORN FOR DATABASE APPLICATIONS
transaction. They must, however, be extended for ORN to perform actions related to
checking lower bound multiplicities and tracking object deletions. They also must
support nested transactions.
The Begin algorithm initializes two object sets, Deletes and LbChecks, to
empty. These sets are associated with every transaction. Deletes is the set of all ob-
jects marked for deletion so far by the transaction, including objects marked for dele-
tion by any committed nested transactions. LbChecks, discussed previously, is the
set of all (object, association) pairs where the object is an instance of the subject
class in the given association and where for this object the lower bound multiplicity
for the related class must be checked at transaction commit, provided the object has
not been previously marked for deletion. The Commit algorithm shows how the sets
Deletes and LbChecks are used to do the appropriate lower bound constraint
checking.
This subsection presents pseudocode that supports the algorithms for the complex
object operations CreateLink, DeleteObject, DestroyLink, and ChangeLink. This
pseudocode provides a wrapper algorithm, which invokes the complex object opera-
tion, and a sub-algorithm, which is invoked by three of these operations.
The algorithms for the complex object operations are invoked within a system-
supplied nested transaction, providing a wrapper for each such algorithm. The
nested transaction, given in Fig. 10.3, results when a complex object operation is
specified within an application-defined transaction. A translation of the specific syn-
tax for this operation must provide the appropriate arguments to the corresponding
CreateLink, DeleteObject, DestroyLink, or ChangeLink algorithm as defined in a
subsequent subsection. The nested transaction ensures that these operations are
atomic.
Begin(t, d);
Invoke the CreateLink, DeleteObject, DestroyLink, or ChangeLink algorithm corresponding to the
specified complex object operation;
if exception then
Abort(t, d);
raise exception
else
Commit(t, d)
if exception then
Abort(t, d);
raise exception
Fig. 10.3 Invocation of a complex object operation in a nested transaction
algorithm enforces an ORN binding. The reader should compare its pseudocode to
the system actions described for each binding in Table 2.1.
When the lower bound multiplicity is violated on a default, i.e., nil, or ' binding,
an exception does not immediately result; rather, the related object and applicable
association are inserted into the set t.LbChecks, deferring any possible exception
until the end of the operation, i.e., the nested transaction commit. These actions ef-
fectively implement the semantic specified by footnote 2 in Table 2.1 and will be
important to remember in the next section.
The ' binding requires yet another nested transaction to appropriately implement
its semantics. If an exception occurs within this transaction, it is simply ignored and
the transaction is aborted; however, a deferred lower bound check on the commit of
the parent, nested transaction can still result in an exception.
The cascade binding cases in EnforceBinding can result in a recursive invocation
of DeleteObject. This recursion is the focus of much discussion in the next section.
based attributes of the subject and related objects. In a relational database, this
means setting the foreign key to an appropriate primary key value.
The DeleteObject algorithm, given in Fig. 10.6, deletes an object x and appropri-
ate related objects as defined by ORN. Every association involving the object x is
accessed by the outer for each loop. In the inner for each, an existing link is im-
plicitly destroyed before any implicit related object deletion is attempted in Enfor-
ceBinding. Thus, the destroyed link is not considered when determining whether or
not an implicit deletion of the related object is possible—that is, it is no longer an ex-
isting link.
The DestroyLink algorithm, given in Fig. 10.7, destroys a link and via Enforce-
Binding may cascade this destruction to appropriately related objects as defined by
ORN. The algorithm invokes EnforceBinding twice to enforce the bindings at each
end of the association for the link, treating in turn each object in the link as the sub-
ject object.
Others have studied the problems posed by “link cycles” within relational databases
and SQL (Date 1990, Date and Darwen 1994, Howowitz 1992), although in these
studies such cycles were called referential cycles, and the concern was not in main-
taining multiplicities as with ORN, but rather in maintaining referential integrity.
Some of this previous work, however, is germane to our exploration of link cycles in
this section where we deal at the entity or object level.
Actually, what was defined as a referential cycle in this previous, relational data-
base work would be called an association cycle in a conceptual data model. An as-
sociation cycle occurs in a model when a class is related to itself directly via an intra-
class association or indirectly via associations with other classes. An association cy-
cle in a model can result in a link cycles in a database as we shall see; however, a
link cycle can occur in a database even without the presence of association cycles in
the database model or DDL, as we shall also see.
To investigate the problems caused by link cycles, we will study some simple ex-
amples of such cycles.
A Conceptual Implementation of ORN: Exploring Semantic Circularity and Ambiguity 189
10.2.1 Circularity
Fig. 10.9 depicts one example. An association cycle is present in the model be-
cause objects of class Y can be related to the objects of class Z via the A1 association
and the objects of class Z can be related to the objects of class Y via the A2 associa-
tion. There are just two objects in the database, y1 and z1, and two links, y1↔z1
of association A1 and y1↔z1 of A2. The association cycle in a database model al-
lows link cycles to develop in the database, here the cycle is z1↔y1, y1↔z1.
A1 ►
|!
* y1↔z1 0..1
Y Z
y1 z1
A2 ►
0..1 |! *
y1↔z1
Fig. 10.9 Link cycle z1↔y1, y1↔z1
scenario above shows, the DeleteObject algorithm detects a cycle and terminates
recursion by means of the set Deletes. Objects are marked for deletion by placing
them into this set. Then, recursive propagation of implicit deletes is terminated when
an object to be deleted is found in t.Deletes or the Deletes of any ancestor transac-
tion, i.e., when a link cycle is detected.
Note that in deleting z1 via the DeleteObject algorithm, as described above, the
order in which the associations were processed did not matter. Unfortunately, this is
not always the case.
10.2.2 Ambiguities
Two kinds of ORN specifications can potentially cause the algorithms implementing
ORN to have nondeterministic, i.e., unpredictable or ambiguous, results. One in-
volves the |- binding and the other the |' binding when these bindings are specified
for associations having links within link cycles. These specifications were briefly
described in Section 9.3. Here, we analysis them in more detail.
A1 ►
|!
* y2↔z1 0..1
Y Z
y2 z1
A2 ►
* b 1
y2↔z1
Fig. 10.10 Link cycle z1↔y2, y2↔z1
* 0..1
A1 ►
Y |! Z
y1 y2 y1↔z1 z1
y2↔z1
* 0..1
|-
A2 ►
y1↔y2
Fig. 10.11 Link cycle z1↔y1, y1↔y2, y2↔z1
Fig. 10.11 is an example of a link cycle involving links of the same association.
Again, we examine what happens when an attempt is made to delete z1.
• If the y1↔z1 link of A1 is processed first, trying to delete z1 causes an implicit
destruction of this link and an implicit delete on y1, which will be successful and
result in the implicit destruction of the y1↔y2 link of A2. Now, when the
y2↔z1 link of A1 is processed, this link is implicitly destroyed, and an attempt
192 ORN FOR DATABASE APPLICATIONS
is made to delete y2, which will succeed since the y1↔y2 link no longer exists.
Thus the delete of z1 is successful.
• If the y2↔z1 link of A1 is processed first, trying to delete z1 causes an implicit
destruction of this link and an implicit delete on y2, which will be unsuccessful
because the |- binding prevents the destruction of the y2↔y1 link of A2-1. The
complex object operation will be rolled back.
Again, note that if the binding on the * end of association A2 was |-, the delete of
z1 would always be unsuccessful.
Besides the potential circularity problem, another problem with link cycles is evi-
dent from the above examples. They can cause the outcome of a complex object op-
eration to be dependent on the order in which associations and links are processed.
This can occur because cycles provide two alternate processing paths from one ob-
ject to another and those paths can have different semantics. Fig. 10.10, case 1
shows that outcomes can be dependent on the order in which different associations
are processed, and Fig. 10.11 shows that outcomes can be dependent on the order in
which the links of a single association are processed. When processing order is un-
specified or indeterminate⎯as it is in relational database definitions and formal
mathematical notations, both involving iterations over (unordered) sets⎯undesirable
anomalies can occur when within an implementation an ordering must be selected
(Date 1990).
There are many ways to avoid this unpredictability. The following list borrows
from Date (1990).
1. Ideally, we could redesign the language or notation so that there is no loss in func-
tionality and processing order does not matter.
2. We could somehow allow the user to specify the processing order when it matters.
3. The system could try all possible processing orders at run-time and always fail if
any of them fail (or always succeed if any succeed).
4. Cases where processing order may matter could be detected at definition time and
be disallowed.
The reader can probably discern the relative merits of each of these solutions. In
the evolution of ORN we have used solution 1, and a database developer can cur-
rently employ 2 to some extent in OR+.
The |- binding can cause processing order dependencies only when it is given for
just one end of an association having links within a link cycle. This is evident in the
previous scenarios and is formally proven in Section 10.2.3. The |- binding is simi-
lar to the RESTRICT referential integrity rule in SQL and suffers the same problem
(Date and Darwen 1994, Horowitz 1992). Unlike the RESTRICT, however, the |-
binding can be protected from a “rear attack” by specifying this same binding for
both ends of an association. In Figs. 10.10 and 10.11, when the |- binding is given
for both ends of the A2 association, dependencies on the order of processing are
eliminated, and the delete of z1 is always unsuccessful.
Use of the |- on only one end of an association when links of the association can
form a link cycle, i.e., a cyclic one-ended |-, is often desirable and harmless, which is
A Conceptual Implementation of ORN: Exploring Semantic Circularity and Ambiguity 193
why it is not simply disallowed. In Fig. 10.12, a one-ended |- is used where no un-
predictability results even though the intra-class association results in an association
cycle in the model, which results in a link cycle in the database. Child c1 is sup-
ported by employee e1, who is married to e2, who also supports c1 (c1↔e1,
e1↔e2, e2↔c1). When a cyclic one-ended |- results in unpredictability, solution
4 above could be adopted to disallow it, but this was not done in OR+ since link cy-
cles are not inevitable when association cycles exist in the database model and a
warning can be issued.
1..2 *
supports ►
Employee ' |- Child
e1 e2 e1↔c1 c1
e2↔c1
0..1 0..1
married
to ►
e1↔e2
Fig. 10.12 Link cycle c1↔e1, e1↔e2, e2↔c1
As shown in Chapters 4 and 5, the |' (implicit tentative cascade) binding provides
powerful semantics that are useful in describing a number of association types.
These semantics, however, come with a small price. It is possible (though rare) that
194 ORN FOR DATABASE APPLICATIONS
ssociations are defined where the precise results of an object deletion can be am-
biguous. The necessary conditions for this ambiguity are rather esoteric. They are:
• A class in an association has an implicit ' binding and a multiplicity m..n where m
≠ n, allowing related objects to be non-dependent.
• A related class has an association with an implicit default binding and a multiplic-
ity m..n where m ≥ 1 and n > m for the subject class. This related class is di-
rectly related by the association having the |' binding (which may be an intra-class
association) or it is indirectly related via this association and other associations
having a subject class implicit cascade binding unlike the ' binding being de-
scribed.
• a link cycle exists involving objects related by the above described associations.
This situation can be characterized as a cyclic non-dependent |' with partly sacrificial
siblings.
0..1 *
A1 ►
X |' Y
x1 x1↔y1 y1 y2
x1↔y2
1..*
y1↔z1
A2 ▼
y2↔z1
0..1
Z
z1
Fig. 10.13 Initial database with link cycle x1↔y1, y1↔z1, z1↔y2, y2↔x1
The model shown in Fig. 10.13 shows such a non-dependent |' binding and the da-
tabase exemplifies a link cycle involving this binding and some partly sacrificial sib-
lings. The 0..1 multiplicity for class X in association A1 makes the |' binding “non-
dependent.” (y1 and y2 are not dependent on x1). The “siblings” here are y1 and
y2, both being “children” of z1. The fact that there are two of them related to z1
when the multiplicity for Y in association A2 is 1..* makes them “partly sacrificial,”
i.e., one of them can be deleted. We will examine what happens when an attempt is
made to delete x1. There are two possible scenarios.
• If the x1↔y1 link of A1 is processed first, trying to delete x1 causes an implicit
destruction of this link and an attempted implicit delete on y1, which will be suc-
cessful and result in the implicit destruction of the y1↔z1 link of A2. This latter
link is destructible since the implicit binding for Y in the A2 association is default
and the 1..* multiplicity is not violated. Now, when the x1↔y2 link of A1 is
processed, this link is implicitly destroyed, and an attempt is made to implicitly
A Conceptual Implementation of ORN: Exploring Semantic Circularity and Ambiguity 195
delete y2. This, however, does not succeed since the lower bound multiplicity of
1 (for Y in A2) is violated. (This is detected by the Commit algorithm, Fig. 10.2,
which was called in case “'” of the EnforceBinding algorithm, Fig. 10.4, which
was called by the DeleteObject algorithm, Fig. 10.6, which was called to delete
x1.) Basically, z1 must be related to at least one Y object. Thus the attempted
implicit deletion of y2 is aborted (in EnforceBinding), the deletion of x1 is suc-
cessful (since deletion of y2 is not required), and the database shown in Fig.
10.14 results.
0..1 *
A1 ►
X |' Y
y2
1..*
y2↔z1 A2 ▼
0..1
Z
z1
Fig. 10.14 Resultant database after deletion of x1 when link x1↔y1 is processed first
0..1 *
A1 ►
X |' Y
y1
1..*
y1↔z1 A2 ▼
0..1
Z
z1
Fig. 10.15 Resultant database after deletion of x1 when link x1↔y2 is processed first
10.2.3 The Theorem for ORN Semantic Clarity and its proof
Here we state and prove a theorem that ORN semantics are unambiguous in the ab-
sence of the two problematic bindings discussed in the previous subsection. The
proof for this Theorem for ORN Semantic Clarity is quite lengthy but includes some
explanation, using examples given in the previous subsection.
Theorem: If no cyclic one-ended |- binding and no cyclic non-dependent |' bind-
ing with partly sacrificial siblings are given for an association, then the semantics of
ORN are unambiguous—that is, the outcome of a complex object operation under
ORN semantics is independent of the order in which links are processed.
Proof: A complex object operation is a link creation or an explicit object dele-
tion, link destruction, or link change. As can be seen in Fig. 10.5, the LinkCreate
A Conceptual Implementation of ORN: Exploring Semantic Circularity and Ambiguity 197
algorithm involves no recursion, and while it may create link cycles, it is unaffected
by them. It processes only one link and thus results are independent of the order in
which links are processed.
We next consider explicit object deletion.
If the object being deleted and all objects linked to it directly or indirectly are not
part of any link cycle, then there is only one processing path to any related object or
link and thus only one possible outcome.
If, however, the object being deleted or any object linked to it directly or indi-
rectly is part of one or more link cycles, then there can be multiple processing paths
to related objects and links. We must show that the result of an object deletion will
be unaffected by the order in which links are processed. We do this by showing that
the result of executing the DeleteObject algorithm, invoked in a nested transaction
t, as shown in Fig. 10.3, to delete an object x in database d, is unaffected by the order
in which the links of x or any related object are processed.
This result, denoted by R, is determined by whether or not exit is with exception,
and if not, the elements that are contained in three sets at the time of commit of any
transaction t, where t is the transaction wrapping the complex object operation (see
Fig. 10.3) or any nested transaction within this transaction. The three sets are:
• the set t.Destroys of links that have been destroyed, which are all the links de-
stroyed in transaction t and all ancestor transactions
• the set t.Deletes' of objects that are or will be deleted, which is the union of
t.Deletes and the set Deletes for all ancestor transactions
• the set t.LbChecks' of object-association pairs defining the lower bound multiplic-
ity checks that must be done at the commit of t, which is {(sO, A) | (sO, A) ∈
t.LbChecks ∧ sO ∉ t.Deletes'}
Note that the sets t.Destroys, t.Deletes', and t.LbChecks′ determine the results of the
lower bound multiplicity checks, so that these results are not an issue.
Let o be x or any object that is related to x directly or indirectly. Assume that
prior to the invocation of DeleteObject(x, t, d), o has n links to related objects,
o↔o1, o↔o2, ..., o↔on. The links may involve one or more association types, the n
related objects may not all be unique and may in fact be o, and o may be part of one
or more link cycles.
If o is being explicitly deleted, then prior to DeleteObject(o, t, d), none of o’s
links have been implicitly destroyed. If, however, o is being implicitly deleted, then
prior to DeleteObject(o, t, d) one of its links, i.e., an entry link, has already been de-
stroyed─e.g., the y2↔z1 link of A1 for object y2 in Fig. 10.10, Case 1, when A1 is
processed first.
Furthermore, if o is part of one or more link cycles, then before a link can be
processed by DeleteObject(o, t, d), it may have become a casualty link or a crucial
surviving sibling link. A casualty link is one that has already been implicitly de-
stroyed as the result of the attempted deletion of a related object in a link cycle─e.g.,
the y2↔z1 link of A2 for object z1 in Fig. 10.10, Case 1, when A1 is processed
first. A vital surviving sibling link is one that has had a sibling link, i.e., one having
the same related (parent) object, destroyed and is now vital in satisfying a lower
198 ORN FOR DATABASE APPLICATIONS
bound on the number of siblings required─e.g., the y2↔z1 link of A2 for object y2
in Fig. 10.13, when the x1↔y1 of A1 is processed first and the sibling link y1↔z1
as been destroyed. The later link will be called a sacrificial sibling link.
Without link cycles, an entry link does not change, and there are no casualty links
or vital surviving sibling links. With link cycles, whether or not a specific link is an
entry or casualty link or has become a vital surviving sibling link before its process-
ing in DeleteObject(o, t, d) is processing order dependent. Therefore, to show
processing order independence, we must show that R will be unaffected if any link,
o↔ok, 1 ≤ k ≤ n, has become an entry or casualty link, i.e., it has already been de-
stroyed, or has become a vital surviving sibling link, rather than a sacrificial one, be-
fore being processed by DeleteObject(o, t, d). We consider below for each compo-
nent of R each possible implicit destructibility binding for the object class of o in the
association of which o↔ok is a link. This binding is given as impB in DeleteObject
(Fig. 10.6) and as b in EnforceBinding (Fig. 10.4), which is invoked by DeleteOb-
ject and shows the actions taken in each case of implicit binding.
Exit with exception. The only situation in which DeleteObject exits with an ex-
ception is when a |- is detected by EnforceBinding. This occurs in case “|-” when
detected in the immediate invocation of DeleteObject and cases “|?” and “|!” when
detected in a recursive invocation.
First, assume the |- binding. Here we apply the theorem’s hypothesis that there
are no cyclic one-ended |- bindings, which means that any |- binding for links within
a link cycle is two-ended. If o↔ok has already been destroyed, then an exception
will have already occurred because of the |- binding for the ok object class. (This
situation is exemplified in Fig. 10.10, Case 1 where the implicit default binding for
class Y in association A2 is replaced with a |-.) Thus, with a |- binding at both ends
of the association, the link o ↔ ok cannot really be an entry or casualty link. It also
cannot be a vital surviving sibling link or a sacrificial sibling link since no sibling
link can be implicitly destroyed.
Now assume the |? binding and an sLB violation or a |! binding, and assume that
the invocation of DeleteObject on ok results in an exception. If o↔ok has already
been destroyed, then a DeleteObject has already been invoked on ok, which has re-
sulted or will result in the same exception (based on encountering a |- binding unre-
lated to o↔ok). Note that if ok has been implicitly deleted as a result of a ' binding, is
uncommitted, and will subsequently be undone (i.e., we are in an nT transaction that
will be aborted), then the results of DeleteObject(o, t, d) will also be undone.
t.Destroys. In all cases of impB, o↔ok is destroyed in DeleteObject before En-
forceBinding is called. Thus, t.Destroys is unaffected if o↔ok has already been de-
stroyed or is or is not a vital surviving sibling link.
t.Deletes'. In all cases of impB, o is added to t.Deletes, and thus to t.Deletes', in
DeleteObject before EnforceBinding is called. Cases “|?”, “|!”, and “|'” of impB
may implicitly delete ok, thus adding it to t.Deletes'; however, if o↔ok has already
been destroyed, then a DeleteObject has already been invoked on object ok, and ok
is already in t.Deletes'.
A Conceptual Implementation of ORN: Exploring Semantic Circularity and Ambiguity 199
If o↔ok has not already been destroyed, it may be a vital surviving sibling link,
which means that a sibling link has already been destroyed, i.e., sacrificed. If so,
then ok has not been deleted, i.e., it is not in t.Deletes'. Cases “|!”, and “|'” of impB
always implicitly delete ok, thus adding it to t.Deletes'. This is true even if o↔ok is
not a vital surviving sibling link. But if it is, for case “|?”, sLB is violated and ok is
implicitly deleted, thus adding it to t.Deletes'. This result is different than that which
would have occurred had o↔ok not been a vital surviving sibling link, but instead a
sacrificial sibling link, i.e., one whose destruction did not violate sLB. In this case,
ok is not implicitly deleted and thus not added to t.Deletes'. Regardless, whether
o↔ok is the vital surviving sibling link or it is merely a sacrificial one and some
other link is the vital surviving sibling link, ok, the common related object, will be
implicitly deleted and added to t.Deletes'. This situation is exemplified in Fig. 10.16
(a revision of Fig. 10.13) where on an attempt to explicitly delete x1, regardless of
which link, y1↔z1 or y2↔z1, becomes the sacrificial one and which the vital
surviving one, z1 is implicitly deleted.
0..1 *
A1 ►
X |! Y
x1 x1↔y1 y1 y2
x1↔y2
|? 1..*
y1↔z1
A2 ▼
y2↔z1
0..1
Z
z1
Fig. 10.16 Fig. 10.13 revised with a |! binding for class X in A1 and a |? binding for class Y in A2
t.LbChecks′. Only cases “nil” and “|'” add (ok, A-1) to t.LbChecks if sLB is vio-
lated, where A is the association of which o↔ok is an instance.
If o↔ok has already been destroyed, then ok is already in t.Deletes', and thus it is
immaterial that (ok, A-1) is not added to t.LbChecks since it won’t be in t.LbChecks′,
which is {(sO, A) | (sO, A) ∈ t.LbChecks ∧ sO ∉ t.Deletes'}. We have already
shown that the t.Deletes' component of R is unaffected by the order in which links
are processed. (This situation is exemplified for b = “nil” in Fig. 10.10, Case 2.)
If o↔ok has not already been destroyed, it may be a vital surviving sibling link. If
so, then ok has not been deleted, i.e., it is not in t.Deletes'. If sLB is violated, then it
is violated because of the loss of a sibling link and (ok, A-1) is added to t.LbChecks.
For case “|'” (i.e., impB and b is “|'”), this is immaterial since object ok is implicitly
deleted and so (ok, A-1) will not be in t.LbChecks′. For case “nil”, however, (ok, A-1)
is essentially added to t.LbChecks′. This result is different than that which would
200 ORN FOR DATABASE APPLICATIONS
have occurred had o↔ok not been a vital surviving sibling link, but instead a sacrifi-
cial sibling link, i.e., one whose destruction did not violate sLB. (This situation is
exemplified in Figs. 10.13, 10.14, and 10.15 where either of the links for A2, shown
in Fig. 10.13, can become the vital sacrificial sibling link depending on the order in
which the links of A1 are processed on deletion of x1.)
Here, however, we apply the theorem’s hypothesis that no cyclic non-dependent |'
binding with possible partly sacrificial siblings is given for an association having
links within a link cycle. This ensures that a |' binding was not the cause of the at-
tempt to implicitly delete o, i.e., the invocation of DeleteObject(o, t, d), or if a |'
binding was the cause, its associated multiplicity implied a dependency. This in turn
ensures that regardless of whether o↔ok is a vital surviving link or a sacrificial link,
the results will be the same: a lower bound violation will be detected by the Commit
of the transaction that wraps the DeleteObject(x, t, d) as seen in Fig. 10.3 causing
the complex object deletion to fail. Either the violation will be caused by the dele-
tion of a vital surviving o↔ok link or, in the case of a |' binding with a dependent
multiplicity (imagine the 0..1 multiplicity for class X in Fig. 10.13 was 1), it will be
caused by the violation of this dependency. (That is, the situation won’t be like that
shown in Section 10.2.2.2 where a nested transaction commit detects a lower bound
violation in trying to implicitly delete o, here y1 or y2, but the exception is ignored.
The nested transaction is simply aborted, as seen by the “Commit(nT, d); If excep-
tion the Abort nT;” in the pseudocode for case “'” in EnforceBinding, Fig. 10.4.)
Since we have shown that for all components of R, the result of executing De-
leteObject(o, t, d), where o is x or any related object of x, are unaffected by the or-
der in which links are processed, the theorem is proved for explicit object deletion.
Now, we consider explicit link destruction and link change.
If a link is being explicitly destroyed or changed and if no object in the link is im-
plicitly deleted, only one link is processed. Thus no dependency on the order in
which links are processed exists.
To more simply address the situation where an object in an explicit link destruc-
tion or change is implicitly deleted, we examine equivalent operations involving ex-
plicit object deletion. An explicit destruction of or change in a link x↔y in an asso-
ciation A will be viewed in terms of the explicit deletion of an object a, which
represents the association instance, in a class A, which represents the association.
The association A with link x↔y is modeled in Fig. 10.17 (a) and remodeled in Fig.
10.17 (b) as a class A with object a. The multiplicities for classes X and Y, mX and
mY, have been mapped to equivalent multiplicities on class A, and the explicit cas-
cade bindings for classes X and Y, bX and bY have been mapped to equivalent implicit
bindings on class A.
Based on the algorithms given in Section 10.1, we first show that explicitly de-
stroying the link x↔y in the model in Fig. 10.17 (a) is equivalent in outcome to ex-
plicitly deleting the object a in the model in Fig. 10.17 (b). The outcome of De-
stroyLink(x↔y, t, d), as can be seen in Fig. 10.7, is determined by invoking
EnforceBinding(bX, A, x, y, t, d), where the multiplicity for the subject class in A is
mX, and EnforceBinding(bY, A-1, y, x, t, d), where the multiplicity for the subject
A Conceptual Implementation of ORN: Exploring Semantic Circularity and Ambiguity 201
class in A-1 is mY. The outcome of DeleteObject(a, t, d), as can be seen in Fig. 10.6,
is determined by invoking EnforceBinding(bX, AY, a, y, t, d), where the multiplicity
for the subject class in AY is mX, and EnforceBinding(bY, AX, a, x, t, d), where the
multiplicity for the subject class in AX is mY. Since the outcome of the EnforceBind-
ing algorithm is determined only by the subject class binding b, the subject class
multiplicity (which determines “if sLb is violated”), and the related object rO, the
results of these EnforceBinding executions in both DestroyLink and DeleteObject
algorithms are the same.
mX mY
A►
X XbX XbY Y
x x↔y y
(a)
my mx
◄ AX AY ►
|bY A |bX
a↔x a a↔y
1 1
{ Any pair of X and Y objects
associated by A are unique. }
X Y
x y
(b)
Fig. 10.17 Equivalence between (a) explicit destruction of an A link and (b) deletion of an A object
There are, however, two differences in these algorithms. In DestroyLink the or-
der in which the two EnforceBinding invocations occur is always the same and the
second invocation is guaranteed. While in DeleteObject, the order of these invoca-
tion is indeterminate and the second execution may not take place if a link cycle
causes one of the links to be a casualty link. We have already shown that the order
in which links are processed in DeleteObject is immaterial, thus we can assume in
our analysis here that they are processed in the same order as that done in De-
stroyLink. Now, suppose that the second EnforceBinding is invoked in De-
stroyLink, i.e., EnforceBinding(bY, A-1, y, x, t, d), when its equivalent in De-
leteObject would not be invoked. This means that object x has already been
implicitly deleted. In this case, the invocation of EnforceBinding is a no-op as a
study of the case statement reveals. The “insert(x, A) into t.LbChecks” is irrele-
vant for nil and “'” since x is in t.Deletes'. A “-” is impossible since the theorem hy-
pothesis does not allow a cyclic one-ended - binding (and a two-ended one would
have already resulted in an exception). Finally, any DeleteObject(x, t, d) is a no-op
since x is in t.Deletes'.
202 ORN FOR DATABASE APPLICATIONS
Now, since we have shown the equivalence of the destruction of x↔y and the ex-
plicit deletion of a and since we have already proved the theorem for explicit dele-
tion, the theorem is also proved for explicit link destruction.
Finally, we complete the proof of the theorem by addressing link change when the
object to be replaced in the link must be implicitly deleted. We do this by showing
that the result of executing the ChangeLink algorithm invoked in a nested transac-
tion t to change a link x↔y1 to x↔y2 in database d is unaffected by the order in
which the links are processed.
As can be seen in Fig. 10.8, the result of executing ChangeLink(x↔y1, y2, t, d) is
determined first by the task of implicitly destroying the x↔y1 link and enforcing the
explicit binding for the class of x in the applicable association and second by the task
of attempting to implicitly create the link between x and y2. If the result of the first
task is independent of the order in which links are processed, then so is the result of
the second. This is because the operations to ensure that objects x and y2 still exist
and, if so, to create the x↔y2 link are clearly unaffected by the order of any link
processing. Thus, we need only show that the result of the first task is unaffected by
the order in which links are processed.
To do this, we first show, based on the algorithms given in Section 10.1, that im-
plicitly destroying the link x↔y1 and enforcing the XbX bind in the model in Fig.
10.18 (a) is equivalent in outcome to explicitly deleting the object a1 in the model in
Fig. 10.18 (b), assuming the link a1↔x has been implicitly destroyed without enforc-
ing the |bY binding prior to enforcing the |bX binding. This assumption is valid since
the “Destroy link x↔y1;” in ChangeLink(x↔y1, y2, t, d) totally destroys the con-
nection between x and y1 and ChangeLink does not enforce the XbY binding.
mX mY
A►
X XbX XbY Y
x x↔y1 y1 y2
(a)
mY mX
◄ Ax Ay ►
|bY A |bX
a1↔x a1 a1↔y1
1 1
{ Any pair of X and Y objects
associated by A are unique. }
X Y
x y1 y2
(b)
Fig. 10.18 Equivalence between (a) explicit change of an A link and (b) deletion of an A object
y1, t, d) where the multiplicity for the subject class in A is mX. The outcome of De-
leteObject(a1, t, d), as can be seen in Fig. 10.6, is determined solely by invoking
EnforceBinding(bX, AY, a, y1, t, d), where the multiplicity for the subject class in AY
is mX, again assuming that a1↔x is implicitly destroyed without enforcing the bY
binding. This outcome is equivalent to that which would occur if link a1↔x did not
exist. Since the outcome of the EnforceBinding algorithm is determined only by the
subject class binding b, the subject class multiplicity (which determines “if sLb is
violated”), and the related object rO, the results of the EnforceBinding execution in
both the ChangeLink and DeleteObject algorithms are the same.
Therefore, since we have shown that the implicit link destruction of x↔y1 is
equivalent to the explicit deletion of a1 assuming no a1↔x link, since we have al-
ready proved the theorem for explicit deletion, and since the “implicit link creation”
part of link change is independent of link processing order, the theorem is now
proved for link change.
Since the theorem has been proven for link creation, explicit object deletion, ex-
plicit link destruction, and link change, the theorem is now proven for all complex
object operations. ■
10.3 Conclusion
This chapter has presented algorithms that can be used to implement ORN. They
have been described at a level of abstraction that is independent of the type of data-
base system, object or relational. The algorithms have been successfully imple-
mented in OR+, an object database system, and ORN Additive, a relational database
system.
In this chapter, we have also explored the problems posed by link cycles. We
have seen how circularity is avoided by the detection of such cycles in the given al-
gorithms and that the results of these algorithms are largely predictable in their pres-
ence. That is, complex object operations are non-circular and independent of the or-
der in which association links are processed, except for two problematic ORN
specifications.
One of these is the cyclic one-ended |- binding, which is given for an association
having links within a link cycle. This specification may cause processing order de-
pendencies. The one-ended |- binding is equivalent to the RESTRICT referential ac-
tion in relational databases, which is similarly problematic.
The other problematic specification is the cyclic non-dependent |' binding with
partly sacrificial siblings, which again may cause processing order dependencies in
link cycles. The |' binding has no equivalent referential action in relational data-
bases; however, if similar semantics were implemented by triggers, similar ambigui-
ties could result.
Possible solutions to avoid the ambiguities caused by the two problematic specifi-
cations were discussed and, more importantly, a theorem was stated and proved that
in the absence of these two specifications, ORN semantics are unambiguous.
Chapter 11
The current standard for RDBMSs is SQL:2008 (ANSI 2008). This chapter, based
on Ehlmann (2006), describes how ORN can be incorporated into standard SQL.1
The chapter is organized into four sections. Section 11.1 gives the motivation for
adding ORN to SQL. It reiterates some of the discussion given in Chapter 1 on the
problems of modeling associations and implementing them in relational databases.
Section 11.2 provides an overview of the existing capabilities for defining associa-
tions in SQL:2008. It reviews some material provided in Chapter 1 but also includes
object-oriented, association capabilities that have been added to standard SQL. Sec-
tion 11.3 gives the proposed syntax, semantics, and pragmatics for extending SQL
with ORN. Section 11.4 concludes by highlighting the benefits of this extension.
11.1 Motivation
1 This work is based on an earlier work: “Incorporating Object Relationship Notation (ORN) into
SQL—revised,” in Proc. ACM Southeast Regional Conf., 1-59593-315-8 © ACM, 2006.
http://doi.acm.org/10.1145/1185448.1185535
transformation of high-level abstract ... models into running systems”. MDD enables
the reuse of expert knowledge, enhances quality as models are successively refined
into running systems, reduces costs by automating this process, and increases the
longevity of the software that results. These benefits can only be achieved when re-
quired mappings between models (e.g., association notations in class diagrams and
SQL) and running systems (e.g., database systems) are straightforward and auto-
mated (Mellor et al. 2003).
Foreign keys and reference types are the two means for implementing associations in
SQL. An association between tables is implemented by defining a foreign key or
reference type within a table, the referencing table, whose values reference rows in a
referenced table. An association link exists when the foreign key value in a row of
the referencing table matches a unique key value in a row of the referenced table or,
alternatively, when a reference type in a row of the referencing table uniquely identi-
fies a row of the referenced table. An association between tables in SQL is either
one-to-one or, from the viewpoint of the referencing table, many-to-one.
SQL:2008 provides declarative constraints for defining unique keys, foreign keys,
and related association semantics. To simplify the overview of these constraints, we
assume that all keys are single column and that all foreign keys reference primary
keys. SQL provides more general constructs for specifying the same constraints
when keys are compound and foreign keys reference non-primary, unique keys.
A REFERENCES clause on a column declares it a foreign key and guarantees
referential integrity, which ensures that all non-null values in the column match a
value in the primary key column or self-referencing column of the referenced table.
Fig. 11.1 (a) gives the SQL needed to implement a many-to-one, or more precisely a
*-to-0..1, association between employees and units using the foreign key unit de-
fined in table Employee. unit references the primary key column id in table Unit.
(b)
Fig. 11.1 Association implemented using (a) a foreign key and (b) a reference
Adding ORN to the SQL Standard for RDBMSs 207
Fig. 11.1 (b) gives the SQL needed to implement the same association using the
reference type unit defined in table Employee. The column unit references the self-
referencing column unitRef in the typed table Unit. Here, the association could be
implemented without the REFERENCES clause, i.e., the reference type need not be
declared as a foreign key; however, referential integrity would then not be guaran-
teed, which could result in dangling references (Melton 2003, Melton J personal
communication).
Placing NOT NULL and UNIQUE constraints on a foreign key or reference type
implements certain association multiplicities. For example, in Fig. 11.1 (a) placing a
NOT NULL constraint on unit, as shown below, constrains each employee to belong
to a unit, implementing the *-to-1 association between employees and units.
unit CHAR(5) NOT NULL REFERENCES Unit
Placing both a NOT NULL and UNIQUE constraint on unit would implement a
0..1-to-1 association between employees and units.
Some association semantics are defined by how the DBMS should react when de-
letions would cause referential integrity to be violated. Some desired actions can be
specified as part of the REFERENCES clause. The syntax of this clause is given in
Fig. 11.2. The ON DELETE phrase specifies the action to be performed when a row
from a referenced table is deleted having matching rows (via foreign key values) in
the referencing table. NO ACTION, the default, specifies that no referential action
be taken, although if any unmatched foreign key values exist after the deletion (at
transaction commit), the deletion is undone and an integrity constraint violation ex-
ception is raised. RESTRICT specifies that the deletion raise an exception immedi-
ately. SET NULL specifies that the matching foreign key values be set to NULL,
and SET DEFAULT specifies that they be set to the specified default value for the
foreign key. CASCADE specifies that all matching rows in the referencing table be
deleted. The following definition of unit, if given in the Employee table, would
cause all employees in a unit to be deleted when the unit is deleted.
unit CHAR(5) REFERENCES Unit ON DELETE CASCADE
208 ORN FOR DATABASE APPLICATIONS
Similar referential actions can be given for ON UPDATE; however, this clause
has little to do with defining association semantics and more to do with key value
maintenance and thus will not be discussed further.
When the declarative constraints discussed above are insufficient to implement
association semantics, the general constraint capability of SQL can often be used—
for example, to implement more precise multiplicities. The constraint below, if
given in the Unit table in Fig. 11.1 (a), implements a 1..100-to-0..1 association be-
tween employees and units.
CONSTRAINT C1 CHECK
((SELECT COUNT(*) FROM Employee E
WHERE E.unit = Unit.id) BETWEEN 1 AND 100)
While general constraints offer power and flexibility, they can become very complex
and provide only the action of raising an exception when a constraint is violated.
This latter problem may be rectified by using triggers, which provide an even
more powerful means to implement association semantics. Fig. 11.3 shows
CREATE TRIGGER statements defined in the SQL that is required to implement
the employee–carpool association as modeled in Figs. 1.24 (a) and 2.14. When trig-
gers must be used, however, the SQL can become even more complex and error-
prone. The processing order of referential actions, trigger executions, and constraint
checking is governed by SQL and can result in subtle errors if care is not taken (e.g.,
see footnote in Fig. 11.3). Also, this ordering may not result in the desired associa-
tion semantics. For example, using referential actions, triggers, and constraints to
implement the ‘<0..1-to-*> association between units in conjunction with the <1-to-
*> association between units and employees, as modeled in Figs. 1.24 (a) and 2.14
and discussed in Chapters 1 and 2, becomes very problematic in SQL (Ehlmann and
Yu 2005a). We can remedy these problems by incorporating ORN into SQL.
Fig. 11.5 gives the extended SQL that implements the associations modeled in
Figs. 1.24 (a) and 2.14. The SQL in bold implements only the “belongs to” associa-
tion between employees and customers and should be compared with the SQL in Fig.
11.3.
The precise semantics of the ?<2..15-TO-0..1> employee–carpool association in
the context of Fig. 11.5 is defined by Table 11.1. The |? binding, implicit in the ?
binding, applies on deletion of an Employee row and means (paraphrasing from Ta-
ble 11.1): a “belongs to” reference can be implicitly destroyed, i.e., a carpool refer-
ence can be set to NULL, but if this violates the multiplicity 2..15, the related Car-
pool row must be implicitly deleted. The X? binding, also implicit in the ? binding,
applies on the explicit destruction of a “belongs to” reference and means (again,
from Table 11.1): a “belongs to” reference can be explicitly destroyed, i.e., carpool
can be explicitly set to NULL or changed from a non-NULL value to another, but if
this violates the multiplicity 2..15, the related Carpool row must be implicitly de-
leted. The multiplicity 2..15 is violated, for example, when carpool is set to NULL
in one of the just two Employee rows referencing a particular Carpool row.
The implicit default binding for the Carpool table in the ?<2..15-to-0..1> asso-
ciation applies on deletion of a Carpool row and means (from Table 11.1): a “be-
longs to” reference can be implicitly destroyed provided this does not violate the
multiplicity 0..1. The explicit default binding for the Carpool class applies on the
explicit destruction of “belongs to” reference and means (from Table 11.1): a “be-
longs to” reference can be explicitly destroyed, i.e., carpool can be explicitly set to
NULL, provided this does not violate the multiplicity 0..1. A 0..1 multiplicity is
never violated by destroying a reference to a Carpool row.
Below are more of the association semantics that are implemented in Fig. 11.5.
They are described both conceptually and, within brackets, in terms of SQL.
212 ORN FOR DATABASE APPLICATIONS
• If an employee [Employee row] is deleted, the link to the employee’s unit is im-
plicitly destroyed [the Employee row’s unit reference is implicitly set to NULL
(and then eliminated by the row deletion)] (default binding and * multiplicity).
• If a unit [Unit row] is deleted, all descendant units [Unit rows that directly or indi-
rectly reference the deleted row via parent] are implicitly deleted; however, a
unit is not deleted if it has any employees [if it is referenced by unit in any Em-
ployee row] (|' binding and implicit default binding with a 1 multiplicity).
• If a link between units is destroyed [if a parent reference is destroyed, e.g., set to
NULL], the child unit and all descendant units [Unit rows that directly or indi-
rectly reference the child via parent] are implicitly deleted; however, again, a
unit is not deleted if it has any employees (X' binding and implicit default binding
with a 1 multiplicity).
When a <references specification> is given as an <association>, the applica-
ble column must be a reference type. This new syntax, as shown in Fig. 11.5 for unit
in table Employee and parent in table Unit, eliminates the redundancy inherent in
the current syntax needed to specify referential integrity for reference types. When
the current <references clause> is given for either of these reference types (instead
of the <association>), the “REFerences” indication and the referenced table name
is specified twice and the self-referencing column is specified even though it is im-
plicit. The <column name> WITH OPTIONS ... syntax for a typed table in SQL
allows a <references specification>, a scope, and other constraints to be given for
reference types defined in the user-defined type related to the table, e.g., parent in
UnitType in Fig. 11.5.
When a <references specification> is given as a <references clause> that
uses an <association>, semantic equivalents to the ON DELETE options NO
ACTION, RESTRICT, SET NULL, and CASCADE are implicit (see Section
5.1.3). For example, NO ACTION is implicit in the <*-to-1> association specified
for unit in Fig. 11.5. If after deletion of a Unit row any Employee rows exist that
don’t reference a Unit row, the deletion is undone and a multiplicity violation excep-
tion is raised. RESTRICT would be implicit if a <*-to-1>|- or <*-to-0..1>|- asso-
ciation had been specified for unit instead of <*-to-1>. SET NULL is implicit in
any ...-to-0..1> association, e.g., that for carpool in table Employee in Fig. 11.5.
CASCADE is implicit in any ...-to-1>|! or...-to-0..1>|! association.
Two alternative, yet quite useful, flavors of “CASCADE” are implicit when a |?
or |' binding is used instead of the |! binding. The |' is given for unit in table Unit.
The effectiveness of this cascade stems from allowing the complex object operation
attempting the implicit deletion to continue without exception in cases when the im-
plicit deletion can’t be done but isn’t required to enforce multiplicities. The |? is
given for carpool in table Employee, but is given for the referencing table instead
of the referenced table. Its effectiveness stems from allowing the cascade to be con-
ditional based on whether or not a lower bound multiplicity is violated.
In an <association definition>, the semantics of the ON DELETE phrase are
similar to those of the existing ON DELETE <referential action> phrase. Here, the
phrase is only applicable to a ...-to-0..1> type of <association> given for a foreign
key that is not a reference type. In the REFERENCES clause for carpool in Fig.
Adding ORN to the SQL Standard for RDBMSs 213
11.5, an ON DELETE SET NULL is implied by default and means that on deletion
of a row in the Carpool table, all carpool values in the Employee table that refer-
ence the deleted row are set to NULL. If, however, ON DELETE SET DEFAULT
was specified just after ?<2..15-to-0..1> in the REFERENCES clause, then these
carpool values would be set to set to the specified default value for the column.
The remainder of this section discusses some of the finer points and impacts of
incorporating ORN into SQL as described above.
Syntax to specify the <referenced table and columns> can replace <table
name> in the <references clause> to allow the specification of a non-primary,
unique key or to explicitly declare the primary key or self-referencing column of the
referenced table.
The ON DELETE alternative to an <association definition> is retained in the
extended SQL for upward compatibility only. An ORN-extended SQL can be com-
pletely upward compatible with existing SQL. When an <association> is not given
for a foreign key or reference, existing SQL semantics apply.
The option to give an ON UPDATE phrase with an <association> is allowed to
manage changes to symbolic primary key values.
If an <association> is given for a foreign key or reference type, then NOT
NULL and UNIQUE constraints are implicit as described in Table 11.2.
Table 11.2 The NOT NULL and UNIQUE constraints implied for a row reference
<association>________________ NOT NULL UNIQUE
m-to-0..1 where m is not 0..1 or 1 no no
m-to-1 where m is not 0..1 or 1 yes no
m-to-0..1 where m is 0..1 or 1 no yes
m-to-1 where m is 0..1 or 1 yes yes
11.4 Conclusion
added to the SQL standard, RDBMS vendors should consider including ORN as an
extended feature to their SQL for the following reasons.
• The multiplicities and bindings for an association as modeled are mapped directly
into an <association> specified for the foreign key or reference type that imple-
ments the association in SQL. This holds true not only for one-to-one and one-to
many associations, but also for many-to-many associations, n-ary associations,
and “is a” relationships when these are modeled (or remodeled) as described in
Chapter 8, Section 8.1.1.
• More powerful association semantics are easily declared in SQL and enforced by
the DBMS. Such semantics enforce multiplicities; delete a row in a table (e.g.,
Carpool) when a given number of rows in the referencing table (e.g., Employee)
no longer reference it, either because a row has been deleted from the referencing
table or a foreign key (e.g., carpool) has been set to NULL or changed; or im-
plicitly delete a row in a table (e.g., Unit) only when it is no longer being used,
meaning there are no longer any required references to the row (e.g., unit refer-
ences in EMPLOYEE).
• The semantics for associations implemented using either foreign keys or reference
types are implemented in a consistent manner and, for reference types, imple-
mented with minimal syntax.
• Database implementations are made easier and less error-prone in that there is less
need for database developers to code, test, and maintain complex constraint and
trigger specifications. Again, to appreciate this, the amount and complexity of the
code needed to implement the employees-carpool association in existing SQL (see
Fig. 11.3) need only be compared to that needed in the ORN-extended SQL (see
Fig. 11.5).
• Adding ORN to SQL is feasible and relatively simple as shown by the develop-
ment of ORN Additive (see Chapter 6).
Not all of the technical issues regarding the incorporation of ORN into SQL have
been addressed in this chapter. For example, the statements needed to add RXC
mode to standard SQL, as it was added to T-SQL via ORN Additive, were not pre-
sented. The chapter, however, has shown the feasibility of its incorporation and dis-
cussed the benefits that would result.
Chapter 12
An object data management system (ODMS) allows objects created and manipulated
in an object-oriented programming language to be made persistent and provides tra-
ditional database capabilities like concurrency control and recovery to manage ac-
cess to these objects. An ODBMS, one type of ODMS, stores the objects directly in
an object database. An object-to-database mapping (ODM), another type of ODMS,
stores the objects in another database system representation, usually relational (Cattel
et al., 2000).
The de facto standard for ODMSs is ODMG 3.0 (Cattel et al. 2000). This stan-
dard defines an Object Model to be supported by an ODMG-compliant ODMS. This
chapter describes how ORN can be added to the Object Model. It is an extended ver-
sion of Ehlmann (2008).1
The chapter is organized into four sections. Section 12.1 briefly describes the
ODMG Object Model and discusses the motivation for adding ORN to the model.
Section 12.2 shows how the ODMG Object Definition Language (ODL), which de-
fines the Object Model, can be extended with ORN syntax and describes ORN se-
mantics in terms of the model. Section 12.3 discusses and illustrates algorithms that
can be used to implement ORN semantics in an ODMS that is based on the extended
Object Model. Section 12.4 provides concluding remarks.
12.1 Motivation
The Object Model defines the object semantics that can be specified to an ODMS.
These semantics deal with how objects are named and identified and the properties
and behavior of objects. They also deal with how objects can relate to one another.
In addition to supporting generalization/specialization relationships, the Object
Model supports one-to-one, one-to-many, and many-to-many binary relationships
between object types. These are the non-inheritance, or structural, types of relation-
ships, termed associations in UML. For example, a one-to-many association be-
tween carpools and employees can be defined in the Object Model. A carpool object
is defined so that it can reference many employee objects, and an employee object is
defined so that it can reference at most one carpool.
1 Portions reprinted from “Adding more support for associations to the ODMG Object Model,”
ICSOFT 2006, Software and Data Technologies, Springer-Verlag, CCIS 10:257-269. © Springer-
Verlag Berlin Heidelberg 2008. With kind permission of Springer Science and Business Media.
The Object Model prescribes that the ODMS automatically enforce referential in-
tegrity for all defined associations. This means that if an object is deleted, all refer-
ences to that object that maintain associations must also be deleted. This ensures that
there are no such references in the database that lead to nonexistent objects.
What has just been described is the extent of support for associations in the Object
Model. What is lacking is some additional, easily implementable support for asso-
ciations that could significantly improve the productivity of developing object data-
base systems and the reliability of those systems.
For example, the Object Model, like the relational model, does not support the
specification of precise multiplicities. For example, the multiplicity for the Em-
ployee class in the carpool–employee association may be given as 2..15 in a class
diagram, meaning that a carpool must be related to a minimum of two and a maxi-
mum of fifteen employees. Such association semantics, documented during concep-
tual database design, are often lost during logical database design and definition
unless supported by the logical data model, here the Object Model. If not supported,
to survive, they must be resurrected by the programmer during implementation and
for object databases translated into cardinality checking and exception handling code
within relevant create and update methods.
The Object Model also does not support association semantics that are equivalent
to those supported in relational DBMSs via the REFERENCES…ON DELETE
clause of the CREATE TABLE statement in SQL (ANSI 2008). Such semantics
would, for instance, allow one to declare an association between objects such that if
an object is deleted, all related objects would be automatically deleted by the ODMS,
i.e., an ON DELETE CASCADE. For example, if a unit within a company were
deleted, all subordinate units would be implicitly deleted. Such an association se-
mantic is required for an ODMS to provide support for composite objects.
This chapter shows how the Object Model can be extended with ORN and pro-
vides the algorithms that an ODMG-compliant ODMS can use to implement the as-
sociation semantics specified by ORN. The ORN extension is very straightforward,
and the algorithms required are relatively simple. The end result is an enhanced Ob-
ject Model that supports more powerful association semantics—in fact, more power-
ful than those supported by relational systems without having to code complex con-
straints and triggers. Extending models with ORN and providing the required
mappings between them—UML class diagram to Object Model to ODMS imple-
mentation—facilitates a model-driven development approach (Mellor et al. 2003).
The benefits of this approach are a major improvement in the productivity of de-
veloping object database systems and an increase in their reliability. Productivity is
improved when translations from class diagram models into object models are more
direct and when programmers do not have to develop code to implement association
semantics. Currently, many developers working on many database applications must
implement, test, and maintain custom code for each type of association, often “rein-
venting the wheel.” Reliability is increased when the ODMS is responsible for en-
forcing association semantics. Currently, developers sometimes fail to enforce these
semantics or inevitably introduce errors into database applications when they do.
Adding ORN to the ODMG Standard for ODMSs 217
This section first describes how associations are defined in ODL and then shows how
ORN syntax and semantics can be integrated into ODL.
class Carpool {
…
relationship set<Employee> riders
inverse Employee::carpool;
...
};
class Employee {
…
relationship Carpool carpool
inverse Carpool::riders;
...
};
Fig. 12.2 ODL for carpool–employee association
218 ORN FOR DATABASE APPLICATIONS
To illustrate the syntax and semantics of ORN in the context of the Object Model,
a database containing the carpool–employee association as well as two other associa-
tions is modeled by the class diagram in Fig. 12.4, which is the same as Figs. 1.24 (a)
and 2.14. The model is implemented by the ORN-extended ODL given in Fig. 12.5.
If an <association> is not given for a relationship in ODL (see Fig. 12.3), the de-
fault <association> is <0..1-to-0..1> for a one-to-one relationship, <0..1-to-*> for
a one-to-many, and <*-to-*> for a many-to-many. These defaults give relationships
the same semantics as they have in the existing Object Model.
An <association> given for a relationship need only to be given for one of the
traversal paths. If given for both traversal paths, the <association>s must be in-
verses of each other. For example, an <association>, if given for carpool in Fig.
12.5, must be given as ?<2..15-to-0..1>.
When an <association> is given for a traversal path tp in class C, the multiplic-
ity and binding given after the -to- apply to tp and to the target class, while the mul-
tiplicity and binding given before the -to- apply to the inverse tp and to class C. For
example, in Fig. 12.5, the multiplicity 2..15 and binding ? apply to the traversal path
riders and class Employee, and the multiplicity 0..1 and default bindings apply to
the traversal path carpool and the target class Carpool. If the multiplicity given for
a traversal path in an <association> implies “many,” then the type of that traversal
path must be a collection type.
class Carpool {
relationship set<Employee> riders
inverse Employee::carpool <0..1 -to-2..15>?;
...
};
class Employee {
relationship Carpool carpool inverse Carpool::riders;
relationship Unit unit
inverse Unit::workers <*-to-1>;
...
};
class Unit {
relationship set<Employee> workers
inverse Employee::unit;
relationship Unit parent
inverse Unit::children;
relationship set<Unit> children
inverse Unit::parent '<0..1-to-*>;
...
};
Fig. 12.5 ODL for class diagram shown in Fig. 12.4
The last issue to address in extending ODL is association inheritance. In the Ob-
ject Model, a relationship can be inherited by a class via the extends relationship.
For example, the declaration class SalesPerson extends Employee { ... } would
mean that the SalesPerson class inherits the attributes, relationships, and behavior
of the Employee class. Thus, the carpool traversal path as declared in the Em-
ployee class in Fig. 12.5 would be inherited by the SalesPerson class, allowing
sales people to belong to carpools. When a relationship is inherited by a class, all of
the semantics defined by its <association>, given or defaulted, are also inherited.
And, of course, the semantics of all <association>s defined in the ODL—
defaulted, given, or inherited—must be maintained by the ODMS.
Table 2.1 described ORN semantics conceptually in terms of ER and class diagrams.
Table 12.1 describes ORN semantics in terms of the Object Model, or ODL. (The
table is very similar to and consistent with Table 7.1.) In the Object Model, instead
of “association links” being “created” and “destroyed,” “relationship references” (or
“traversal path references”) are “formed” and “dropped.” Dropping a relationship or
traversal path reference also means dropping the corresponding inverse reference (in
the inverse traversal path). Also, bindings and multiplicities are now associated with
traversal paths as well as with related classes. This is convenient for identifying
bindings and multiplicities in intra-class associations since the subject class and re-
lated class, called the “target class” in ODL, are the same. Traversal path names can
be equated to role names given in UML class diagrams. In Table 12.1, traversal path
names tpR and tpS are also role names in the class diagram for relationship A.
220 ORN FOR DATABASE APPLICATIONS
12.3 Algorithms
in the context of ORN. This means they may no longer involve just one object or re-
lationship reference but may involve many objects, relationships, and relationship
references in the scope of a complex object.
In this section, the algorithms for these operations are given by providing related
pseudocode, with commentary, for the ObjectFactory::new() and Object::delete()
methods, which are associated with an object, and the C::form_tp(), C::drop_tp(),
and C::change_tp() methods, which are associated with a declared traversal path tp
in a user-declared class C. These methods, except for C::change_tp(), are defined
as part of the Object Model (see Chapter 2 of Cattel et al. (2000)).
The algorithms have been developed by reverse engineering the code for imple-
menting ORN within OR+ (see Chapter 7). This is the same code executed when
one uses the ORN Simulator (see Chapter 3). Thus, the algorithms are well-tested.
Their implementation of ORN semantics is unambiguous in the presence of asso-
ciation cycles as long as <association>s do not contain a problematic, cyclic |- or |'
binding, both of which are thoroughly explained in Section 10.2. Here, unambigu-
ous means that the results of a complex object operation are independent of the order
in which traversal paths and the references in these paths are processed. This prop-
erty of ORN is discussed in detail and proven in Chapter 10.
As stated in Section 12.1, the algorithms are relatively simple; however, they de-
pend on the ODMS implementation supporting a nested transaction capability.
Nested transactions are needed to implement the semantics of the ' binding and are
desirable so that the system can check multiplicity violations at the end of a complex
object operation, undoing the operation upon any exception and thus making the
complex object operation atomic. The Object Model defines a Transaction Model,
which does not provide nested transactions. So, before giving the algorithms for the
complex object operations, the Transaction Model is extended to support nested
transactions, at least for the purpose of implementing ORN (but not necessarily as a
user capability). Such support for nested transactions is assumed, and algorithms for
transaction methods are given, focusing on the actions required to support ORN se-
mantics.
All methods are assumed to execute in the context of an opened database d, and
methods new(), delete(), form_tpR(), drop_tpR(), and change_tpR() are assumed
to execute within the scope of a user-defined transaction.
The pseudocode that expresses the algorithms is a mixture of ODL, C++, Java,
and English and adheres as close as possible to the conventions of ODL. Indentation
indicates compound statements within control structures, with appropriate end’s of-
ten used to terminate these statements. The try...handle...end handle control struc-
ture for exception handling is similar to Java’s try {...} catch {...}. Methods for a
class are introduced with a header of the form Method <variable>.<method
name>( ... ), where the <variable> is used in the body of the method to refer to the
object on which the method is invoked, i.e., the implicit parameter and this object in
C++ and Java. A <method name> begins with an underscore if it is to be invoked
only by the ODMS implementation.
The algorithms are expressed using the variables defined in Table 12.1 and the
following functions:
Adding ORN to the ODMG Standard for ODMSs 223
Type(o) – the type, or class, of object o, which is the most specific type of o in any
type hierarchy.
LbM(tp) – the lower bound multiplicity for tp in the <association> for the relation-
ship represented by traversal path tp.
UbM(tp) – the upper bound multiplicity for tp in the <association> for the relation-
ship represented by traversal path tp.
ImpB(tp) – the implicit destructibility binding for tp (minus the | symbol) in the
<association> for the relationship represented by traversal path tp.
ExpB(tp) – the explicit destructibility binding for tp (minus the X symbol) in the
<association> for the relationship represented by traversal path tp.
Inverse(tp) – the inverse traversal path of tp.
Refs(o.tp) – the number of references in o.tp, which, if tp is a collection, is the car-
dinality of the collection, i.e., o.tp.cardinality() and, if tp is a reference, is 0 if nil
and 1 if not.
Fig. 12.6 gives a partial implementation of class Transaction, focusing on the code
needed to implement ORN. Here, for simplicity the pseudocode departs some from
the ODMG Transaction Model and adopts more the language of its ODMG C++
Binding. It is assumed that the static method current() returns the transaction cur-
rently in progress and that the proper constructor method is called to create a new
transaction when a Transaction is declared. The second constructor, which requires
a parameter, is invoked when declaring a nested transaction.
The variable rxc_mode records whether or not the transaction is in Relationship
eXChange(RXC) mode. Setting this mode defers checks on lower bound multiplic-
ities until the user-defined transaction commit so that normal ORN semantics, which
could cause an exception or implicit delete of a target object, are not invoked. This
permits “harmless” relationship exchanges within a transaction. For example, as-
sume a database as defined in Fig. 12.5 where a Carpool object c references just two
Employee objects, e1 and e2. If a transaction dropped the reference from c to e1, c
would normally be implicitly deleted (X? binding and multiplicity violation). But if
RXC mode were set, the transaction could drop this reference and form another from
c to an employee e3, for instance, without c being deleted. The RXC mode feature
complements ORN. The method set_rxc_mode() sets the mode and re-
set_rxc_mode() resets it.
The set deleted_objects is used to record which objects will be deleted in this
transaction or have already been deleted. The set deferred_lbM_checks is used to
record which traversal paths in which objects must be checked at transaction commit
for violations of lower bound multiplicity.
The begin() method initializes the RXC mode to false unless the transaction is
nested, in which case it initializes the mode to that of the parent transaction. The
224 ORN FOR DATABASE APPLICATIONS
The commit() method ensures that lower bound multiplicity constraints are satis-
fied for certain traversal paths in certain objects, i.e., certain traversal path instances.
These include instances that have such constraints, i.e., a nonzero lower bound, and
that 1) are in objects that have been created during the transaction (in this case, the
user-defined transaction); 2) have had a reference explicitly dropped during the
Adding ORN to the ODMG Standard for ODMSs 225
transaction (again, the user-defined transaction) while in RXC mode and the drop
caused a lower bound multiplicity violation; and 3) have had references dropped
implicitly or explicitly during the transaction (in this case, a system-defined, nested
transaction) and require multiplicity checks at the end of the complex object opera-
tion because of their binding (see footnote 2 in Table 12.1). The required checks are
done for each traversal path instance, i.e., object and traversal path pair, in the set
deferred_lbM_checks, provided the object is not in the deleted_objects set of the
current transaction or the deleted_objects set of any ancestor transaction. This pro-
vision ensures that checks are not made for objects that were or will be deleted in the
transaction. An exception is raised if the number of references in a traversal path in-
stance is less than the traversal path’s lower bound multiplicity.
The statement “Perform other commit transaction functions” may involve in-
voking a “primitive” commit() transaction method. OR+ invokes the “primitive”
commit() transaction method on the associated Object Store transaction.
The commit() method, if invoked on a nested transaction, includes its set of de-
leted_objects into the set of deleted_objects of its parent transaction before exit-
ing.
In the abort() method, the statement “Perform other abort transaction func-
tions” may involve invoking a “primitive” abort() transaction method. OR+ in-
vokes the Object Store abort() method. This, of course, restores the database to the
state it was in when the begin() was invoked on the transaction.
The remaining transaction methods defined in Fig. 12.6, are only invoked in the
implementation of other methods and are discussed when they are first invoked.
The new() method, given in Fig. 12.7, is described like the new operator in the
ODMG C++ Binding. The method serves as a wrapper to invoke the
_primitive_new() method, which refers to the currently defined new() method in the
Object Model, which deals only with the object as a primitive object. The function-
ality that must be added to this method to support ORN must ensure that the object
as a complex object is properly constructed. This means that all lower bound multi-
plicities for its traversal paths are satisfied before the transaction that invokes the
new() can commit. To ensure this, new() invokes _check_ paths_at_commit(o)
on the current transaction, where o is a reference to the newly created object.
The delete() method, seen in Fig. 12.8, is defined in the interface Object, which is
implicitly inherited by all user-defined classes in the Object Model. The method re-
places the delete() method as currently defined in Object Model. It provides the
ORN semantics for the deletion of a complex object, yet retains the semantics of the
currently defined delete() when all traversal paths of a class have default <associa-
tion>s. The delete() method—like the form_tpR(), drop_tpR(), and change_tpR()
methods to be presented later—provides a nested transaction that embeds the com-
plex object operation, permitting its effects on the database to be undone if an excep-
tion occurs. If one occurs, it is re-raised after aborting the transaction to allow the
user-defined transaction to take appropriate action.
Fig. 12.8 Algorithms for the delete() and _try_delete() methods in interface Object
The _try_delete() method, given in Fig. 12.8, is a recursive method that may re-
sult in the implicit deletion of a number of objects that are related directly or indi-
rectly to the object upon which it is invoked, designated here as s. Its invocation on
an object must be dynamically bound to the method on the class representing the ob-
ject’s most specific type, i.e., it must be a virtual function in the C++ sense. This en-
sures that _try_delete() processes all traversal path instances involving the object.
Adding ORN to the ODMG Standard for ODMSs 227
The method first checks that object s has not already been marked for deletion by
invoking the _deleted() method on the current transaction. If it has, _try_delete()
simply exits. If not, it invokes _mark_for_deletion() on the current transaction to
mark object s for deletion. The methods _deleted() and _mark_for_deletion() are
given in Fig. 12.6.
The outer for each loop in Fig. 12.8 traverses every traversal path tpR defined in
class S, declared in the class or inherited. For each of these traversal paths in object
s, the inner for each traverses all references in the traversal path. The purpose here
is to attempt to implicitly drop each reference to a target object r (including the in-
verse reference to s) so that the object s can be deleted. The code first drops each
such reference by invoking the _primitive_drop_tpR method on s, which drops
s.tpR’s reference to r and r.tpS’s reference to s. It then invokes the method
_enforce_binding() on the target object r to enforce the implicit destructibility bind-
ing ImpB(tpS) for the inverse traversal path tpS. This method is presented in the
next section.
The last step of _try_delete() actually deletes the object but is done only if all of
the references to target objects could be dropped, i.e., only if none of the
_enforce_binding() invocations resulted in an exception. The _primitive_delete()
method is invoked on object s. It is assumed that this method simply deletes the
primitive object from the database. It does not enforce referential integrity like the
delete() method in the existing Object Model since this has already been done by
_try_delete().
For a default <association>, the nil case is always executed and the if condition is
always false, resulting in nothing more than the already executed primitive drop
with referential integrity enforced.
The - binding case, i.e., a |- or X- binding, always results in an implicit exit with
an IntegrityError exception. The relationship reference cannot be dropped.
The ? binding case invokes _try_delete() on the target object r when the lower
bound multiplicity for the traversal path tpS has been violated. If this invocation
raises an exception, _enforce_binding() exits with an exception.
The ! binding case simply invokes _try_delete() on the target object r. If this in-
vocation raises an exception, _enforce_binding() exits with an exception.
The ' binding case first invokes _check_path_at_commit() on the current trans-
action when the lower bound multiplicity for traversal path tpS has been violated.
The code then proceeds to invoke _try_delete() on the target object; however,
unlike the ? or ! case, it invokes this method within another nested transaction so that
the delete can be undone if an exception results. Here, such an exception is not re-
raised. The implicit delete that was tried and failed is simply forgotten, which im-
plements the unique, useful, and often applicable semantics of the ' binding. If the
delete was required because of a lower bound multiplicity violation, an exception re-
sults at the commit of the nested transaction that ends the complex object operation
(based on the prior call to _check_path_at_commit()).
It should be noted that before the _try_delete() method is invoked to implicitly
delete a target object (for cases ?, !, and '), the reference to the target object and its
inverse have already been deleted. Thus, this reference (or association instance) is
not subsequently considered when determining whether or not an implicit delete of
the target object is possible.
It should also be noted that link cycles in the database, in which an object refer-
ences itself directly or indirectly, do not cause circularity within the given algo-
Adding ORN to the ODMG Standard for ODMSs 229
rithms. The cascading deletes are guaranteed to terminate because of the “if
t._deleted(s) then exit” statement in the _try_delete() method, which does a
depth-first traversal of the database tracing out a tree of implicitly deleted objects.
The form_tpR() method, given in Fig. 12.10, is generated by the ODMS for each tra-
versal path, tpR, defined in ODL. It is a method on a class S (see Table 12.1) that
contains the traversal path tpR. The method wraps the form_tpR() method as cur-
rently defined in the Object Model. It provides the ORN semantics for the creation
of an association link, i.e., the forming of a traversal path reference (including its in-
verse reference), yet retains the semantics of the currently defined form_tpR()
method when the traversal path has the default <association>. The form_tpR
method, like the delete() method, provides a nested transaction that embeds the
complex object operation, making it atomic.
The method first checks that upper bound multiplicities for traversal path tpR and
its inverse tpS will not be violated by forming the new relationship reference. For
simplicity, it is assumed that the = operator returns false for upper bound multiplicity
*. If a multiplicity is violated, an exception is raised. If not, the method invokes the
primitive version of form_tpR() on s, i.e., s._primitive_form_tpR(r), which just adds
to s.tpR a reference to r and adds to r.tpS a reference to s. The primitive method
should raise an IntegrityError if a traversal path already contains the reference being
added.
230 ORN FOR DATABASE APPLICATIONS
The drop_tpR() method, given in Fig. 12.11, is generated by the ODMS for each tra-
versal path, tpR, defined in ODL. It is a method on a class S (see Table 12.1) that
contains the traversal path tpR. The method wraps the drop_tpR() method as cur-
rently defined in the Object Model. It provides the ORN semantics for the explicit
destruction of an association link, i.e., the dropping of a traversal path reference (in-
cluding its inverse reference), yet retains the semantics of the currently defined
drop_tpR() method when the traversal path has the default <association>. The
drop_tpR method provides a nested transaction that embeds the complex object op-
eration, making it atomic.
ship must be made accessible to the other class. (In OR+, this and the
_enforce_binding() method are actually implemented in C++ on a base class for all
traversal paths and inherited by the derived classes that are generated by the system
for each traversal path. The class for a traversal path and that for its inverse traversal
path are declared as friends.)
The change_tpR() method, given in Fig. 12.13, is generated by the ODMS for each
traversal path, tpR, defined in ODL. It is a method on a class S (see Table 12.1) that
contains the traversal path tpR. The method does not have an equivalent method in
the Object Model but uses the form_tpR() and drop_tpR() methods as currently de-
fined in the model. It provides the ORN semantics for the explicit change of an as-
sociation link, replacing one related object reference with another. The change_tpR
method provides a nested transaction that embeds the complex object operation,
making it atomic.
Within the nested transaction, the method first does the “drop” portion of the rela-
tionship change operation. It invokes the primitive version of drop_tpR() on s, spe-
cifically s._primitive_drop_tpR(r1), which simply removes from s.tpR the reference
to r1 and removes from r1.tpS the reference to s. This method should raise an Integ-
rityError if the traversal paths do not contain these references. If no exception is
232 ORN FOR DATABASE APPLICATIONS
The change_tpR() method next does the “form” portion of the relationship
change operation. It first checks that neither objects s nor r2 have been implicitly
deleted as a result of enforcing the tpS binding. Then it checks that the upper bound
multiplicity for traversal path tpS will not be violated by forming a new relationship
reference between object r2 and object s. Again, for simplicity, it is assumed that
the = operator returns false for upper bound multiplicity *. If a multiplicity is vio-
lated, an exception is raised. If not, the method invokes the primitive version of
form_tpR() on s, i.e., s._primitive_form_tpR(r2), which just adds to s.tpR a refer-
ence to r2 and adds to r2.tpS a reference to s. The primitive method should raise an
IntegrityError if a traversal path already contains the reference being added.
12.3.9 Example
To aid in the reader’s understanding of the algorithms presented here, we will trace
an example execution of delete() to illustrate the enforcement of ORN semantics
and the recursive nature of the implementation. Let us assume the ODL in Fig. 12.5,
the sample company database shown in Fig. 12.14, and the invocation of e2.delete()
to delete employee e2. Fig. 12.14 is the same as Fig. 3.7. The class diagram and da-
tabase was created using the ORN Simulator.
Adding ORN to the ODMG Standard for ODMSs 233
The method delete() (Fig. 12.8) invokes e2._try_delete() within the nested
transaction nt. Assume that the type of e2 is actually SalesPerson (a subclass of
Employee not shown in Fig. 12.14). In this case the _try_delete() method for the
class Salesperson is executed.
The method _try_delete() (Fig. 12.8) checks that e2 has not already been deleted
(it has not) and marks the object to be deleted. Then, it processes all of the refer-
ences from e2 to related objects seeking to drop them. For e2 this involves looping
through all of the references in traversal path unit and carpool (both shown in Fig.
12.5) and perhaps other traversal paths, e.g., orders, that are not shown in Fig. 12.5
or Fig. 12.14. e2.unit contains a reference to unit u1, and e2.orders may contain
many references to the orders that employee e2, as salesperson e2, has obtained. To
focus on the carpool traversal path, we assume that the unit reference to u1 is suc-
cessfully dropped (it will be since the implicit destructibility binding for Employee
is default and the lower bound multiplicity is 0) and that any references in a traversal
path orders are also successfully dropped For the reference in carpool to c0, the
code invokes e2._primitive_drop_carpool(c0) to drop it (along with the reference
in c0.riders to e2). It then invokes c0._enforce_binding(?, riders) to enforce
ORN semantics.
The _enforce_binding() method (Fig. 12.9) executes the code for case ?, which
is: if Refs(c0.riders) < LbM(riders) then c0._try_delete(). Since the value of
Refs(c0.riders) is now 1 and LbM(riders) is 2, an implicit delete of c0 is attempted.
234 ORN FOR DATABASE APPLICATIONS
12.4 Conclusion
This chapter has shown how ORN can be added to the ODMG Object Model and has
presented and discussed algorithms for implementing ORN semantics in an ODMS.
The shortcomings of adding ORN to the Object Model are a slight increase in com-
plexity and a requirement that ODMS implementations include a nested transaction
capability for ORN implementation. Despite these shortcomings and regardless of
whether or not ORN is added to any standard for ODMS, ODMS vendors should
consider including ORN as an extended feature to their system because:
• ORN is a simple notation that allows the database developer to specify a large va-
riety of association semantics, which define the scopes of complex and composite
objects.
• The extended ODL would facilitate a straightforward mapping of association se-
mantics from a conceptual database model, expressed as an ORN-extended UML
class diagram, to the logical database model, expressed in the ODL.
• The ODMS would provide the same support for associations that is provided by
relational DBMSs via the SQL references clause plus support even more powerful
association semantics.
• If no <association> is given for a traversal path, the default <association> cor-
responds to current system capabilities. Thus, adding ORN is a pure extension re-
quiring no changes to the underlying Object Model capabilities.
Adding ORN to the ODMG Standard for ODMSs 235
Albano A, Ghelli G, Orsini B (1991) A relationship mechanism for a strongly typed object-oriented
database programming language. Proc VLDB Conf, Morgan Kaufmann, 565-575
Albert M, Pelechano V, Fons J, Ruiz M, Pastor O (2003) Implementing UML association, aggrega-
tion, and composition: a particular interpretation based on a multidimensional framework. Proc
CAiSE 2003 Conf, Eder J and Missikoff M (eds), Springer-Verlag LNCS 2681:143-158
ANSI (2008) Information technology - database languages - SQL - part 2: foundation
(SQL/Foundation), ISO/IEC 9075-2:2008. American National Standards Institute (ANSI), New
York, www.webstore.ansi.org. Accessed 4 March 2009
ANSI (1975) ANSI/X3/SPARC Study Group on Database Management Systems, Interim Report,
FDT. ACM SIGMOD Bulletin 7, 2.
Balaban M, Shoval P (2000) MEER – A EER model enhanced with structure methods. Inf Syst 27,
4:245-275
Barbier F, Henderson-Sellers B, Parc-Lacayrelle A, Bruel J (2003) Formalization of the Whole-Part
Relationship in the Unified Modeling Language. IEEE Trans on Softw Eng 29, 5:459-469
Bertino E, Martino L (1991) Object-oriented database management systems: concepts and issues.
IEEE Computer 24, 4:33-47
Booch G, Rumbaugh J, Jacobson I (1999a). The Unified Modeling Language user guide. Addison
Wesley, Reading, MA
Booch G, Rumbaugh J, Jacobson I (1999b). The Unified Modeling Language reference manual.
Addison-Wesley, Reading, MA
Bouzeghoub M, Metais E (1991) Semantic modeling and object oriented databases. Proc VLDB
Conference, Morgan Kaufmann, 3-14
Brown SG (1997) The ORN Simulator: a practical tool for modeling relationship behavior. Proc
ADMI Conf, 130-135
Cattel RGG, Barry DK, Berler M, Eastman J, Jordan D, Russell C, Schadow O, Stanienda T, Velez
F (2000) The object database standard: ODMG 3.0. Morgan Kaufmann, San Mateo, CA
Cattel RGG, et al. (1997) The object database standard: ODMG 2.0. Morgan Kaufmann, San Fran-
cisco, CA (see Release 1.1 for description of future binding)
Chen PP (1976) The entity-relationship model: towards a unified view of data. ACM Trans on Da-
tabase Syst 1, 1:1-36
Civello F (1993) Roles for composite objects in object-oriented analysis and design. Proc OOPSLA
Conf, ACM, 376-393
Codd EF (1970) A relational model of data for large shared data banks. Commun of the ACM 13,
6:377-387
Codd EF (1979) Extending database relations to capture more meaning. ACM Trans on Database
Syst 4, 4:397-434
Codd EF (1990) The relational model for database management—version 2. Addison-Wesley,
Reading MA
Connolly T, Carolyn B (2005) Database systems: a practical approach to design, implementation,
and management. Addison-Wesley, Reading, MA, 467
Copeland G, Maier D (1984) Making SmallTalk a database system. Proc SIGMOD Conf, ACM,
316-325.
Date CJ (1981) Referential Integrity. Proc VLDB Conf, 2-12
Date CJ (1990) Relational database writings 1985-1989. Addison-Wesley, Reading, MA, 119-125,
143-147
Date CJ, Darwen H (1994) A guide to the SQL standard, third edition. Addison-Wesley, Reading,
MA, 399-401
Ehlmann B (2008) Adding more support for associations to the ODMG Object Model. ICSOFT
2006 Conf: Revised Selected Papers, Softw and Data Technol, Springer-Verlag, Filipe J, Shish-
kov B, and Helfert M (eds), CCIS 10:257-269
Ehlmann BK (2007) ORN Additive: shrinking the gap between database modeling and implementa-
tion. Proc ICIS Conf, IEEE Computer Society, 555-560
Ehlmann BK (2006) Incorporating Object Relationship Notation (ORN) into SQL—revisited. Proc
ACM Southeast Conf, 389-394
Ehlmann BK (2002) A data modeling tool where associations come alive. Proc IASTED MIC Conf,
66-72
Ehlmann BK (1992) Applying an object-oriented database model to a scientific database problem:
managing experimental data at CEBAF. Ph.D. dissertation, UMI Dissertation Services, Ann
Arbor, MI
Ehlmann BK, Riccardi GA (1994) A notation for describing aggregate relationships in an object-
oriented data model. Springer-Verlag Lect Notes in Comput Sci 819:62-77
Ehlmann BK, Riccardi GA (1996) A comparison of ORN to other declarative schemes for specify-
ing relationship semantics. Inf and Softw Technol 38, 7:455-465
Ehlmann BK, Riccardi GA (1997a) An integrated and enhanced methodology for modeling and im-
plementing object relationships. J of Object-Oriented Program 10, 2:47-55
Ehlmann BK, Riccardi GA (1997b) Object Relater Plus: a practical tool for developing enhanced
object databases. Proc Data Eng Conf, IEEE Computer Society Press, 412-421
Ehlmann BK, Riccardi GA (1999) Object Relationship Notation (ORN) and the ORN Simulator.
Demos and Posters Proc ER Conference, 9-10
Ehlmann BK, Stewart MA (1997) Incorporating Object Relationship Notation (ORN) into SQL.
Proc ACM Southeast Conf, 282-289
Ehlmann BK, Yu X (2005a) Generating SQL to implement enhanced association semantics. Proc
WorldComp IKE Conf, 120-127
Ehlmann BK, Yu X (2005b) The difficulty of mapping modeled associations to SQL. Proc IASTED
DBA Conf, 65-70
Ehlmann BK, Yu X (2002) Extending UML class diagrams to capture additional association seman-
tics. Proc IASTED Applied Informatics Conf, 395-401
Ehlmann BK, Riccardi GA, Dennis LC (1992) Representing non-inheritance relationships in an ob-
ject-oriented, scientific database. Proc SSDBM Conf, ETH Zurich, 99-109
Ehlmann BK, Dennis LC, Riccardi GA (1993) An object-based conceptual model of a nuclear phys-
ics experiments database. Nucl Instrum & Methods in Phys Res, Sect A A325,1&2:294-308
Ehlmann BK, Rishe N, Shi J (2000) The formal specification of ORN semantics. Inf and Softw
Technol 42, 3:159-170
Ehlmann BK, Riccardi GA, Rishe N, Shi J (2002) Specifying and enforcing association semantics
via ORN in the presence of association cycles. IEEE Trans on Knowl and Data Eng 14, 6:1249-
1257
Embley DW, Ling TW (1990) Synergistic database design with an extended entity-relationship
model. In: Lochovsky FH (ed) Entity-relationship approach to database design and query.
North Holland, New York
Fowler M (1997) Analysis Patterns: Reusable Object Models, Addison-Wesley, Reading, MA
Gamma E, Helm R, Johnson R, Vlissides, J (1995) Design patterns: elements of reusable object-
oriented software. Addison-Wesley, Reading, MA
Guo M, Su SYW, Lam H (1991) An association algebra for processing object-oriented databases.
Proc Data Eng Conf, 23-32
Hardeman SK, Ehlmann BK (1996) Relationship behavior in object databases: subtleties and in-
consistencies. Proc ACM Southeast Conf, 224-229
Hay DC (1996) Data model patterns: conventions of thought. Dorset House, New York
Bib liography 239
Henderson-Sellers B, Barbier F ((1999) What is this thing called aggregation? Proc of TOOLS 29,
IEEE Computer Society, 216-230.
Horowitz BM (1992) A run-time execution model for referential integrity maintenance. Proc Data
Eng Conf, 548-556
Kilov H, Ross J (1994) Information modeling: an object-oriented approach. Prentice Hall, Engle-
wood Cliffs, NJ, 268
Kim W (1990) Object-oriented databases: definition and research directions. IEEE Trans on Knowl
and Data Eng 2, 3:327-341
Kim W, Bertino E, Garza JF (1989) Composite objects revisited. Proc ACM SIGMOD Conf. In:
ACM SIGMOD RECORD 18, 2:337-347
Kolp M, Zimanyi E (2000) Enhanced ER to relational mapping and interrelational normalization.
Inf and Softw Technol 42:1057-1073.
Lazarevic B, Misic V (1991) Extending the entity-relationship model to capture dynamic behavior.
European J of Inf Syst 1, 2:95-106
Markowitz VM (1990) Referential integrity revisited: an object-oriented perspective. Proc VLDB
Conf, Morgan Kaufmann, 578-589
Markovitz M, Shoshani A (1992) Representing extended entity-relationship structures in relational
databases: a modular approach. ACM Trans on Database Syst 17, 3:423-464
Mellor SJ, Clark AN, Futagami T (2003) Guest editor’s introduction: model-driven development.
IEEE Softw 20, 5:19-25
Melton J (2003). Advanced SQL: 1999—Understanding Object-Relational and Other Advanced
Features. Morgan Kaufmann, San Francisco, CA, 119-151.
Micosoft Inc. (2008) Microsoft SQL Server 2008. www.microsoft.com/sql/default.mspx Accessed
27 February 2009.
Neal E, Ehlmann BK (2000) A new UML-compatible object relationship notation (ORN). Proc
ACM Southeast Conf, 179-183
Odell JJ (1994) Six different kinds of composition. J of Object-Oriented Program 5, 8:10-15
OMG (2005) OMG unified modeling language specification, version 2.0. Object Management
Group, www.omg.org. Accessed 27 February 2009.
ONTOS (1994) ONTOS DB 3.0 developer's guide. ONTOS Inc, Burlington, MA
Progress Software Inc (2006) ObjectStore interprise. www.objectstore.com/datasheet/index.ssp
Accessed 27 February 2009.
Ricardo CM (2004) Databases Illuminated. Jones and Bartlett, Sudbury, MA
Riccardi GA, Ehlmann BK (1991) Object-oriented development of scientific databases, an example
from experimental physics. Proc SERF Conf, Rodriguez RV (ed), 277-286
Rumbaugh J (1987) Relations as semantic constructs in an object-oriented language. Proc OOPSLA
Conf, ACM, 466-481
Rumbaugh J (1988) Controlling propagation of operations using attributes on relations. Proc
OOPSLA Conf, ACM, 285-296
Rumbaugh J, Blaha M, Premerlani W, Eddy F, Lorensen W (1991) Object-oriented modeling and
design. Prentice Hall, Englewood Cliffs, NJ
Rundensteiner EA, Bic L, Gilbert JP, Yin M (1994) Set restrictions for semantic groupings. IEEE
Trans on Knowl and Data Eng 6, 2:193-204
Saksena M, France RB, Larrondo-Petrie (1998) A characterization of aggregation. Proc OOIS
Conf, Springer, Roland C and Grosz G (eds), 11-19
Shipman DW (1981) The functional data model and the data language DAPLEX. ACM Trans on
Database Syst 6, 1:140-173
Smith J, Smith D (1977) Database abstractions: Aggregation and Generalization. ACM Trans on
Database Syst 2, 2:105-133
Snoeck M, Dedene G (2001) Core modeling concepts to define aggregation. L’Object 7, 3:281-306
Stonebraker M, Rowe LA, Hirohama M (1990) The implementation of POSTGRES. IEEE Trans
on Knowl & Data Eng 2, 1:125-142
Tan P, Steinbach M, Kumar V (2006) Introduction to data mining. Addison-Wesley, Reading, MA
240 ORN FOR DATABASE APPLICATIONS
Teorey T (1990) Database modeling and design: the Entity-Relationship approach. Morgan Kauf-
mann, Los Altos, CA
Tsichritzis DC, Lochovsky FH (1982) Data models. Prentice-Hall, Englewood Cliffs, NJ
Ullman J (1982) Principles of database systems. Computer Science Press, Rockville, Maryland
VERSANT (1993) VERSANT ODBMS system reference manual release 3.0 VERSANT Object
Technologies, Menlo Park, CA
Winston M, Chaffin R, Herrmann (1987) A taxonomy of part-whole relations. Cognitive Science
11: 417-444
Wordsworth JB (1992) Software development with Z. Addison-Wesley, Wokingham, UK
Zaniolo C (1983) The Database Language GEM. Proc SIGMOD Conf, ACM, 207-218
Zdonik SB, Maier D (1990) Fundamentals of object-oriented databases. In: Zdonik SB, Maier D
(eds) Readings in object-oriented DB systems. Morgan Kaufmann, San Mateo, CA
Index
_ API, 30
_check_paths_at_commit() method, 226 Application program interface. See API
_deleted() method, 227 Application-defined deletion stored
_enforce_binding() method, 227 procedure, 123
_enforce_explicit_binding() method, 230 Associated class, 80, 154
_mark_for_deletion() method, 227 Associated object, 80
_primitive_drop_tpR() method, 227 Associating class, 26, 99, 102, 150, 151,
_primitive_new() method, 225 154, 158
_try_delete() method, 226 Associating object, 80
“is a Association, 3, 25
“is a part of” association, 162 “is a”, 89–90, 152, 156
“is a part of” pattern, 82–88, 91 aggregation, 26
“is a part of” relationship, 106, 107–13 ambiguities, 172–74, 177
“is a realization of” pattern, 79 composition aggregation, 26
“is a” association, 89–90, 152, 156 definition, 3–4
“is a” pattern, 89–90, 152 ecursive, 87, 88
“is a” relationship, 8, 25–26, 31, 89–90, 135 functional interpretation, 174–76
“is an update of” pattern, 81 implementation in object database, 157–
“is associated by” pattern, 80–81, 91, 150, 64
158 implementation in relational database,
“is defined by” pattern, 73–74, 91 149–57
“is recorded for” pattern, 75–78, 150, 152 inconsistencies, 165–70, 177
inconsistency detection, 171
< inter-class, 160, 165
<association>, 39, 40, 41, 56, 118, 122, intra-class, 34, 150, 160, 162–64, 165,
134, 138, 155, 156, 160, 161, 209, 166, 175–76
218, 234 link, 182
<binding>, 40, 42 link cycle, 188
<di>, 40 many-to-many, 26, 91, 158, 161, 162,
<multiplicities>, 39 209, 214
<multiplicity>, 40, 42 n-ary, 25, 151, 158
<references specification>, 209 n-ary, 214
A non pattern conforming, 95
abort algorithm, 183 one-to-many, 152, 154–55, 160–61
abort() method, 225 one-to-one, 156–57, 160, 162
Abstract object, 79 recursive, 34, 82, 83
Access path, 28 shared aggregation, 26
Aggregate, 26 symmetric, 26, 162, 176
Aggregate object, 82 ternary, 151
Aggregation, 26, 98, 107, 111 transitive, 26
Ambiguity, 181, 190–203 whole-part, 26, 107–13
Analysis pattern, 70 Association attribute, 151, 158, 162
ANSI-SPARC, 134 Association class, 26, 158
Antisymmetry, 109, 112 Association cycle, 188, 189
242 ORN FOR DATABASE APPLICATIONS