1 / 41

Converting An Essential Entity/Relationship Model Into A Real Database Design

Converting An Essential Entity/Relationship Model Into A Real Database Design. David C. Hay Enterprise Data World Austin, Texas May 1, 2014. Enterprise Data World David Hay Tampa, Florida April 6, 2009. Essential Strategies International. 13 Hilshire Grove Lane Houston, TX 77055

roana
Download Presentation

Converting An Essential Entity/Relationship Model Into A Real Database Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Converting AnEssential Entity/Relationship ModelIntoA Real Database Design David C. Hay Enterprise Data World Austin, Texas May 1, 2014 Enterprise Data World David Hay Tampa, Florida April 6, 2009 Essential Strategies International 13 Hilshire Grove Lane Houston, TX 77055 http://essentialstrategies.com

  2. Different points of view . . . Designer Data modeler End User

  3. Data Modeler’s Assignment . . . • Capture the language of the business • Do so in as flexible and robust a manner as possible. Data modeler

  4. How to achieve flexibility and robustness . . . • Generalize entity classes, • Each describes as large a population of phenomena as possible. • For example, a Party is a Person or an Organization that is of interest to the company. Organization in this case can then have more specific sub-types, like Company, GovernmentAgency, Household, etc. • Separate roles from the definitions of things. • For example, an “Employee” is a Person who is employed by an Organization, such as a company. A “Vendor” is a Party who is a vendor in an Order.

  5. How to achieve flexibility and robustness . . . • Put as much of the language of the business as instances of ...type entity classes. • This includes categories, like Activity Type and Product Type. • Treat nearly all attributes as beingmulti-valued, requiring a separate entity class. • For example, Party Characteristic, with an intersect entity class Party Characteristic Value each instance of which contains a “Value” of a Party Characteristic for a particular Party. • Essential Data Model – • General concepts • Super-set of user views

  6. The End User’s view . . . • The end user, on the other hand deals with very concrete, particular things. • The user interface must reflect the way the user deals with things today. • The behavior of the system is an extension of the user’s behavior. • Ideally ‘e participated in the modeling and agreed with the overall concepts. • But those abstractions have little to do with today’s problems. End User

  7. Designer’s Assignment . . . • Designers may not be experienced with models this abstract. • This paper is intended to present some of the more basic steps required to convert an essential data model into a database design. • It turns out that abstract models are implemented using the same steps as not so abstract models.

  8. Connections to System Users . . . • Conceptual Data Model – • General concepts • Super-set of user views • User Views – • Concrete terms • Habits and personal preferences • Database and Application Design • True to conceptual model • Accommodates technological limits • Makes user views possible

  9. UML Alert! • Both the Essential Data Modeland the Relational Database Design shown here use constrained versions of the Unified Modeling Language. • Translation:

  10. Four Steps to Design • Resolve sub-types. • Perform default database design • Design computed columns. • De-normalize as necessary. • Deal with those parameters.

  11. Four Steps to Design • Perform default database design • Resolve sub-types. • Design computed columns. • De-normalize as necessary. • Deal with those parameters

  12. The Default Database Design . . . • Each entity class becomes a table. • Each attribute becomes a column. • Each primary identifier becomes a primary key. Each component of the identifier is a reference to a column in the table. • Each role on the “many” end of a relationship becomes a foreign key, composed of pointers to the columns in the other table’s primary key. • If a relationship from table A to table B was part of a unique identifier, the columns in table A that are the foreign key implementation of that relationship become part of the primary key for Table A.

  13. An Entity/Relationship Diagram . . . Identifiers {id}

  14. The Default Conversion . . . Foreign Key Columns Primary Keys Foreign Keys

  15. Four Steps to Design • Perform default database design • Resolve sub-types. • Design computed columns. • De-normalize as necessary. • Deal with those parameters

  16. Resolve sub-types • V1: One table for thesuper-type. • All attributes from all sub-types become columns. • Cannot meaningfully enforce mandatory columns. • Requires adding “type” column. • V2: One table foreach sub-type. • Attributes for super-type plus sub-type form columns for each sub-type table. • Foreign keys for each relationship linked to super-type in each sub-type table. • V3: Combinations • Most complex. • Most “true”.

  17. For example, this model . . . Inherit super-type attributes Implement Sub-types Collapse un-implemented sub-types

  18. Could be implemented, thus . . . “Department number is only required if “Organization Type Name” is “Department”.

  19. Criteria • Relative frequency of sub-type retrieval? • Who is going to do it? • Different populations? • Different timings?

  20. Four Steps to Design • Perform default database design • Resolve sub-types. • Design computed columns. • De-normalize as necessary. • Deal with those parameters

  21. Design Computed Columns . . . • Compute on input: • if values are relatively stable, or • if retrieval volume per day is significantly greater than update volume. • Maintenance is required to keep values consistent. • Compute on output: • if values are relatively dynamic, or • if retrieval volume is relatively low. • Additional maintenance is unnecessary. • Kinds of calculations: • Simple: A*B+C • Inference: INFER-THRU (<relationship>,<parent entity>, <target attribute>) • Summation: SUM-THRU (<relationship>, <child entity>, <target attribute>)

  22. For example, this model . . . /Price INFER-THRU (to buy, Product Type, Unit Price) /Value = Quantity * Price /Contract Value = SUM-THRU (composed of, Line Item, Value) /Total Sales to Date = SUM-THRU (bought via, Line Item, Value)

  23. Could be implemented thus . . . Computed on input (and stored) Computed on query* * Note that translating the formula into, for example, a stored procedure, is left to the viewer.

  24. Four Steps to Design • Perform default database design • Resolve sub-types. • Design computed columns. • De-normalize as necessary. • Deal with those parameters

  25. De-normalize (three methods) . . . • Inherit reference values. • Split tables horizontally (by instance). • Split tables vertically (by column).

  26. PARTY # GLOBAL IDENTIFIER * NAME PERSON buyer in seller in ORGANIZATION * DESCRIPTION COMPANY CONTRACT from # CONTRACT NUMBER * ISSUE DATE buyer in * (TOTAL VALUE) INTERNAL LINE ITEM ORGANIZATION part of to # LINE NUMBER * QUANTITY composed of seller in o COST GOVERNMENT * (VALUE) for GOVERNMENT AGENCY OTHER purchased via ORGANIZATION PHYSICAL ASSET SPECIFICATION # GLOBAL IDENTIFIER * DEFAULT NAME * DESCRIPTION * EFFECTIVE DATE an example o o DISCONTINUE DATE o STANDARD PRICE f * (TOTAL SALES VALUE) embodied in MATERIAL PRODUCT a sub-type of PARTY TYPE # NAME * DESCRIPTION a super-type of Inherit from reference tables . . . This model . ..

  27. CONTRACTS CONTRACT_NUMBER(PK) ISSUE_DATETOTAL_VALUE BUYER_NAMESELLER_NAME LINE_ITEM CONTRACT_NUMBER(FK) PRODUCT_NAME QUANTITY COST STANDARD_PRICE VALUE Could be implemented as . . .

  28. Note: • When replicating values, recognize the maintenance required to keep them consistent. • Note that the paradigm of INFER-THRU and SUM-THRU already anticipated this. • If these are implemented as dynamic columns, maintenance is automatic. • If they are implemented as static copies, maintenance must be added. Denormalization replicates computed fields Have you heard this before?

  29. Split Horizontally (instances) . . . • For example, • By Geographic Area • Some tables for North American customers • Some tables for European customers • Etc. • By Customer Type, etc. • Some tables for corporate customers • Some tables for individual customers • Etc. • Note the problems that will arise if a significant number of customers (for example) fall into more than one category.

  30. Split Vertically (columns) . . . • For example, • People with customer attributes • Annual sales • Sales representative • Etc. • People with employee attributes • Social security number • Employment date • Note that people with both kinds of attributes would appear redundantly in both tables.

  31. NOTE . . . • De-normalization optimizes some operations at the expense of others. • Test the effects before making them permanent. • Document the rationale for the de-normalization.

  32. Four Steps to Design • Perform default database design • Resolve sub-types. • Design computed columns. • De-normalize as necessary. • Deal with those parameters.

  33. About those parameters . . . • Some entity classes (Party, for example) invariably have a lot ofattributes. • And they change over time. • Their definitions change over time. • We need an alternative. • Define attributes as data. • Also called: • Characteristics, • Parameters, • Variables, • Etc. • Here’s an approach for Party, for example

  34. PARTY CHARACTERISTIC VALUE: “Height” of “Jerry Smith” has CHARACTERISTIC VALUE of “6.1” (feet)… according to “Jerry Smith”. PARTY CHARACTERISTIC: “Height”“Number of employees”“Regulatory target”, Etc. Party parameters as “Characteristics” . . .

  35. NOTE: theCONTINUOUS PARTY CHARACTERISTIC“Height” -- may only be used as a PARTY CHARACTERISTIC VALUE -- for a PARTY that is an example of the PARTY TYPE“Person”. Party Characteristic Constraints . . .

  36. Designing those parameters . . . • While it is a powerful way of dealing with the complexity of data … • …the Parameter Model makes common manipulations harder, however. • Convert parameters that are . . . • Relatively stable • Not multi-valued • (Over time?) • Do not convert parameters that are . . . • Multi-valued • Changeable over time and this must be reported.

  37. For example, in this model . . .

  38. PEOPLE BIRTHDATE HEIGHT COMPANIES ANNUAL SALES TAX IDENTIFICATION NUMBER PARTY CHARACTERISTIC NameDescription (Party Type) Birthdate The day the person appeared Person Height Vertical distance Person Annual Sales Average sales in a year Company Tax ID IRS tax identifier Company Can be implemented thus . . . • These Characteristics: • Could be implemented as: Bad idea!

  39. Four Steps to Design • Perform default database design • Resolve sub-types. • Design computed columns. • De-normalize as necessary. • About those parameters. • About those user views.

  40. In summary: About Those User Views . . . • The database designer need only balance data model integrity with performance issues. • The application designermust take the data as organized in a database and present it reasonably to each particular end user. • This requires skill in understanding both the database and the underlying data model.

  41. Questions . . . ?

More Related