macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Applying "Digital Hub" Concepts to Enterprise Software Design, Part 2
Pages: 1, 2, 3

Creating ID Attributes (representing database columns):
  1. Highlight the DataType entity in the left frame of EOModeler by clicking it.
  2. Choose Add Attribute from the Property menu. Your new attribute should show up in the main window and in the Inspector. If you have closed the Inspector, please open it again before proceeding.
  3. With your new attribute selected, set the name field to dataTypeId and the column field to DATA_TYPE_ID. Set the external type to long and the Internal Data Type to Integer.
  4. In the main frame of the window, make sure that the key icon is showing next to your ID attribute and that the diamond icon is not showing. You can click the space next to the attribute to toggle this setting. See the screenshot below to make sure that you have it right.
  1. Create an ID column for the other two tables. The external and internal types are the same. Follow the same convention for the names, too: use measuredDataId and measurementTypeId for the names. Use MEASURED_DATA_ID and MEASUREMENT_TYPE_ID for the columns. In each case, make sure the key icon is showing and the diamond icon is not.
  2. Save your work.
Creating Attributes to store data:
  1. Highlight the DataType entity in the left frame of EOModeler by clicking it.
  2. Choose Add Attribute from the Property menu.
  3. Set the name of the new attribute to name and the column to NAME.
  4. Set the external type to char and the internal data type to String. When you select String as an internal type, a field will appear that allows you to set an external width. Type 255 in this field.
  1. For this attribute, make sure that the key icon is not selected and the diamond is selected. Note: This should be the default and is the opposite of the ID columns.
  2. Add a name attribute to the MeasurementType entity that is identical to the one you just created. In fact, you can use copy and paste to create it, if you want. To do this, select the attribute in the main window and choose copy. Then, select the MeasurementType entity and choose paste.
  3. We're going to create two new attributes for the MeasuredData entity. The first one is to store a timestamp for each new piece of data that is entered. Create a new attribute, set its name to timeTaken, the column to TIME_TAKEN, the external type to datetime, and the internal type to Date.
  4. Next, add an attribute to the MeasuredData entity to store the actual measured data. Since we do not know the type of the data for each row in the database ahead of time, we will set the data column to store a large string. Most other data types can be converted to a string. Set the name of the new attribute to data, the table name to DATA, the external type to char, and the internal data type to String, with an external width of 1024
  5. Double-check that every attribute except the ones storing ID numbers have the diamond visible and do not have a key icon. The measured data table will look like this:
Configuring Relationships
  1. Copy the dataTypeId attribute from the DataType entity and paste it into the MeasurementType entity. This will allow the measurement type to store a link to each row's data type. Set the attribute so that neither the key or diamond icons are showing (because it is not a primary key, and because this attribute will not normally visible to users).
  2. Select the dataTypeId that you just pasted into the MeasurementType entity. In the Inspector, view the Advanced Options for this attribute by clicking the second icon in the toolbar of the Inspector. There should be a checkbox to set whether or not to allow null. Make sure that it is checked so that null values will be allowed.
  1. Copy the measurementTypeId attribute from the MeasurementType entity and paste it into the MeasuredData table. This allows the measured data to store a link to its respective measurement type. Set the attribute so that neither the key or diamond icons are showing.
  2. Set the newly pasted attribute to allow a null value (see step 2).
  3. Select the MeasurementType table and choose Add Relationship from the Property menu.
  4. Using the Inspector, name the relationship dataType. Select the DataType table in the Entity selector. Then make sure that To One is selected, since there will be one data type for each measurement type. Finally select "dataTypeId" in both of the Join selectors and click connect. This is what it should look like:
  1. Select the MeasuredData table and choose "Add Relationship" from the Property menu.
  2. Using the Inspector, name the relationship measurementType. Select the MeasurementType table in the Entity selector. Make sure that To One is selected, and then select measurementTypeId in both of the Join selectors and click connect.
  3. Save your EOModel.

Your database schema is complete. To view it in a nice graphical form, use the icon on the far left of the toolbar to toggle to the table view. Your model should look something like this:

Create the Database

Once our EOModel has been created, it's no problem to create database tables that match the design. EOModeler can create the SQL code for you, and will even apply it to your database using the adaptor information that you specified earlier.

  1. Select the Weather entity from the left frame of EOModeler.
  2. Generate SQL in the Property menu.
  3. EOModeler will create all the SQL code necessary to set up your database.
  4. Uncheck Drop Tables and Drop Primary Key Support, since there is nothing in the database to drop.
  1. Click Execute SQL to apply the changes to the database.
  2. If you click the Tables... button and get a list of your three tables, then everything is good to go. If you get an error message, double-check all the model settings. For me, I often seem to forget to assign table names to attributes, so you might want to check that.
  3. When the tables have been created, save your work and quit EOModeler.

Pages: 1, 2, 3

Next Pagearrow