IM 101_Fundamentals of Database Systems_Unit 7
IM 101_Fundamentals of Database Systems_Unit 7
All rights reserved. No part of this module may be reproduced, repurposed, distributed, or transmitted in
any form or by any means including photocopying, reprinting, or other electronic or mechanical
methods without the prior written permission of PLV and the individual developers of instructional
materials (IMs) except in the case of brief quotations embodied in critical and creative reviews and
certain other noncommercial uses permitted by the Copyright Law. For permission request, address your
written correspondence whether printed or electronic to the Chair of the University Committee on
Instructional Materials Development and Evaluation at the address below:
Essential Question
What are the different types of Obejct-oriented data model?
How can we create a UML diagram?
What are the levels of data abstraction?
Lessons Input
Object-Oriented Data Model (OODM)
Both data and their relationships are contained in a single structure known as an object. In turn, the
OODM is the basis for the object-oriented database management system (OODBMS). The OODM is
said to be a semantic data model because semantic indicate meaning.
The OO data model is based on the following :
1. An object is an abstraction of a real-world entity. In general terms, an object may be considered
equivalent to an ER model’s entity. More precisely, an object represents only one occurrence of
an entity.
2. Attributes describe the properties of an object. For example, a PERSON object includes the
attributes Name, Social Security Number, and Date of Birth.
2
3. Objects that share similar characteristics are grouped in classes. A class is a collection of similar
objects with shared structure(attributes) and behavior(methods). In a general sense, a class
resembles the ER model’s entity set. However, a class is different from an entity set in that it
contains a set of procedures known as methods. A class’s method represents a real-world action
such as finding a selected PERSON’s name, changing a PERSON’s name, or printing a
PERSON’s address. In other words, methods are the equivalent of procedures in traditional
programming languages. In OO terms, methods define an object’s behavior.
4. Classes are organized in a class hierarchy. The class hierarchy resembles an upside-down tree in
which each Class has only one parent. For example, the CUSTOMER class and the EMPLOYEE
class share a parent PERSON class.
5. Inheritance is the ability of an object within the class hierarchy to inherit the attributes and
methods of the classes above it. For example, two classes, CUSTOMER and EMPLOYEE, can
be created as subclasses from the class PERSON. In this case, CUSTOMER and EMPLOYEE
will inherit all attributes and methods from PERSON.
Object-oriented data models are typically depicted using Unified Modeling Language(UML) class
diagrams. Unified Modeling Language (UML) is a language based on OO concepts that describes a
set of diagrams and symbols that can be used to graphically model a system. UML class diagrams are
used to represent data and their relationships within the larger UML object-oriented system’s modeling
language.
The class diagram is a static diagram. It represents the static view of an application. The class diagram
is not only used for visualizing, describing, and documenting different aspects of a system but also for
constructing executable code of the software application.
The class diagram describes the attributes and operations of a class and also the constraints imposed on
the system. The class diagrams are widely used in the modeling of object-oriented systems because
they are the only UML diagrams, which can be mapped directly with object-oriented languages.
The class diagram shows a collection of classes, interfaces, associations, collaborations, and
constraints. It is also known as a structural diagram.
The purpose of the class diagram is to model the static view of an application. Class diagrams are the
only diagrams that can be directly mapped with object-oriented languages and thus widely used at the
time of construction.
UML diagrams like activity diagram, sequence diagram can only give the sequence flow of the
application, however, class diagram is a bit different. It is the most popular UML diagram in the coder
community.
3
Class diagrams are the most popular UML diagrams used for the construction of software applications.
It is very important to learn the drawing procedure of the class diagram.
Class diagrams have a lot of properties to consider while drawing but here the diagram will be
considered from a top-level view.
The class diagram is a graphical representation of the static view of the system and represents different
aspects of the application. A collection of class diagrams represent the whole system.
The following points should be remembered while drawing a class diagram −
The name of the class diagram should be meaningful to describe the aspect of the system.
Each element and their relationships should be identified in advance.
Responsibility (attributes and methods) of each class should be identified
For each class, the minimum number of properties should be specified, as unnecessary
properties will make the diagram complicated.
Use notes whenever required to describe some aspect of the diagram. At the end of the drawing,
it should be understandable to the developer/coder.
Finally, before making the final version, the diagram should be drawn on plain paper and
reworked as many times as possible to make it correct.
The following diagram is an example of an Order System of an application. It describes a particular
aspect of the entire application.
First of all, Order and Customer are identified as the two elements of the system. They have a
one-to-many relationship because a customer can have multiple orders.
Order class is an abstract class and it has two concrete classes (inheritance relationship)
SpecialOrder and NormalOrder.
The two inherited classes have all the properties as the Order class. Also, they have additional
functions like dispatch () and receive ().
The following class diagram has been drawn considering all the points mentioned above.
4
A class represents a concept which encapsulates state (attributes) and behavior (operations). Each
attribute has a type. Each operation has a signature. The class name is the only mandatory
information.
Class Name:
The name of the class appears in the first partition.
Class Attributes:
5
Class Visibility
The +, - and # symbols before an attribute and operation name in a class denote the visibility of the
attribute and operation.
Parameter Directionality
6
Each parameter in an operation (method) may be denoted as in, out or inout which specifies its
direction with respect to the caller. This directionality is shown before the parameter name.
The choice of perspective depends on how far along you are in the development process. During the
formulation of a domain model, for example, you would seldom move past the conceptual
perspective. Analysis models will typically feature a mix of conceptual and specification
perspectives. Design model development will typically start with a heavy emphasis on
the specification perspective, and evolve into the implementation perspective.
A diagram can be interpreted from various perspectives:
Conceptual: represents the concepts in the domain
Specification: the focus is on the interfaces of Abstract Data Type (ADTs) in the software
Implementation: describes how classes will implement their interfaces
The perspective affects the amount of detail to be supplied and the kinds of relationships worth
presenting. As we mentioned above, the class name is the only mandatory information.
UML is not just about pretty pictures. If used correctly, UML precisely conveys how code should be
implemented from diagrams. If precisely interpreted, the implemented code will correctly reflect the
intent of the designer. Can you describe what each of the relationships means relative to your target
programming language shown in the Figure below?
If you can't yet recognize them, no problem this section is meant to help you to understand UML class
relationships. A class may be involved in one or more relationships with other classes. A relationship
can be one of the following types:
A generalization is a taxonomic relationship between a more general classifier and a more specific
classifier. Each instance of the specific classifier is also an indirect instance of the general classifier.
Thus, the specific classifier inherits the features of the more general classifier.
Represents an "is-a" relationship.
An abstract class name is shown in italics.
SubClass1 and SubClass2 are specializations of SuperClass.
8
Figure 7.8 below shows an example of inheritance hierarchy. SubClass1 and SubClass2 are derived
from SuperClass. The relationship is displayed as a solid line with a hollow arrowhead that points
from the child element to the parent element.
The figure below shows an inheritance example with two styles. Although the connectors are drawn
differently, they are semantically equivalent.
Association
Associations are relationships between classes in a UML Class Diagram. They are represented by a
solid line between classes. Associations are typically named using a verb or verb phrase which reflects
the real-world problem domain.
Simple Association
A structural link between two peer classes.
There is an association between Class1 and Class2
The figure below shows an example of a simple association. There is an association that connects the
<<control>> class Class1 and <<boundary>> class Class2. The relationship is displayed as a solid line
connecting the two classes.
Cardinality
Aggregation
The figure below shows an example of aggregation. The relationship is displayed as a solid line with an
unfilled diamond at the association end, which is connected to the class that represents the aggregate.
Composition
A special type of aggregation where parts are destroyed when the whole is destroyed.
Objects of Class2 live and die with Class1.
Class2 cannot stand by itself.
The figure below shows an example of composition. The relationship is displayed as a solid line with a
filled diamond at the association end, which is connected to the class that represents the whole or
composite.
Dependency
An object of one class might use an object of another class in the code of a method. If the object is not
stored in any field, then this is modeled as a dependency relationship.
A special type of association.
Exists between two classes if changes to the definition of one may cause changes to the other
(but not the other way around).
Class1 depends on Class2
The figure below shows an example of dependency. The relationship is displayed as a dashed line with
an open arrow.
11
The figure below shows another example of dependency. The Person class might have a hasRead
method with a Book parameter that returns true if the person has read the book (perhaps by checking
some database).
Realization
Realization is a relationship between the blueprint class and the object containing its respective
implementation level details. This object is said to realize the blueprint class. In other words, you can
understand this as the relationship between the interface and the implementing class.
For example, the Owner interface might specify methods for acquiring property and disposing of
property. The Person and Corporation classes need to implement these methods, possibly in very
different ways.
The class diagram is static and it is used to model the static view of a system. The static view describes
the vocabulary of the system.
The class diagram is also considered as the foundation for component and deployment diagrams. Class
diagrams are not only used to visualize the static view of the system but they are also used to construct
the executable code for forward and reverse engineering of any system.
Generally, UML diagrams are not directly mapped with any object-oriented programming languages
but the class diagram is an exception.
The class diagram clearly shows the mapping with object-oriented languages such as Java, C++, etc.
From practical experience, a class diagram is generally used for construction purpose.
In a nutshell, it can be said, class diagrams are used for :
Describing the static view of the system.
Showing the collaboration among the elements of the static view.
Describing the functionalities performed by the system.
Construction of software applications using object-oriented languages.
Because data are being modeled, ER diagrams will be used to represent the external views. A specific
representation of an external view is known as an external schema.
The conceptual model represents a global view of the entire database as viewed by the entire
organization. That is, the conceptual model integrates all external views(entities, relationships,
constraints, and processes) into a single global view of the data in the enterprise. Also known as a
conceptual schema, it is the basis for the identification and high-level description of the main data
objects.
The internal Model is the representation of the database as “seen” by the DBMS. In other words, the
internal model requires the designer to match the conceptual model’s characteristics and constraints to
those of the selected implementation model. An internal schema depicts a specific representation of an
internal model, using the database constructs supported by the chosen database.
16
Figure 7.22 ER diagram from Figure 7.21 with the equivalent table definition
The physical model operates at the lowest level of abstraction, describing the way data are saved on
storage media such as disks or tapes. The physical model requires the definition of both the physical
storage devices and the (physical) access methods required to reach the data within those storage
devices, making it both software- and hardware-dependent. The storage structures used are dependent on
the software(the DBMS and the operating system) and on the type of storage devices that the computer
can handle. The precision required in the physical model’s definition demands that database designers
who work at this level have a detailed knowledge of the hardware and software used to implement the
database design.
The physical model is dependent on the DBMS, methods of accessing files, and types of hardware
storage devices supported by the operating system. When you can change the physical model without
affecting the internal model, you have physical independence. Therefore, a change in storage devices or
methods and even a change in the operating system will not affect the internal model.
17
References
Garcia-Molina, H.,Ullman, J.,Widom, J. (2008). Database Systems: The Complete Book (2nd ed., pp 15-
55). Pearson