Object-Role Modeling Fundamentals: A Practical Guide to Data Modeling with ORM by Terry Halpin

Object-Role Modeling Fundamentals: A Practical Guide to Data Modeling with ORM by Terry Halpin

Author:Terry Halpin [Halpin, Terry]
Language: eng
Format: azw3, pdf
Publisher: Technics Publications
Published: 2015-04-07T16:00:00+00:00


Figure 3.1 An ORM schema for Table 3.1, including value constraints

In principle, value constraints could be declared for CountryCode and CountryName, but the value lists would be very large (about 240 values in each list), and they would be somewhat unstable, since countries sometimes change their name, and over time some countries can be removed from or added to the official lists. So we’ll leave the conceptual schema as shown in Figure 3.1. When this is mapped to a relational schema, the code and name fact types for Country map to the table scheme Country(countryCode, countryName) with CountryCode as the primary key, and CountryName as a secondary key. We can now populate this table with the relevant data (e.g. based on country codes and names from the ISO 3166 standard). Such a table may be used in many databases, and is often called a reference table.

Although value constraints may seem fairly trivial, they are useful for picking up data entry errors, especially those that result from accidentally hitting the wrong key. Figure 3.2 provides a more comprehensive sample of value constraint settings for object types. These value constraint settings may also be applied to roles.

Ranges specified as n..m are assumed to be closed, so the end values n and m are included. For example, 0..100 includes 0 and 100 as well as the numbers in between. To exclude the start value n from the range, prepend a left parenthesis, and to exclude the last value m from the range, append a right parenthesis. So a range of the form (n..m excludes n but includes m; a range of the form n..m) includes n but excludes m; and a range of the form (n..m) excludes both n and m. This is useful if the underlying data type is a real number (e.g. float or decimal). On an ORM diagram, ranges are always displayed inside braces. For example, the range displayed as {(0..100} covers the positive (above 0) numbers up to 100. If desired, a square bracket may be used to explicitly indicate inclusion (the default). For example, “(0..100” and “(0..100]” mean the same. You may also combine enumerations and/or ranges into a single constraint, as in Figure 3.2(c).



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.