Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

10.12 Managing Table Links

There are a couple of buttons that are helpful for managing links. The Auto-Arrange button rearranges the tables on the screen into an easier-to-read layout. This is useful when handling a report with many tables. A multitude of tables makes it difficult to visualize the relationship with one another and the overall structure. If the Auto-Arrange button doesn’t help, you can reposition the tables yourself by dragging them around within the window.

The Auto-Link button rebuilds the links based on whether you want to link by field name or by index. This comes in handy for undoing any new links you added, should you want to start from scratch. The Clear Links button removes all the links between the tables so you can start with a blank slate do it yourself.

A primary way of improving report performance is to link on fields that have an index associated with them. Creating an index on a field tells the database server to build internal sorting tables so that the data can be read much faster. If an index isn’t created for a field, then the database has to search through every record in the table to find the data. This is very inefficient. Crystal Reports tells you which fields have indexes by using the triangular icon to the left of the field name. When you see this icon, you know that the database table has been optimized for searching on these fields and your reports will run faster if you link on them. Each icon is colored so that you can see where the index is in the hierarchy of all the indexes in the table. By clicking on the Index Legend button, you see the dialog box in Figure 10-9 and see how the color schemes are laid out.



Figure 10-9. Index Legend color schemes.

Another button on the Links tab is the Link Options button. It lets you modify how the two tables are linked together. You make the changes in the Link Options dialog box, shown in Figure 12 -10.



Figure 10-10. The Link Options dialog box.

The Link Options dialog box establishes the type of relationship between the two fields. It sets the type of join (Inner, Left Outer, Right Outer, or Full Outer) as well as how the fields are compared (equal to each other, less than, etc.). By default, fields are joined together when they are equal to each other. But you can modify this to give you greater flexibility with your report. You can link tables if one field is less than the other (<), greater than the other (>), or even when the fields are not equal to each other (!=). The link type options on the right side of the dialog box let you make this type of modification.