Create a Table

Now that we have the connection from our application to the database in place, it is time that we build a table. The name of the table that we want is "Device" and the fields that we want in that table are as follows:

Table 4. Table "Device"

Field NameData TypeLength
deviceNumberUnsigned Decimal5
descriptionString35
typeIdString3
dateInstallDate (format CCYY-MM-DD)10

The primary key will be deviceNumber

There are 4 easy steps involved in creating a table in ProLinga:

  1. Check if data dictionaries are available and if not create them.
  2. Group data dictionaries together in a Record.
  3. Group data dictionaries together in an Index.
  4. Create a Table definition and assign the Record(s) and Index(es) to it.

From this point on we should not be using the terminology "Field Name" any more when refering to table definitions in ProLinga. Instead, ProLinga uses the concept of Data Dictionaries. A Data Dictionary is a very powerful reusable object. Think of 2 tables for instance that both have a field called "description". In traditional database environments, you have to create this field 2 times. Besides more work, also there is a chance that 1 field has a length of 15 and the other of 35 and that data can get lost when assigning one to another. In the case of ProLinga, we will use the same Data Dictionary for both tables, eliminating the possibility of incompatibility.

To create the Data Dictionaries, open your application in the ProLinga Developer and select "Data Dictionary" from the Object Palette.

Figure 56. Data Dictionary On Object Palette

Screenshot of the data dictionary button on the object palette.

Press the button "New" on toolbar of the Data Dictionary editor to make sure you start with a new object. We first will create the Data Dictionary "deviceNumber". Set the "Maximum Length" to 5, "Data Type" to UnsignedDecimal, "External Storage Type" to Integer and "Justification" to Right. Leave all other fields default as they are. Save the Data Dictionary and name it "deviceNumber".

Figure 57. Data Dictionary deviceNumber

Screenshot of the data dictionary "deviceNumber".

Some details of key fields. The "Data Type" is the type of the data within ProLinga, while "External Storage Type" is the type of the data in the database. Most of the time they will be of a similar type, meaning that a String translates to the type Character and Unsigned Decimal to Integer, but there maybe situations that this is not the case.

The same way, create the Data Dictionaries "description", "typeId" and "dateInstall".

Figure 58. Data Dictionary description

Screenshot of the data dictionary "description".

Figure 59. Data Dictionary typeId

Screenshot of the data dictionary "typeId".

Figure 60. Data Dictionary dateInstall

Screenshot of the data dictionary "dateInstall".

Once we created all the Data Dictionaries that we need for our table "Device", we can group them together in a Record. Open the Record editor from the Object Palette.

Figure 61. Record On Object Palette

Screenshot of the record button on the object palette.

Type in the name "deviceNumber" in the screen field "Data Dictionary Name" and press the "Add" button. You will see that the name now shows up in the list. Add the same the Data Dictionaries "description", "typeId" and "dateInstall". Instead of typing them in, you can also select them from the list when pressing the button "Find". The order from top to bottom will be the order of the fields in the database from left to right. It is important to get this right. When finished, save the Record with the name "Device".

Figure 62. Record Device

Screenshot of the record "Device".

On a similar way, we can create an index. Open the Index editor from the Object Palette.

Figure 63. Index On Object Palette

Screenshot of the index button on the object palette.

Click on the tab "Entries" and add the Data Dictionary Name "deviceNumber". Save the index with the name "deviceNumber."

Figure 64. Index deviceNumber

Screenshot of the index "deviceNumber".

Finally, we create the Table itself. Open the Table editor from the Object Palette.

Figure 65. Table On Object Palette

Screenshot of the table button on the object palette.

Add the Record to the Table definition by typing the name of the Record "Device" in the field "Record Name" under the "Record" tab and press the "Add" button.

Figure 66. Add Record to Table

Screenshot of adding Record to Table definition.

Press on the tab "Index" and add the Index called "deviceNumber".

Figure 67. Add Index to Table

Screenshot of adding Index to Table definition.

Click on the tab "Provider". The "External Name" will be used for the physical file name in the database. So enter "Device" here. As "Data Interface Type" choose GDA and the Data Source is the one we created earlier with the name "netadm".

Figure 68. Add Provider details to Table

Screenshot of adding Provider details to Table definition.

Now save the table and give it the name "Device". Now click on the tab "Data Manager" and click the button "Build Database Table". If you receive no error messages, all went OK and your table is now created in the database. To double check this, open an interactive terminal for your database and check if the new table is present.

Figure 69. Check Table in Database

Screenshot of Table definition in the database.

As you can see, all the fields are available as well as the index. At this stage, we can not test this yet in our application, as we do not have any data entry screen. Please proceed to the next chapter to build one.