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.
Step | Action |
---|---|
1 | Preprocess (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 | |
2 | Model selected object types as entity types, and map a selection of their n: 1 and 1:1 associations as attributes |
3 | Map remaining unary fact types lo Boolean attributes or subtypes |
4 | Map remaining fact types to associations |
5 | Map ORM constraints to ER graphic constraints, textual constraints, or notes |
6 | Retain subtypes, but map subtype definitions to textual constraints |
7 | Map 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.
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.
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.
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).
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.
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).
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.
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.
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.
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.
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.
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.
Movie | Title | Category | Copy Nr | Purchase dale | Lease expiry | Status |
---|---|---|---|---|---|---|
AP2K | Apocalypse 2000 | R | 1 | 01/10/2000 | Good | |
BMF | Batman Forever | M | ||||
CJ | City of Joy | MA | 1 | 07/01/2000 | OK | |
2 | 01/01/2001 | X | ||||
DS | Donovan Sings | G | 1 | 01/03/1999 | Good | |
2 | 01/03/1999 | OK | ||||
GHST | Ghost | M | 1 | 06/06/1991 | X | |
2 | 07/10/1991 | Poor | ||||
3 | 07/10/1991 | X | ||||
GQ | Galaxy Quest | PG | 1 | 01/10/2000 | OK | |
2 | 07/01/2001 | Good | ||||
MTX | The Matrix | R | 1 | 11/11/1999 | Good | |
2 | 11/11/1999 | Good | ||||
MTX2 | The Matrix 2 | R |
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.
Movie | CopyNr | Comment | Written off? |
---|---|---|---|
CJ | 2 | faulty | Y |
GHST | 1 | faulty | N |
GHST | 3 | stolen | Y |
The following table records details about the categories in which movies are classified.
Category | Description |
---|---|
G | For General exhibition |
PG | Parental Guidance recommended for persons under 15 |
M | Recommended for Mature audiences 15 years and over |
MA | For Mature Adults: restrictions apply to persons under the 15 years age |
R | Restricted to adults 18 years and over |
For the current calendar year, a record is kept of which movies are the best sellers.
Month | Rank | Movie | Title |
---|---|---|---|
1 | 1 | MTX | The Matrix |
2 | AP2K | Apocalypse 2000 | |
3 | DS | Donovan Sings | |
... | ... | ... | |
2 | 1 | MTX | The Matrix |
2 | GQ | Galaxy Quest | |
2 | DS | Donovan Sings | |
4 | AP2K | Apocalypse 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.
Customer | Name | Address | Phone | Call period |
---|---|---|---|---|
1 | Frog F | 5 Ribbit Rd, Bellevue | 425 555 7000 | N |
2 | Jones E | 3 Sun Ave, Spokane | ||
3 | Smith J | 520 Pike St, Seattle | 206 555 6789 | D |
4 | Jones E | 520 Pike St, Seattle | 206 555 6701 | D |
5 | Frog K | 5 Ribbit Rd, Bellevue | 425 555 7000 | D&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.
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.
18.222.196.175