340 likes | 508 Views
Modeling Relationships . Farrokh Alemi, Ph.D. Definition of Hierarchy. A collection of super and sub entities. A super entity is the broadest definition of several sub entities. A sub entity is an entity that inherits its relationship from another entity. . Definition of Relationship.
E N D
Modeling Relationships Farrokh Alemi, Ph.D.
Definition of Hierarchy • A collection of super and sub entities. • A super entity is the broadest definition of several sub entities. • A sub entity is an entity that inherits its relationship from another entity.
Definition of Relationship • Relationship describes the link between two entities • Different words for the same idea • At the conceptual level (e.g. entity and their relationships) • At the physical level (tables, data classes and linkages)
Relationships Are Identified Through Sentences • A sentence containing the names of the two entities and a verb phrase in between. • Verb phrases: "has," "contains," "visits," "prescribes," "travels with," etc. • The two entities "Patient" and "Clinician" can be made into a sentence such as "A patient visits a clinician."
Relationships Revealed • Is one of the entities a look up table used to provide menu items for an attribute of the other entity. • Is one of the entities a subcategory to another. • Do two entities share an attribute.
Relationships Documentation • The name of first entity • The name of second entity • The verb phrase describing the relationship • The cardinality of the relationship • one to one, one to many or many to many
Some Relationships Suggest New Entities • Hierarchical • Many to many relationships
Generalization & Specialization • The process of abstracting from narrowly scoped terms into terms of broader scope is a generalization process. • Starting with a general term and narrowing its scope is a specialization process.
Hiearchy May Simplify Data Structures • Specializations of the more general data class Person • Oftentimes, introducing a subtype hierarchy can simplify the information model
Rules for Identifying Hierarchies • Super-type is the broadest entity, should have all the attributes that are shared across the sub-entities. • Each sub-entity should have an attribute that makes it different from other entities. • The attributes should be mutually exclusive.
Confusion • It may not be possible for sub types to unambiguously reside in one and only one of the subtypes specified in the hierarchy. • Refine further • If confusing, do not do it
Steps for Identifying a Hierarchy • Shared attributes • Discriminator attribute • Entity linkages at the super type level
Step Three: Linkages at Super Entity Level • Reduces unnecessary linkages • Simpler to read • Easier to implement
Advantages of Hierarchies Stabilize the overall model with respect to new requirements.
An example New Requirement: “Patient of record” becomes inactive but the system does not purge it
Insert a new entity in the hierarchy • Include the new entity in the discriminator attribute • Check that all sub entities are appropriately named
Check Sub Entities The first issue is whether the sub entity is distinct form other entities
Check Super Entity • Do the attributes in the super entity apply equally well to the new sub entity
Check Discriminator The third issue is whether the discriminator attribute in the super-entity applies to all sub types The importance of good entity and attribute definitions
Association Class Simplifies • Resolve all many-to-many linkages • A simpler way of capturing and tracking many relationships
Self Referral • A Person to Person Association • A self referring relationship is found in the same way as all relationships are found by making a sentence containing the name of the entity and a verb phrase
New Requirements • Some of the facilities may have multiple postal addresses. • One way to incorporate the new requirement would be to add multiple attributes to each one of the entities.
Take Home Lessons • We saw that scenarios focus on decisions • Scenarios contain use cases which reveal the information exchange • Exchanges are used to specify fields.