Enhancing your model then syncing it up with the physical model
At some point in time you may have to enhance your logical model and then move the changes to your physical model. You can do this by simply adding a new logical entity to the logical model and then comparing the model with the physical model. Say you want to change your Bookstore example to be a Library now. In order to do this, you need a new Library entity but want to keep all of the other existing entities. In other words, the new logical model will have Library, Book, Author and BookCategory as the logical entities.
Here are the steps:
- Add a Library Entity with two TimeStamp fields — DateCheckedOut and DateDue — to the logical model using the steps described in the previous section.
- After that, create a relationship between Library and Book using BookID. As a reminder, highlight the Book entity, and after you see two boxes, drag it from the Book entity to the Library entity.
- Transform from a logical to a physical model as described in Step 6 of the previous section. In this instance, however, choose Update Existing Model and click on Browse to pick up the storesLogicalModel.dbm file.
- Once that is done, you will see a compare screen like the one
shown in Figure 31, below, showing you what
the differences are between the two models. From this screen, you
can specify what you would like to do with the differences (copy
the change or ignore the change). For example, to merge changes
from the physical model to the database you can:
- Highlight the Library entry.
- Use the toolbar (shown circled in Figure 31) to copy over the LIBRARY change from the logical to the physical model.
- Click on the Generate DDL button (which is circled in Figure 31) to generate the necessary DDL for the delta change.
Figure 31. Syncing up logical with physical models
- Once the changes are done, you can go to the physical model and change the column types. Because the TIMESTAMP type gets transformed to a CHAR(10) type (this is the default, and can be changed using the preferences option described below), you can change it to an Informix-specific DATETIME YEAR TO SECOND data type for both the DateCheckedOut and DateDue columns. You can also do this when the transform is taking place as well when the changes are copied over from the logical to the physical model.