Chapter 7 Conceptual Data Modeling ObjectOriented Systems Analysis

Chapter 7: Conceptual Data Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A. Hoffer

Chapter Objectives l After studying this chapter you should be able to: – Determine how to develop conceptual data models. – Understand UML notations for conceptual data modeling. – Explain relationship characteristics such as degree and multiplicity.

Chapter Objectives (Continued) l After studying this chapter you should be able to: – Describe data relationships such as association, aggregation, and generalization. – Describe different kinds of attributes such as identifier, multivalued, and derived.


What Is a Conceptual Data Model? l A conceptual (or logical) data model is a model that represents data in a structured/organized manner l A conceptual/logical data model also represents the relationships between data l A conceptual/logical data model is independent of any database management system or other physical implementation considerations.

What Is a Conceptual Data Model? l A conceptual data model focuses on data. Although class diagrams also represents required operations l A conceptual data model is similar to an ER (Entity Relationship) database model l Represented by UML class diagrams

Class Diagram Elements l Classes l Objects l Attributes l Identifiers l Operations l Associations, aggregations, compositions l Generalizations

What Is an Object? l Object – An object is an entity that encapsulates data (attributes) and behavior (operations) l Examples: product, employee, order, line item l Class – a set of objects that share the same data and behavior. A class is a template or a blueprint for an object l Instance – a single object from a class.

Class vs. Object Instances Class (abstract) Instances (concrete)

UML Class symbol has three parts: 1) Name 2) List of attributes 3) List of operations

What is an Attribute? l An attribute is a data element that a class of objects will have. It is a property, a characteristic, a piece of information. l Example: customer. Num, invoice. Date, car. Model, payment. Status, course. Id, dog. Name, etc. l Each object instance will have different values for each of attribute l The full UML syntax for an attribute is: visibility attribute. Name : attribute. Type = default. Value l In the analysis phase (conceptual modeling), only attribute names are identified

Types of Attributes l Simple attributes – contain single data item l Identifiers – Identifies that object instance with a unique key value l Multi-valued attributes – contain multiple values simultaneously. Example: multiple phone numbers. Implemented as an array, a list, or a collection class l Composite attributes – group of related attributes. Example: a name (composed of first, last, middle), an address, a bank number, etc. Implemented as a separate class

Stereotypes in Class Diagrams • Stereotype – a construct that “extends” the UML vocabulary • We have seen <<include>> and <<extends>> in the use case diagrams • In class diagrams we use stereotypes such as: • <<PK>> for primary key identifier • <<multivalued>> for multi-valued attributes

Primary key is a unique identifier; no two Student object instances will have the same student. Id value.

Identifiers and Keys l Identifier – an attribute (or combination of attributes) that is selected to be used as the unique identifier for a class – i. e. as a primary key l Candidate key – an attribute (or combination of attributes) that also uniquely identifies each object of a class. However, for various reasons, these candidate keys were not chosen as primary keys. Examples: a social security num, a phone number.

Important Considerations for Selecting Primary Keys l Choose a primary key that will not change l Choose a value that is guaranteed not to have null l Avoid intelligent keys, keys that have meanings. These may require a change in value at some point in their lifetime. Instead choose a surrogate key, one with no special meaning l Choose a primary key that is as small as possible, - single attribute is better than composite attribute - numeric type is better than character type

Multivalued Attribute Multivalued attribute can contain multiple values; a student may have several phone numbers

Composite Attribute Composite attributes have multiple attributes (sub-attributes). They are treated as separate classes in conceptual data models.

What Is a Operation? l An operation is a process that a class can carry out l Implemented in OO as a method l Example: register. Student, login. Customer, determine. Tax, apply. Cash, compute. Invoice, etc. l In the analysis phase - identify the method name( ). As you elaborate, add more detail. l The full UML syntax for a method signature: visibility operation. Name (parameter. List) : return. Type

What Is a Relationship? l. A connection between a class and another, or the class to itself l In a UML class diagram, represented as a line connecting two or more class boxes (or connecting one class to itself)

What Is Relationship Degree? l The number of classes that participate in a relationship l Main degrees: – Unary – a relationship of a class to itself. It is between different objects of the same class – Binary – a relationship between a class and another. It is a relationship between objects of two different classes

Unary relationships exist between two objects of the same class Another example is a company org. chart

This is a binary relationship, which indicates that an employee has a relationship with a department.

Roles identify the purpose of each class in the relationship. Here worker and employer are the roles. The name of the relationship is works

What Is Relationship Multiplicity? l The range/number of objects in Class A that can or must be associated with each object of Class B. l. A multiplicity is made up of: – A minimum cardinality – the minimum number of objects in the relationship – A maximum cardinality – the maximum number of objects in the relationship

Relationship Multiplicity l Relationships can be: Ø One–to–One Ø One–to–Many Ø Many–to–Many

Multiplicity notation is: min. . max This shows that one movie can be stocked as any number of videotapes, or none at all

Fixed cardinality involves an actual number instead of the generic n This indicates that the maximum number of sections an instructor can teach is 6

Roles make it clearer to see which should be on the one side and which should be on the many side of the relationship.

What Is an Associative Class? l In the conceptual analysis phase, when you have a many-to-many relationship, you can leave that as is. Optionally you can model this as an associative class l An associative class is required if the association needs to capture additional attributes of its own l Once you begin the physical design phase, if you still have a many-to-many relationship, You must model this using an associative class l An associative class is represented as a class connected to an association with a dotted line

Student A single Student has many Instructors and a single Instructor teaches many Students Instructor Course A Course represents an associative relationship between an student and an instructor, and has an attribute pertaining to that relationship

Sometimes associative classes have their own relationships with other classes. Assignment Skill

Types of Associations • Association – no object is subordinate to any other. • Aggregation – one class represents the whole, and the other represents the part, it is a loose coupling, the parts can exist independently without the whole. (e. g. class and students, magazines and articles) • Composition – an aggregation with a tight coupling, • the parts cannot exist without the whole. (e. g. invoice and invoice line items, body and legs)

Aggregation is modeled as Open diamond -loose coupling(A player is part of a team, but could also exist without being part of a team) Composition is modeled as Closed diamond -tight coupling(course line item cannot exist without course registration)

Navigability • Navigability indicates a responsibility of one side of the relationship to know about the other side of the relationship, but not the other way around • It is depicted by an arrow. The non-arrow end is the responsible class.

Navigability 0. . n 1 Navigability means responsibility. Here Employee is responsible to tell you what department As we elaborate, we will add dept. Id in the employee class

What Is Generalization? l A Superclass – A class relationship in which this class forms a broader category of another class l A Subclass – A class relationship in which this class forms a more specific sub-category of another class l Inheritance – A subclass will inherit all the attributes and operations of its superclass. A subclass contains all the information of the superclass plus more specific information. l l Inheritance is an “is-a” relationship Aggregation & composition are a “has-a” relationships

Generalization is modeled as an arrow pointing to the superclass. (A car “is-a” vehicle, a truck “is-a” vehicle)


Recap l After studying this chapter we learned to: – Use UML notation for conceptual modeling. – Understand relationship multiplicity and degree. – Work with attributes, identifier, multivalued, and composite attributes. – Work with aggregation, composition, and generalization.
- Slides: 40