Tables & DataSets
Introduction
In this article, we'll cover using tables in Data² and how to create and manipulate persistent data. We'll explore the importance of standardized naming and how to relate tables through lookup fields. We'll also see how to filter and display data efficiently.
Creating tables and fields
When creating a table in Data², it's essential to use clear, standardized naming. This ensures everyone on the team can understand the table's content. It's recommended to use entity names, such as "contacts," "opportunities," or "customers."
Within a table, you need to create columns to store the data. Each column will have a name and an associated data type. Some common types are: text, number, boolean, date, file, password, formula, and lookup. It's important to choose the correct type for each column, taking into account the nature of the data to be stored.
Data persistence
In Data², you can create persistent data — that is, data that remains even after turning off the computer or refreshing the page. This is useful when you want to store information that needs to be accessed later.
To interact with the data in a table, you need to create a DataSet. The DataSet is a representation of the table's data that allows you to view and manipulate records. It's through the DataSet that we can add, edit, and delete records.
Relating tables
Tables are often related to each other. For example, in a contacts table, it's useful to have a field indicating the group the contact belongs to. For this, we use lookup fields that reference records from another table.
We can also filter a table's data based on the value from another table. This is especially useful when we want to display only the contacts that belong to a certain group. This filtering is done through a field called "master," which relates the current DataSet to the DataSet of another table.
Manipulating data
When working with data in a table, you can perform basic operations such as inserting, editing, and deleting records. These operations are performed through interactions with the DataSet.
You can also display data in a table or in an edit form using the appropriate Data² components. The DataGridBlock is used to display data in a table, while the DataFieldBlock is used to display data in edit forms. You can customize how data is displayed and edited using these components.
Conclusion
Tables and DataSets are fundamental resources in Data² for storing and manipulating persistent data. With the techniques presented in this article, you'll be able to create and relate tables, filter data, and interact with records. Always remember to use standardized naming and to test your implementations to ensure data integrity.