42
Relationships in Detail 1

Data Modeling Chapter 3

Embed Size (px)

DESCRIPTION

Setec

Citation preview

Chapter 3

Relationships in Detail1RelationshipsTen different relationship typesNontransferabilityRelationships that seem to have attributesRules of Normalization2OverviewIntroductionThis lesson discusses in detail how to establish a relationship between two entities. You meet the ten types of relationship and examples of the less frequent types. This lesson looks at nontransferable relationships and discusses the differences and similarities between relationships and attributes. It also provides a solution for the situation where a relationship seems to have an attribute. Finally, the rules of normalization are discussed in the context of conceptual models.ObjectivesAt the end of this lesson, you should be able to do the following:Create a well-defined relationship between entitiesIdentify which relationship types are common and which are notGive real-life examples of uncommon relationship typesChoose between using an attribute or a relationship to model particular informationResolve a m:m relationship into an intersection entity and two relationshipsResolve other relationships and know when to do soRules of NormalizationDetermine the existence of a relationship Choose a name for the relationship from both perspectivesDetermine optionalityDetermine degreeDetermine nontransferability

3Establishing a RelationshipDetermining the Existence of a Relationship Ask, for each of your entities, if it is somehow related to one or more of the entities in your model, and, if so, draw a dotted skeleton relationship line.Usually all entities in a model are related to at least one other entity. Exceptions are rare, but they do exist.Two entities can be related more than once. For example, in the Electronic Mail system there are two relationships between entities MESSAGE and USER, one is about who is sending a MESSAGE and one about who receives a MESSAGE.An entity can be related to itself. This is called a recursive relationship. For example, a MESSAGE can be a reply to another MESSAGE. See the paragraph on recursive relationships for more details on this.Establishing the Relationship4USERMESSAGEsendingreceivingreplyingRelationship Names5USERMESSAGEsent bysender ofreply ofreplied to by sent toreceiver ofChoosing a Name for the Relationship Sometimes the relationship name for the second perspective is simply the passive tense of the other one, such as is owner of and is owned by. Sometimes there are distinct words for both concepts, such as parent of / child of or composed of / part of.Try to use names that end in a preposition.If you cannot find a name, you may find these relationship names useful:Consists of / is part ofIs classified as / is classification forIs assigned to / is assignment ofIs referred to / referring toResponsible for / the responsibility ofSometimes a very short name is sufficient, for example, with, in, of, for, by, about, at, into.Naming the Relationship6MESSAGEUSERreceivingA MESSAGE is received by a USERreceived byA USER is receiver of a MESSAGEreceiver ofNaming the RelationshipAre sent to and receiver of really opposite? If so, the assumption is that if a MESSAGE is sent to a USER, it also arrives. Maybe it is safer to name the relationship received by / receiver of...Optionality7USERMESSAGEwritten byauthor ofreply ofreplied to by received byreceiver ofDetermining Optionality of Both the Relationship EndsAnswer the questions: Must every MESSAGE be sent by a USER?Must every USER be sender of an MESSAGE?Must every MESSAGE be sent to a USER?Must every USER be addressed in a MESSAGE?When an answer is Yes the relationship end is mandatory, otherwise it is optional.Be careful at this point. Often a relationship end seems to be mandatory, but actually it is not. In the ElectronicMail example it seems that every MESSAGE must be sent by a USER. But a MESSAGE that was sent by an external user to an internal USER has no relationship to a USER, unless the system were to keep external users as well.Sometimes a relationship is ultimately mandatory, but not initially. Such a relationship should be modeled as optional.Optionality8Must every MESSAGE be received by a USER?No:Yes:YesMust every USER be receiver of a MESSAGE?NoMESSAGEreceiver ofUSERreceived byDetermining Degree of Both the Relationship EndsAnswer the questions:Can a MESSAGE be written by more than one USER?Can a USER be author of more than one MESSAGE?If the answer is No the degree is called 1.If the answer is Yes the degree is called many or just m.This must be determined for all relationship ends.Note that a mandatory many relationship end from A to B does not mean that it is mandatory for A to be split into more than onMandatory 1: Mandatory m9Asplit intopart of BEvery A must be split into at least one BEvery B must be part of exactly one ADegree10USERwritten byauthor ofreply ofreplied to by ATTACHMENTwithcontaining