The ORM Foundation

Get the facts!

Merging Entity Types in ORM Lite - A Quick and Painless Process

Last post 06-30-2012 14:39 by BrianC. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 06-08-2012 21:26

    Merging Entity Types in ORM Lite - A Quick and Painless Process

    In this series of posts I will explain some important features of ORM Lite that help save time and effort in modeling projects. While wondering where to begin, I read with interest Tyler Young's account of his current ORM modeling project. He gave a good example of a common challenge for large re-engineering projects. So let's start with the problem of merging entity types. I'll skip the earlier steps of importing the tables from the existing database, converting them to fact types, and loading profile data into the ORM tool, and move right in to consolidating entity types themselves.

    Here are the steps:

    1. Open the ORM Object Type report. This report shows a table view that lists the Name, RefMode, and Data Type of all of the Object types in the model. Elapsed time: 1 second.
    2. Filter the report to only show the entity types of interest. This is done by selecting the Name column, clicking the filter button, and typing a string that all of the targeted entity type names will contain, for example: "date". Elapsed time: 2 seconds.
    3. Click on each entity type row to verify that it should be merged. Clicking on the row will update the content of the ORM Lite verbalizer window which shows the original column's data type, column name, database label, and the column's data profile (that shows the number of distinct values in the column, the most commonly occurring values, and the max/min values) and other documentation on that column that has been loaded into the model. Elapsed time: Less that 1 second each to display the information, but you may want to take a little more time to verify that the entity type should be merged.
    4. If the entity type is one that should be merged, directly copy and paste its new Name, RefMode, and Data Type into the report. This will create entity types with duplicate names. ORM LIte allows duplicate names based on the idea that it should be legal to temporarily to create an invalid model as long as that condition is later corrected. Elapsed time: less that 1 second each.
    5. After updating the Names, RefModes, and Data Types for all of the columns to be merged, click on one of the target entity type rows and then click on a "diagram link" in the References window. The link will open the diagram on one of the merge candidates. Elapsed time: 2 seconds.
    6. Make sure the diagram is the active window and click the "Combine Dup OT" button to merge the duplicate object types. ORM Lite look for any other entity types that have the exact same Name and RefMode. It will report the number of duplicates found and ask permission to complete the merge.Click OK. Elapsed time: 4 or 5 seconds.

    And you are done.

    Total time to merge 100 entity types: less than two minutes.

  • 06-30-2012 14:39 In reply to

    Re: Merging Entity Types in ORM Lite - A Quick and Painless Process

    Merging 100 entity types in less than two minutes?! What features of ORM Lite make this efficiency possible? Let's take a closer look at these six steps and find out. Even if you haven't tried ORM Lite you will find this interesting. Read on!

    1. Direct editing in table views of model objects. Entity types can be directly edited in a table view. This view was initially created to make it easy to do mass updates to data types, but simplifies changing names and reference modes, too. Much time is save because you don't have to open and edit each entity type one at a time.
    2. Column filtering of table views. Filters make it easy to find the five model objects you need out of the thousands in the model. At its simplest the filter can be just a text string, but it is also possible to invert the filter by typing a hyphen as the first character. For power users the filter can be a complex regular expression.
    3. Enhanced verbalizer. While it can be useful to translate ORM constraints into sentences (especially for new users), it is more important to pull together into one compact display connected data from multiple parts of the model. For example, when clicking on an entity type, ORM Lite will display the different data types of the connected source system table columns, the long Entity description, modeler notes, and all of the fact types the entity takes a role in. When clicking on a fact type, it will show the fact type derivation rule and a source column data profile including the most commonly occurring data values.
    4. Flexibility with some of the rules. ORM LIte will allow entity types with duplicate names and fact types without readings. In my current modeling project I found that I created hundreds of fact types through the import process that I then wanted to ignore. I was able to set the "Omit from Mapping" flag and leave them in their invalid condition. I don't want to delete them because they may eventually turn out to be important, but I don't want to spend the time making them follow the rules.
    5. The References window. The cross-reference windows is updated every time you click on any model object. It provides a link to directly navigate to every other report or diagram where that object appears and to everything the object points toward. This makes complex navigation through the model relatively easy and quick. It is a good example of a zero-clicks feature (a feature that does not require any action on the users part to get a significant benefit).
    6. I initially added the "Combine Dup OT" button when I observed that one of the most common errors that new ORM students made was to create a duplicate of an object when they really should have created another reference to an already existing object. At that time I didn't realize how critical it would be for large re-engineering projects.

    In the next post, we'll look at some other powerful features of ORM Lite. Let me know if you have any specific requests.

    The purpose of this post (and of the ORM Lite project) is to further an ongoing discussion about how we can improve the user interface for all ORM tools. I hope that ORM tool users will raise their standards and expectations and that ORM tool developers will carefully consider these ideas.

    Your comments are welcome.

Page 1 of 1 (2 items)
© 2008-2014 The ORM Foundation: A UK not-for-profit organisation -------------- Terms of Service