Conceptual Data Modeling. What Is a Conceptual Data Model? A detailed model that shows the overall...

Preview:

Citation preview

Conceptual Data Conceptual Data ModelingModeling

What Is a Conceptual What Is a Conceptual Data Model?Data Model?

A detailed model that shows the A detailed model that shows the overall structure of organizational overall structure of organizational datadata

It is independent of any database It is independent of any database management system or other management system or other implementation considerations.implementation considerations.

Represented by UML class Represented by UML class diagramsdiagrams

Use cases are key inputs to conceptual data modeling.

Conceptual Data Model Conceptual Data Model ElementsElements

ClassesClasses AttributesAttributes IdentifiersIdentifiers Associations, aggregations, Associations, aggregations,

compositionscompositions GeneralizationsGeneralizations Time dimensionsTime dimensions Integrity rulesIntegrity rules Security controlsSecurity controls

Object/Class/InstanceObject/Class/Instance

ClassClass::– A person, place, thing, event, or concept in user A person, place, thing, event, or concept in user environment about which organization wishes to environment about which organization wishes to maintain data.maintain data.– It is a set of objects that share the same It is a set of objects that share the same attributes, operations, relationships, and attributes, operations, relationships, and semantics (abstract).semantics (abstract).

ObjectObject::– A single occurrence of a class;A single occurrence of a class; encapsulates data encapsulates data and behavior.and behavior.(Examples: product, employee, order, line item)(Examples: product, employee, order, line item)

InstanceInstance::– A single object (concrete). A single object (concrete). (i.e. John Smith, student)(i.e. John Smith, student)

Class

Instances

UML Class symbol has three parts:

1) Name2) List of attributes3) List of operations

Types of AttributesTypes of Attributes

Simple attributesSimple attributes – contain single data item – contain single data item (i.e. name)(i.e. name)

IdentifiersIdentifiers (aka (aka Primary KeyPrimary Key) – contain unique ) – contain unique key value for class key value for class (i.e. studentId in Student class)(i.e. studentId in Student class)

Multivalued attributesMultivalued attributes – contain multiple values – contain multiple values simultaneously simultaneously (i.e. phone number – may have several (i.e. phone number – may have several phone numbers - home, cell, beeper)phone numbers - home, cell, beeper)

Composite attributesComposite attributes – group of related – group of related attributesattributes(i.e. address – contains sub-attributes of street, city, state, zip)(i.e. address – contains sub-attributes of street, city, state, zip)

Stereotypes in Class Stereotypes in Class DiagramsDiagrams

Stereotype – a construct that extends the Stereotype – a construct that extends the UML vocabularyUML vocabulary

Identifier stereotype Identifier stereotype <<PK>><<PK>> for primary for primary key key

Multivalued stereotype Multivalued stereotype <<multivalued>><<multivalued>>

Since there are no standard UML symbols for Since there are no standard UML symbols for primary key or multivalued they are created primary key or multivalued they are created using stereotypesusing stereotypes

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

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

Composite attributes have multiple sections (subattributes).They are treated as separate classes in conceptual data models.

Selecting Primary KeysSelecting Primary Keys

Choose a primary key that will not change its value over the Choose a primary key that will not change its value over the life of each object of the class (i.e. name and address life of each object of the class (i.e. name and address changes so they are not good candidates)changes so they are not good candidates)

Choose a primary key such that, for each object of the Choose a primary key such that, for each object of the class, the attribute is guaranteed to have valid values and class, the attribute is guaranteed to have valid values and not be null. (include controls in data entry and not be null. (include controls in data entry and maintenance routines to eliminate errors)maintenance routines to eliminate errors)

Avoid the use of so-called intelligent keys. For instance, the Avoid the use of so-called intelligent keys. For instance, the 11stst two digits stand for a warehouse location or region. two digits stand for a warehouse location or region. These conditions can change.These conditions can change.

Consider substituting single-attribute surrogate keys for Consider substituting single-attribute surrogate keys for large composite keys.large composite keys.

What Is A What Is A Relationship?Relationship?

A semantic connection between objects of A semantic connection between objects of one or more classesone or more classes

In UML, represented as a line connecting two In UML, represented as a line connecting two or more class boxes (or connecting one class or more class boxes (or connecting one class to itself)to itself)

Labeled with verb phrasesLabeled with verb phrases

A relationship is generally described by its A relationship is generally described by its name, degree, and multiplicity (minimum name, degree, and multiplicity (minimum and maximum cardinality)and maximum cardinality)

This is a binary relationship, which indicates that an employee works in a department.

Roles identify the purpose of each class in the relationship.

What Is Relationship What Is Relationship Degree?Degree?

The number of classes that The number of classes that participate in a relationshipparticipate in a relationship

Main degrees:Main degrees:– Unary – a relationship between Unary – a relationship between

objects of the same class objects of the same class (also called (also called recursive)recursive)

– Binary – a relationship between Binary – a relationship between objects of two different classes objects of two different classes (most (most common)common)

– Ternary – a relationship between Ternary – a relationship between objects of three different classesobjects of three different classes

Quantity is the amount of a particular Part shippedfrom a particular Vendor to a particular Warehouse

What Is Relationship What Is Relationship Multiplicity?Multiplicity?

The range of the number of objects in The range of the number of objects in Class A that can or must be Class A that can or must be associated with each object of Class associated with each object of Class B.B.

A multiplicity is made up of:A multiplicity is made up of:– A minimum cardinality – the minimum A minimum cardinality – the minimum

number of Class A objects possiblenumber of Class A objects possible– A maximum cardinality – the maximum A maximum cardinality – the maximum

number of Class A objects possiblenumber of Class A objects possible

Relationship Relationship MultiplicityMultiplicity

Relationships can be:Relationships can be:

– One – to – oneOne – to – one

– One – to – manyOne – to – many

– Many – to – manyMany – to – many

Multiplicity notation is: min..max

Store stocks more than 1 videotape of a movie

1 instructor teaches 0-6 sections

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

0-1 supervisor manages0 to many subordinates

What Is an Associative What Is an Associative Class?Class?

A special purpose class that represents A special purpose class that represents an association (relationship) between an association (relationship) between classes and contains attributes and/or classes and contains attributes and/or relationships in its own rightrelationships in its own right

A many-to-many association that is A many-to-many association that is modeled as a separate classmodeled as a separate class

Represented as a class connected to Represented as a class connected to an association with a dotted linean association with a dotted line

A Certificate represents a relationship between an employee and a course, and has an attribute pertaining to that relationship (dateCompleted)

Sometimes associative classes have their own relationships with other classes.

Types of AssociationsTypes of Associations

AssociationAssociation – no object is subordinate – no object is subordinate to any other.to any other.

AggregationAggregation – one class represents – one class represents the whole, and the other represents the the whole, and the other represents the part, but it is a loose coupling.part, but it is a loose coupling.

CompositionComposition – an aggregation with a – an aggregation with a tight coupling. The whole and the part tight coupling. The whole and the part cannot exist without each other.cannot exist without each other.

The whole The part

Course registration needs at least 1 course and vice versa

What Is Generalization?What Is Generalization?

A superclassA superclass – subclass– subclass relationshiprelationship in in which one class forms a broader category which one class forms a broader category in which the other class is a sub-categoryin which the other class is a sub-category

InheritanceInheritance – A subclass will inherit all – A subclass will inherit all the attributes and operations of its the attributes and operations of its superclass; an instance of the subclass superclass; an instance of the subclass contains all the same information (plus contains all the same information (plus more) as an instance of the superclass.more) as an instance of the superclass.

Multiple inheritance is complicated and not supported by all object-oriented programming languages.

Any Questions?Any Questions?

Recommended