R McFadyen Chapter 7 Conceptual Data Modeling
R McFadyen Topics 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 for ERDs)
R McFadyen Topics UML: –attributes –association, aggregation, and generalization –multiplicities, roles, …
R McFadyen
R McFadyen 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
R McFadyen Use cases are key inputs to conceptual data modeling.
R McFadyen
R McFadyen
R McFadyen Conceptual Data Model Elements Classes Attributes Identifiers Associations, aggregations, compositions Generalizations Time dimensions Integrity rules Security controls
R McFadyen 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)
R 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
R McFadyen
R McFadyen Types of Attributes Simple attributes – contain single data item Identifiers – unique key value Multivalued attributes – contain multiple values simultaneously Composite attributes – group of related attributes
R McFadyen Stereotypes in Class Diagrams Stereotype – a construct that extends the UML vocabulary Identifier stereotype > for primary key Multivalued stereotype >
R McFadyen Primary key is a unique identifier; no two Student instances will have the same studentId value.
R McFadyen Multivalued attribute can contain multiple values; a student may have several phone numbers
R 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.
R McFadyen 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
R 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.
R McFadyen We use an adornment to indicate how to read the association: “an employee works in a department” works in
R 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
R McFadyen 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
R McFadyen A reflexive association reflexive
R 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:
R McFadyen An n-ary association, n>2, is shown with a diamond symbol Part VendorWarehouse ships The diamond is the symbol used for a n-ary association
R 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 VendorWarehouse ships Shipment
R McFadyen Multiplicity Associations can be: –One – to – one –One – to – many –Many – to – many
R McFadyen Multiplicity 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 more 0..*same meaning as above 1..*one or more 1..5one, two, three, four, or five 0,1zero or one 1exactly one 3exactly three Ranges use.. Enumeration uses,
R McFadyen Multiplicity notation is: min..max
R 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.
R McFadyen A reflexive association What are the multiplicities?
R McFadyen Associative 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
R McFadyen A Certificate represents a relationship between an employee and a course, and has an attribute pertaining to that relationship
R 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: EmployeeCourse ** EmployeeCourse ** Certificate completes
R McFadyen Suppose an employee can take the same course more than once. We must promote the associative class to a full class: EmployeeCourse ** EmployeeCourse ** Certificate 11 dateCompleted Certificate dateCompleted
R McFadyen Reconsider marriedTo. Do we need an associative class? Do we need to promote an associative class to a full class?
R McFadyen Sometimes associative classes have their own relationships with other classes.
R McFadyen Types 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)
R McFadyen Composition Aggregation
R McFadyen Generalization 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
R McFadyen Generalization (Ch 26) Multiple subclasses can be grouped to indicate they are related subclasses LibraryMember StaffMemberStudentMember It then becomes meaningful to consider certain constraints: complete, incomplete, disjoint, overlapping
R 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 more Specialization: there are some things that a specialized class can do that a LibraryMember cannot LibraryMember StaffMemberStudentMember
R 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 RealEstateBankAccountSecurity SavingsAccountChequingAccount
R McFadyen Payment Amount: money Cash Payment Credit PaymentCheque Payment Sale Pays-for 1 1 Every payment, regardless of whether it is cash, credit, or cheque, has an Amount and it is associated with a Sale CreditCardCheque *
R 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
R McFadyen
R McFadyen Using the UML symbol
R McFadyen
R McFadyen
R McFadyen Multiple inheritance is complicated and not supported by all object- oriented programming languages.
R 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.
R McFadyen Consider:
R McFadyen Instead of Figure 7.23, a modeler might use: Part BasicPartAggregate 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
R McFadyen Summary We have covered : –Developing data models from use cases –UML notation for conceptual modeling –Associations and multiplicity –Aggregation, composition, and generalization –Attributes: identifier, composite, multivalued, derived attributes