Upload
kimberly-hillary-jones
View
215
Download
0
Embed Size (px)
Citation preview
7-292.2911R McFadyen
TopicsTopics
topics:
– Developing a conceptual data model from use cases
– UML notations for conceptual data modeling
– UML class diagram bears a resemblance to an Entity Relationship Diagram (see 92.3914 for ERDs)
7-392.2911R McFadyen
TopicsTopics
UML:
– attributes
– association, aggregation, and generalization
– multiplicities, roles, …
7-592.2911R McFadyen
What Is a Conceptual Data Model?What Is a Conceptual Data Model?
A detailed model that shows the overall structure of organizational data; it is independent of any database management system or other implementation considerations.
Represented by UML class diagrams
Sources: • Current knowledge• Existing system• System documents / reports• Interviews• Use cases
7-992.2911R McFadyen
Conceptual Data Model ElementsConceptual Data Model Elements
ClassesAttributes IdentifiersAssociations, aggregations, compositionsGeneralizationsTime dimensions Integrity rulesSecurity controls
7-1092.2911R McFadyen
What Is an Object?What Is an Object?
An entity that encapsulates data and behavior
Examples: product, employee, order, line item
Class – a set of objects that share the same attributes, operations, relationships, and semantics (abstract)
Instance – a single object (concrete)
7-1192.2911R McFadyen
Instances
We use a rectangular shape to represent a class. It may be shown with one, two or three compartments
attributes
operations
Name of class
7-1392.2911R McFadyen
Types of AttributesTypes of Attributes
Simple attributes – contain single data item
Identifiers – unique key value
Multivalued attributes – contain multiple values simultaneously
Composite attributes – group of related attributes
7-1492.2911R McFadyen
Stereotypes in Class DiagramsStereotypes in Class Diagrams
• Stereotype – a construct that extends the UML vocabulary
• Identifier stereotype <<PK>> for primary key
• Multivalued stereotype <<multivalued>>
7-1592.2911R McFadyen
Primary key is a unique identifier; no two Student instances will have the same studentId value.
7-1692.2911R McFadyen
Multivalued attribute can contain multiple values; a student may have several phone numbers
7-1792.2911R McFadyen
Composite attributes have multiple components.They are treated as separate classes in conceptual data models.The attribute address is defined to be of type Address.
7-1892.2911R McFadyen
What Is a Relationship?What Is a Relationship?
A semantic connection between objects of one or more classes
In UML, represented as a line connecting two or more class boxes (or connecting one class to itself)
In UML, known as an association
7-1992.2911R McFadyen
This is association between two classes, and is known as a binary association: an employee works in a department.Binary associations are the most common type.
7-2092.2911R McFadyen
We use an adornment to indicate how to read the association: “an employee works in a department”
works in
7-2192.2911R McFadyen
Roles identify the purpose of each class in the relationship.•Rolenames are useful (much) later on when we have software classes with attributes referring to instances of classes•Note that neither class has an attribute referring to object(s) of the other class – that would be an implementation detail
7-2292.2911R McFadyen
What Is Relationship Degree?What Is Relationship Degree?
The number of classes that participate in a relationship
Main degrees:
– Unary – a relationship between objects of the same class
– Binary – a relationship between objects of two different classes
– Ternary – a relationship between objects of three different classes
– !NOTE. Our text differs from other texts in these definitions:
• Degree is the number of objects that participate – there is no Unary relationship.
• Instead of unary, the term recursive is used
From text
7-2492.2911R McFadyen
This example is related to a business rule that states a specific quantity of a Part is shipped by a Vendor to a Warehouse.
The ternary relationship is expressed as in the following slide:
7-2592.2911R McFadyen
An n-ary association, n>2, is shown with a diamond symbol
Part
Vendor Warehouseships
The diamond is the symbol used for a n-ary association
7-2692.2911R McFadyen
An analyst will likely promote the association to a full class. This changes the model so it now has four classes and three binary associations.
Part
Vendor WarehouseshipsShipment
7-2792.2911R McFadyen
MultiplicityMultiplicity
Associations can be:
– One – to – one
– One – to – many
– Many – to – many
7-2892.2911R McFadyen
MultiplicityMultiplicity
The range of the number of objects in a class that can or must be associated with each object of another class in an association.
* * represents zero or more0..* same meaning as above1..* one or more1..5 one, two, three, four, or five0,1 zero or one1 exactly one3 exactly three
Ranges use ..
Enumeration uses ,
7-3092.2911R McFadyen
Roles, especially for reflexive associations, make it clear how an object participates in the association.Here, one object is the supervisor and the other is the subordinate.
7-3292.2911R McFadyen
Associative ClassAssociative Class
An associative class is both a class and an association. It contains attributes and/or participates in relationships in its own right
Represented as a class connected to an association with a dotted line
Typically appears with a many-to-many association – there probably are attributes that describe the association
7-3392.2911R McFadyen
A Certificate represents a relationship between an employee and a course, and has an attribute pertaining to that relationship
7-3492.2911R McFadyen
In a many-to-many association, an object of one class can be associated with an object of the other class at most one time. This is true irrespective of whether we have an associative class or not:
Employee Course* *
Employee Course* *
Certificate
completes
7-3592.2911R McFadyen
Suppose an employee can take the same course more than once. We must promote the associative class to a full class:
Employee Course* *
Employee Course
* *Certificate
1 1
dateCompleted
CertificatedateCompleted
7-3692.2911R McFadyen
Reconsider marriedTo. Do we need an associative class? Do we need to promote an associative class to a full class?
7-3792.2911R McFadyen
Sometimes associative classes have their own relationships with other classes.
7-3892.2911R McFadyen
Types of AssociationsTypes of Associations
• Association – no object is subordinate to any other.
• Aggregation – one class represents the whole, and the other represents the part, but there is no concept of ownership
• Composition – one class represents the whole, and the other represents the part; the whole contains or owns the part; the part cannot exist without the whole.
• Generalization/specialization –an association between a general thing (the superclass or parent class) and a more specific kind of thing (the subclass or child class)
7-4092.2911R McFadyen
GeneralizationGeneralization
• a generalization is an association between a general thing (the superclass or parent class) and a more specific kind of thing (the subclass or child class)
• Inheritance – A subclass inherits all the attributes and operations of its superclass; an instance of the subclass contains all the same information (plus more) as an instance of the superclass
• An instance of a subclass is also an instance of the superclass
7-4192.2911R McFadyen
Generalization (Ch 26)
Multiple subclasses can be grouped to indicate they are relatedsubclasses
LibraryMember
StaffMember StudentMember
It then becomes meaningful to consider certain constraints:
complete, incomplete, disjoint, overlapping
7-4292.2911R McFadyen
Generalization
Inheritance of attributes and behaviour:•everything a LibraryMember can do, a StaffMember can do•everything a LibraryMember can do, a StudentMember can do
•If a LibraryMember can borrow a book, so can a StaffMember and a StudentMember
•a StaffMember and a StudentMember have all the attributes the LibraryMember has, and possibly moreSpecialization: there are some things that a specialized class can do that a LibraryMember cannot
LibraryMember
StaffMember StudentMember
7-4392.2911R McFadyen
example:
•a SavingsAccount is a specialized kind of BankAccount•a ChequingAccount is a specialized kind of BankAccount•a BankAccount is a specialized kind of Asset •RealEstate is …
Asset
RealEstate BankAccount Security
SavingsAccount ChequingAccount
7-4492.2911R McFadyen
PaymentAmount: money
Cash Payment Credit Payment Cheque Payment
SalePays-for1 1
Every payment, regardless of whether it is cash, credit, or cheque, has an Amount and it is associated with a Sale
CreditCard Cheque
1
1
1
*
7-4592.2911R McFadyen
Motivation for partitioning a conceptual class into subclasses:
•subclass has additional attributes of interest
•subclass has additional associations of interest
•subclass is operated on, handled, reacted to, or manipulated differently than the superclass or other subclasses
•the subclass concept represents an animate thing that behaves differently than the superclass or other subclasses
7-5092.2911R McFadyen
Multiple inheritance is complicated and not supported by all object-oriented programming languages.
7-5192.2911R McFadyen
This is a difficult model to work with. An employee could be a Secretary paid hourly, but another Secretary may be paid a salary.
7-5392.2911R McFadyen
Instead of Figure 7.23, a modeler might use:
Part
BasicPart Aggregate
1..*
What is this?
What does this allow us to build?
Are there some common attributes for BasicPart and Aggregate? Are there common operations?
Composed of
subpart