Professional Documents
Culture Documents
Lecture 3 Lecture 3
1 Different Levels of Generalization
CMPS 328 CMPS 328
Rules Rules
Subtypes and Supertypes Using 3 Using Subtypes and Supertypes Using
Classes Classes
Attributes Attributes
www.gheadley.org/ub/cmps328 5 Diagramming and Definitions
Rules Rules
Relationships Relationships
1 / 22 9 Benefits of Subtypes 2 / 22
Lecture 3 Lecture 3
Classes While all have mothers, will run out of knowledge Classes
Family tree designs Diagramming and Diagramming and
Definitions Choice of classes is the issue Definitions
Attributes
Nouns from problem, mother, father, child overlap Attributes
Rules Rules
Child, Mother have redundant data
Overlaps Overlaps
Relationships Relationships
3 / 22 4 / 22
Different Levels of Generalization Rules versus Stability
Lecture 3 Lecture 3
CMPS 328
Important difference between models - number of rules CMPS 328
man-woman – three classes, six relationships
Difference is on level of generalization Generalization
person – two classes, four relationships Generalization
Rules Rules
Person is generalization of Man, Woman man-woman seems to represent more rules
Using Using
Man, Woman are specializations of Person Classes
man-woman – marriage is one man and one woman Classes
Overlaps Overlaps
Only sometimes reduce system complexity person – sex rules in program logic
Benefits Benefits
Often causes complexity by combining logic for subtypes Choice is where to build rules into system
Stopping Stopping
Reducing classes versus programming complexity Changing running database structure is expensive
Relationships Relationships
Assess likelihood of rule change in system lifetime
Likely – program logic
Not – database model
5 / 22 6 / 22
Lecture 3 Lecture 3
Do not build a rule into the data structure of a system unless Nice not to lose rules specific to men and woman
Generalization Generalization
you are reasonably confident that the rule will remain in force Even without subtypes, document the rules
Rules Rules
Classes
Problem of right level, opportunity to explore options Classes
Overlaps Overlaps
Stopping Stopping
Tendency to over do generalization
Relationships Relationships
Rules must exist somewhere – right place
Very general models abdicate responsibility
7 / 22 8 / 22
Subtypes and Supertypes as Entity Classes Subtypes and Supertypes as Entity Classes
Naming Subtypes
Lecture 3 Lecture 3
Rule
CMPS 328 CMPS 328
Subtypes and supertypes are entity classes.
Generalization Generalization
Classes Classes
Can have attributes – associate with relevant class Naming Naming
Can have relationships Permanent Employee not Permanent
Diagramming and Diagramming and
Attributes Attributes
Reasons
Subtypes Rules Rules
Documentation may show classes out of visual context
Overlaps Overlaps
Automatic generation of tables will lose context
Benefits Benefits
Stopping Stopping
Relationships Relationships
9 / 22 10 / 22
Lecture 3 Lecture 3
Rules Rules
Rule – Entity class inherits the definition from supertype Class Contract – Renewable Contract, Fixed-Term
Overlaps Overlaps
Subtype definition is about differentiation Contract
Benefits Benefits
Job Position subtyped – Permanent and Temporary Job Hold Renewal Date with Renewable Contract
Stopping Stopping
Position Hold Expiry Date with Fixed-Term Contract
Relationships Relationships
Definition for Permanent Job Position Hold End Date with Contract
“. . . a Job Position that . . . ”
11 / 22 12 / 22
Nonoverlapping and Exhaustive Nonoverlapping and Exhaustive
Lecture 3 Lecture 3
Attributes Attributes
Detailed look at family tree model
Person cannot be both a man and a woman Rules Rules
Overlaps Overlaps
Person must be either a man or a woman Sure we can classify into man or woman?
Benefits Benefits
13 / 22 14 / 22
Lecture 3 Lecture 3
Classes What business value of knowing they are the same Classes
Many roles: supplier, customer, investor, account holder,
Diagramming and person Diagramming and
employee Definitions Definitions
Attributes
Discretion again !!! Attributes
How can we subtype without overlap ?
Rules Do this with care ! Rules
Good news – people and organizations only common Overlaps Overlaps
major issue Ignore
Bank have one class for borrowers, guarantors, Ignore
Supertype Only
depositors Supertype Only
Benefits
Other classes for suppliers and stockholders Benefits
Stopping Stopping
Relationships Relationships
15 / 22 16 / 22
Overlapping Subtypes and Roles Overlapping Subtypes and Roles
Modeling only the Supertype Modeling the Roles as Participation in Relationships
Lecture 3 Lecture 3
Generalization Generalization
Use one supertype for all roles Rules Rules
Such as “legal entity class type” – company, partnership Classes Describe Supplier as Party who has a Contract Classes
Rules Rules
“Market Segment must be recorded if this Party has the Chen notation
Overlaps Overlaps
Role of Customer” Ignore Document in description of Party Ignore
Supertype Only Supertype Only
Participation Participation
Lost from diagram Role Classes Role Classes
Benefits Benefits
Stopping Stopping
Relationships Relationships
17 / 22 18 / 22
Lecture 3 Lecture 3
Many options on one diagram, each level is an option
Role entity classes CMPS 328 As we propose classes CMPS 328
Rules
Can we generalize these into a supertype Rules
Using
Simplify the “big picture” for communication Using
Classes
Summarize by removing subtypes Classes
Diagramming and
Vary across the model according to interest, audience Diagramming and
Create an class to hold the role Definitions Inviable models can be useful with customers Definitions
One-to-one relation between party and role Attributes Must finish viable first Attributes
Role entity class supertyped into Party Role Rules Allows synonyms Rules
Normal not implemented – lose too much information Overlaps Truck as an Asset subtype Overlaps
Ignore
Motor Pool Manager versus Accountant Benefits
Sometimes some intermediate supertyping Supertype Only
Participation Financial Instrument into Bond and Bill Stopping
All buyers of insurance same – type irrelevant Role Classes
Never have to implement
Benefits Relationships
“Role” is always in the class name – no primary data Inform view designs, capture rules
Stopping
Usually the neatest solution Develop design patterns
Relationships
19 / 22 Multiple modelers 20 / 22
When To Stop Supertyping and Subtyping Generalization of Relationships
Lecture 3 Lecture 3
Classes Classes
In practice more nuanced exclusivity
Diagramming and Diagramming and
When in doubt subtype Definitions Definitions
21 / 22 22 / 22