Individual items in the
Data Type section correspond with items in the
Data
section of the same name. If you create a new item in the
Data Type section, an item
of the same name is automatically created also in the
Data
section. The
Data
section is used to enter the
value of the item, whereas the
Data Type
section is used to specify its
type.
For example, if you select the
Integer number (
Int
)
type in the
Data Type section, the respective item in the
Data
section is represented by a
line
editor, in which you can enter a number. Similarly, if you select the
table
type in the
Data Type section, containing
First_name and
Last_name
columns of the
String (
String
)
type, the respective item in the
Data
section is a
table
with these two columns, in which you can enter a list of {
First_name,
Last_name}
pairs.
The
object name of the item and the
data
type editor are displayed in the right pane of the main window (or in a separate window
if you double-click the item). The name must be an
identifier.
When you edit the data type, the changes are immediately applied to the actual data in the
Data
section; you can observe this behavior by opening the respective
Data
section item in a separate window by a double click so that it is displayed together with the editor
of its type. If the type is incorrectly specified (e.g. two columns have the same name, etc.), the item
type in the
Data
section is not changed and an error message is displayed in the
status
line.
Sfairadora endeavors to preserve as much as possible of the already existing data in any
item whose type is being changed. This is straightforward when an item or a table column are being renamed.
When the data type is changed,
Sfairadora performs a
data
type conversion : if you change, for example, the type of a column in a table from
String
to
Integer number, then string values representing numbers are converted to numbers
and all other values are replaced by 0 (or left missing if the column is defined as
optional).
You can perform even more complicated operations that still preserve your data. For example, if you create
a new table column by coping the definition of an existing column, values in the table instance are also
copied from the original column to the new one. Furthermore, data is preserved in the following situation:
Another useful feature is the option to change the type from
computed
to basic – the computed values are thus fixed.
If you need to perform a more complex data type manipulation, it may be undesirable to have the partial
changes of type immediately applied to the actual data. In some situations you will need to change the
type by a series of changes and apply these changes to the data at the end, all at once. This is achieved
by the button with the image of a padlock
located to the right of the “
Data Type”
title. The button works as a switch – if it is in the “locked” mode, data type modifications
are not applied to the data. When you switch the button to “unlocked” again, all changes
are applied to the data. This lock locks data type and view type at once.