Home > Articles

  • Print
  • + Share This

One-to-One Relationships

We might consider one-to-one relationships as strong or weak in nature. Weak relationships are just simple references to other classes that are shareable across multiple object instances. For example, a CPerson class can be referenced by many other classes, with a particular OPerson instance being referenced by multiple object instances of disparate classes. Strong relationships, on the other hand, are usually the result of containment relationships, where one object is the sole user of a subordinate object. In an automotive manufacturing application that tracks the serial numbers of finished units, an example might include the CSerializedEngine and CSerializedAutomobile classes, where each OSerializedEngine object can belong to only one OSerializedAutomobile object. Figure 3.5 shows a weak reference, whereas Figure 3.6 shows its strong counterpart.

In Figure 3.5, we show a graphical representation of a weak reference. In this example, the CPerson class (and thus, object instances based on the class) is referenced by both the CAccount and CLoan classes. In the real world that forms the basis for this mini-model, the relationship diagram indicates that it is possible for the same person to have both a checking account and a house or car loan at the bank. The same person could have multiple accounts or loans at the same bank.

In Figure 3.6, we show the graphical representation of a strong, or containment, reference. In this example, we show how a finished, serialized automobile has an engine and transmission, both of which the manufacturer serializes as well for tracking purposes. Each OSerializedEngine and OSerializedTransmission instance will reference only one instance of the CSerializedAutomobile class.

Figure 3.5 A weak association relationship.

Figure 3.6 A strong association relationship.

 

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.