8.5. Mapping from ORM to ER

Fully attributed IDEFIX schemas are essentially relational schemas displayed in a different notation. For this reason, Microsoft’s ORM Source Model solution treats IDEFIX as simply a different relational style. If you are using that tool, you can generate IDEFIX schemas from ORM schemas by automatically generating the relational schema, setting the drawing style to IDEFIX, and then noting any extra ORM rules as textual annotations.

If instead you need to manually generate IDEF1X schemas from ORM, follow the relational mapping (Rmap) procedure discussed in Chapter 11 to obtain a relational schema and then redraw it in IDEF1X.

Mapping from ORM to a true ER depends on the ER dialect (e.g., does it support Alary associations, multivalued attributes, any form of objectification, or derived attributes/associations?). Industrial ER dialects typically support none of these options. The ERmap procedure in Table 8.2 provides basic guidelines for mapping ORM to Barker ER or IE.

Table 8.2. ERmap Procedure.
StepAction
1Preprocess (the ORM schema (actually or mentally)
 1.1 Replace objectified associations by coreferenced object types
 1.2 Binarize n-ary associations by co-referencing
 1.3 Binarize any sets of exclusive unaries
2Model selected object types as entity types, and map a selection of their n: 1 and 1:1 associations as attributes
3Map remaining unary fact types lo Boolean attributes or subtypes
4Map remaining fact types to associations
5Map ORM constraints to ER graphic constraints, textual constraints, or notes
6Retain subtypes, but map subtype definitions to textual constraints
7Map derived fact types to textual derivation rules, and map semi-derived fact types to attributes/associations plus textual derivation rules

We now illustrate the steps in this procedure with examples using the Barker ER notation. Step 1.1 replaces objectified associations by coreferenced object types. For example, if the fact type Person wrote Paper is objectified as Writing, replace this by Writing is by Person and Writing is of Paper, as shown in Figure 8.43.

Figure 8.43. Step 1.1: replace objectifications by coreferenced object types.


Step 1.2 binarizes n-ary predicates by co-referencing. For example, the ternary Room at HourSlot is booked for Activity is replaced by forming a coreferenced entity type Room-Booking, as shown in Figure 8.44.

Figure 8.44. Step 1.2: replace n-ary fact types by coreferenced object types.


Step 1.3 binarizes any sets of exclusive unaries. For example, the Employee is male and Employee is female fact types are replaced by the single binary Employee is of Gender, with relevant constraint transforms, as shown in Figure 8.45.

Figure 8.45. Step 1.3: replace any set of exclusive unaries by a binary fact type.


In step 2, we decide which object types to model as entity types and which n: and 1:1 ORM associations to remodel as attributes. Typically, entity types that play functional fact roles are retained as entity types. In rare cases, value types that are independent or play explicit mandatory, functional fact roles map to entity types. Functional binary (n:1 and 1:1) associations from an entity type A to a value type B, or to an entity type B about which you never want to record details, usually map to an attribute of A. If you have specified role names, these can usually be used as attribute names, with the object type name becoming the attribute’s domain name.

The mapping in Figure 8.46 illustrates several of these step 2 considerations, as well as step 5 (map ORM constraints to ER graphic constraints, textual constraints, or notes).

Figure 8.46. Step 2: map selected n:1 and 1:1 associations to attributes.


The “{M, F}” annotation is a textual note to capture the value constraint on gender codes. The “{Ul}” annotation is a textual note to indicate a uniqueness constraint on the ssn attribute. Neither of these textual annotations is part of the Barker ER notation.

In step 3 we map unaries to Boolean attributes or to subtypes. The example in Figure 8.47 assumes a closed world interpretation for the unary. If this is not the case, the is-smoker attribute is made optional and an UnknownSmoking subtype is added. Open/closed world aspects are discussed in more detail in Chapter 10.

Figure 8.47. Step 3: map unaries to Boolean attributes or subtypes.


In step 4, the remaining fact types are mapped to associations. Any m:n associations should remain that way, unless the target notation doesn’t support them (e.g., IDEF1X). In that case, you can replace the association by an intersection entity type as discussed earlier.

In the example shown in Figure 8.48, the n: fact type is retained as an association because it relates two entity types that will remain as such in the mapping. Even if the m:n association did not apply, we would normally retain Country as an entity type, since now or later we are likely to record details for it (e.g., country name).

Figure 8.48. Step 4: map remaining fact types to associations.


If an m:n association involves a value type, and the ER dialect does not support multivalued attributes, map the value type to an entity type. Figure 8.49 provides an example. Otherwise, where possible, transform the m:n association into multiple n: associations (e.g. Employee has PhoneNrl; Employee has PhoneNr2, etc.). Conceptual schema transformations like this are discussed in depth in Chapter 14.

Figure 8.49. Step 4: map remaining fact types to associations.


In step 5, the simplest constraints in ORM usually map in an obvious way to multiplicity (mandatory and/or cardinality) constraints, as illustrated earlier. The more complex ORM constraints have no counterpart in ER, so you need to record these separately in textual form. Table 8.3 summarizes the main correspondences.

Table 8.3. Mapping main ORM graphic constraints to ER (for use in step 5).
ORM constraintER
Internal UCMaximum multiplicity of 1, or {Un}
External UCComposite primary id (Barker) or textual constraint
Simple mandatoryMinimum multiplicity of 1, or textual constraint
Inclusive-orTextual constraint (unless within exclusive-or)
FrequencyMultiplicity or textual constraint
ValueTextual constraint
Subset and EqualityTextual constraints
ExclusionBarker exclusive arc, or textual constraint
Ring constraintsTextual constraint

In step 6, subtypes are mapped to subtypes, adding relevant constraints if needed. Subtype definitions are handled with discriminators and/or textual constraints. If needed, introduce an “Other” subtype to complete a partition. If needed, use multiple diagrams (e.g., when multiple categorization schemes apply to the same supertype). Figure 8.50 shows a simple example. The braced value constraint and footnoted constraints are not part of the Barker ER notation.

Figure 8.50. Step 6: map subtyping.


In step 7, we map derived and semiderived fact types. Industrial ER typically has no graphical support for derivation, so the derivation rules are captured as textual notes. Figure 8.51 provides a simple example. With these few hints, and the examples discussed, you should now have enough background to do the mapping manually. The mapping procedure is fairly boring and is best automated with a CASE tool.

Figure 8.51. Step 7: map derivation rules.


For mapping to IDEFIX, the relational mapping procedure discussed in Chapter 11 may be used essentially as is, treating the relationships as foreign key references and making the relevant notational variations.

Exercise 8.5

  1. Model the following application domain in your preferred version of ER or IDEFIX. We suggest that you do an ORM model first, but that’s up to you.

    A video store has a library of videotapes that may be lent to customers. Six extracts are shown from the information system used by the store. Several aspects have been simplified or removed to reduce the size of this problem. For example, addresses are shown as a single entry, and financial aspects are ignored. Data about a movie may be recorded before the store obtains a videotape of it. Each videotape contains a copy of exactly one movie, and is either purchased or leased from another supplier. The status or condition (Good, OK, Poor, X) of each tape is noted on a regular basis. A status of “X” indicates that the tape is excluded from the list of tapes that may be borrowed.

    MovieTitleCategoryCopy NrPurchase daleLease expiryStatus
    AP2KApocalypse 2000R101/10/2000 Good
    BMFBatman ForeverM    
    CJCity of JoyMA107/01/2000 OK
       2 01/01/2001X
    DSDonovan SingsG101/03/1999 Good
       201/03/1999 OK
    GHSTGhostM106/06/1991 X
       207/10/1991 Poor
       307/10/1991 X
    GQGalaxy QuestPG101/10/2000 OK
       2 07/01/2001Good
    MTXThe MatrixR111/11/1999 Good
       211/11/1999 Good
    MTX2The Matrix 2R    

    For excluded video tapes, a record is kept to indicate the reason for their exclusion and whether they are written off for taxation purposes. Here is a sample extract.

    MovieCopyNrCommentWritten off?
    CJ2faultyY
    GHST1faultyN
    GHST3stolenY

    The following table records details about the categories in which movies are classified.

    CategoryDescription
    GFor General exhibition
    PGParental Guidance recommended for persons under 15
    MRecommended for Mature audiences 15 years and over
    MAFor Mature Adults: restrictions apply to persons under the 15 years age
    RRestricted to adults 18 years and over

    For the current calendar year, a record is kept of which movies are the best sellers.

    MonthRankMovieTitle
    11MTXThe Matrix
     2AP2KApocalypse 2000
     3DSDonovan Sings
     .........
    21MTXThe Matrix
     2GQGalaxy Quest
     2DSDonovan Sings
     4AP2KApocalypse 2000
     .........

    Loans are charged to customers, who are identified by the number on their video storecard presented at the time of borrowing. The combination of name and address is unique for a customer. Customers who indicate a phone number must indicate when they may be contacted on that phone (D = day only; N = Night only; D&N = Day and Night). Customer details may be recorded before they take out any loan.

    CustomerNameAddressPhoneCall period
    1Frog F5 Ribbit Rd, Bellevue425 555 7000N
    2Jones E3 Sun Ave, Spokane  
    3Smith J520 Pike St, Seattle206 555 6789D
    4Jones E520 Pike St, Seattle206 555 6701D
    5Frog K5 Ribbit Rd, Bellevue425 555 7000D&N

    Each loan is identified by a loan number and may involve more than one tape. Customers may borrow tapes as often as they like and may even borrow the same tape more than once on the same day (after returning it). The rental of a video tape within a loan is called a Loanltem. Although return data for loan items may be derived from video tape returns and other data, to simplify the problem you can ignore this.

    Loan dateLoan nrCustomerVideotapeDale returned
    NrNameMovieCopy
    10/01/0090012Jones EGQ1?
        MTX110/02/2000
     90023Smith JGQ210/01/2000
    10/02/0090033Smith JMTX110/03/2000
        DS210/03/2000
        GQ210/03/2000
     90044Jones EGHST2?
    10/03/0090051Frog FAP2K110/03/2000
        MTX1?

  2. The following ORM schema models information about university academics. As a challenge exercise, map this to your preferred ER or IDEFIX notation, including some comments to cater for advanced constraints and multiple inheritance. You may wish to delay this until you have studied the relational mapping procedure in Chapter 11.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.196.175