# Stage 3: Database Tables and Business Components Implementation

You can either create database tables or business components first, and then automatically create the other based on the definitions.

## Database tables

There are two ways you can create database tables:

- With reverse generation, a database administrator creates a table for each entity in the UML diagram. The table has columns corresponding to the attributes of the entities, and has database constraints based on the relationships between the entities. The tables are used to create the initial definitions of entity objects using the business components wizards.

- With forward generation, the tables are created based on the business components definitions. The database administrator can then refine them as needed.

## Business components implementation

The business components implementation closely follows the UML diagram, so it is basically made of the following objects:

- Entity objects corresponding to the entities in the UML diagram. Each entity object has the attributes listed in the UML diagram.

- Associations link the entity objects, in a bidirectional manner, so each entity object can access other entity objects' information.

- View objects filter data from the entity objects.

- View links link the view objects, in a unidirectional manner, from master to detail.

- The view objects and view links will form the data model in one application module.

Business Components for Java provides a wizard for each business component, to help you define them quickly. You can then modify the automatically generated code as needed.

## Why use both entity objects and view objects?

Entities answer the question "What objects are relevant to the business?" (Nouns in the problem domain) Application modules answer the questoin "What tasks does the business perform?" Views answer the question "What data is relevant to the task?"Associations are relationships between entities, regardless of the tasks involved. View links help you set up hierarchical master-detail relationships so you can build the view you want. "I need to work with XS and it's related set of Y." Although they are similar to associations, you may need additional relationships that gather the data you need for a certain task.

Items have a supplier. Items below min reorder>Supplier of that item from whome we havne't order for 5 months > Ordered by the time since we've ordered from them. First, VL coordinated data sets and Filter ording calculations.

Share business logic at entity level. Saves time, improves consistency by not rebuilding logic all over the place, but in one place. Data model for task.

What is UI for task? Batch program (no user interaction),

Building UI may need to cause data model to be enhanced; Building data model for a task may need additional entities.

If you have legacy data in tables that contain information for multiple entities, the recommended thing to do is to build database views representing each entity.

Views query against tables, offering speed. But if table changes, vos break.