# 1 Information

There are two types of relationship between SQL-Tables: Subtable and Related Box.

## 1.1 Subtable

In the subtables, two Sql-Tables are defined, one of them being subtable of the other.

Only one box is displayed in the form, but the content consists of the two defined SQL-Tables. For each record of the Sql-Table parent, the content of the Sql-Table defined as a subtable is represented.

#### In this example, an object is created with two SQL-Tables, the content of which shows the albums and their songs. The main SQL-Table contains the set of system albums and the second Sql-Table contains the songs of each album.

Object with the set of system albums.

Sql-Tables in the form. Two boxes of type SQL-Table.

Access Layout/SQL table tab by means of the Box settings option of Celldata box.

Parameterization of the main SQL-Table with the set of system albums.

Sentence used:

Copy
<select>
<columns>
album.albumid,
album.title
</columns>
<from table='album' />
<where>
\$0
</where>
</select>

Access Layout/SQL table/SQL table output tab. Output fields:

Parameterization of the secondary SQL-Table with the set of songs of each album. It is noted that the parameter 'Relationship' is in 'Subtable' mode and the parent identifier is the box with the main SQL-Table.

Sentence used:

Copy
<select>
<columns>
track.trackid,  track.name,
track.composer, track.milliseconds,
track.bytes,    track.unitprice,
track.costprice
</columns>
<from table='track' />
<where>
track.albumid IN (#albumid)
</where>
</select>

#### It is noted that the statement contains in the filter '#albumid' the value of it comes from the SQL statement of the main SQL-Table.

Output fields:

Result (Subtable):

## 1.2 Related box

In the related boxes, 2 Sql-Tables are defined, one of them being a related box of the other.

Two boxes are displayed in the form. The first contains a selector and the second box shows content when a record of the main one is selected.

#### The previous object is modified to show the related boxes.

Parameterization of the main SQL-Table with the set of system albums. The selection field is modified with the value 'Single row'.

Parameterization of the secondary SQL-Table with the set of songs of each album. Note that the parameter 'Relationship' is in 'Related Box' mode and the parent identifier is the box with the main SQL-Table.

Result (Related boxes):