ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

New WINDEV 2025 feature!
Help / WINDEV Tutorial / Tutorial - Creating a WINDEV project and its analysis
  • Lesson 2 - Creating data files in the analysis
  • Next steps
  • Prerequisites
  • Creating a data file
  • Creating a data file using a preset data file
  • Creating a data file from scratch
  • Importing a CSV file
  • Importing existing data files directly
  • Creating links
  • Generating the analysis
  • To sum up
  • Further information

Tutorial - Creating a WINDEV project and its analysis

Lesson 2 - Creating data files in the analysis
We will cover the following topics:
  • Creating a data file description.
  • Creating items.
  • Creating links between data files.
  • Generating the analysis.
Durée de la leçon 40 mn
Next steps
In the previous lesson, we created the project and the associated analysis.
For this example, we will continue with the creation of the analysis. It can be used in a customer and order management application.
This analysis includes five different data files (tables):
  • Customer,
  • Order,
  • PaymentMethod,
  • OrderLine,
  • Product.
Data model editor - Lesson analysis
We are going to:
  • Create the data files of this analysis using the different methods available in WINDEV:
    • use a preset data file.
    • create a data file from scratch.
    • import a CSV file.
    • import an existing HFSQL data file.
  • Generate the analysis to use it in the various elements of the project.

Prerequisites

In this lesson, you will be provided with various files. To download these files:
  1. On the home page, click "Tutorial".
  2. In "Tutorial - Creating a WINDEV project and its analysis", click "Download elements for the exercise".
Creating a data file

Creating a data file using a preset data file

First, we will create the Customer data file. To do so, we will use a preset data file available in WINDEV:
  1. In the data model editor, on the "Analysis" tab, in the "Creation" group, click "New data file".
    The data file creation wizard opens.
  2. In the wizard, select "Select a preset data file description".
    Preset data file creation wizard
    Proceed to the next step of the wizard.
  3. The list of preset data files is displayed.
    Data file creation wizard - List of data files
    We are going to create the "Customer" data file. In the list of data files, select "Customer". Go to the next step.
  4. The wizard shows the list of items that will be included in Customer data file.
    Data file creation wizard - Items to include

    This list allows you to manage several types of Customer data files.
    We will only keep some items:
    • Click "None" to deselect all items.
    • Check the following items: CustomerID, Company, LastName, FirstName, Address, PostalCode, City, StateDep, Country, Phone, Cell, Email.
  5. Finish the wizard.
The "Customer" data file is automatically created in the data model editor.
Customer data file

Creating a data file from scratch

Now, let's create the Order data file from the beginning:
  1. In the data model editor, on the "Analysis" tab, in the "Creation" group, click "New data file". The data file creation wizard opens.
  2. In the wizard, select "Create a new data file description".
    Data file creation wizard
    Proceed to the next step of the wizard.
  3. In the wizard, enter the name of the data file: "Order". This name will be used:
    • to handle the data file in the code. The variable associated with the data file will be "Order".
    • to build the name of the associated physical data file ("Order.fic" file). The caption and description of the elements represented by the records in the data file appear automatically.
      In "A record represents", enter "An order".
      The name you enter in this field is used to generate a clear description of the links between data files. A description is automatically created based on the data file name.
      Data file creation wizard - General settings
  4. In the "Automatic identifier" section, keep "8-byte automatic identifier".
    If an automatic identifier is defined on the data file, it means that the data file includes a unique key, automatically managed by WINDEV.
    Each time a record is added to the data file, WINDEV automatically assigns a value to the data file identifier. This value is unique.
  5. Go to the next step and select the type of database associated with the data file. We are going to work on HFSQL Classic data files. Click "Finish" to confirm.
The data file is automatically created in the data model editor. The description window of the items and indexes appears.
Data file description
We are going to create the items of the "Order" data file. In the data file description window, you will notice that an item has been automatically created: "OrderID". This item corresponds to the automatic identifier of the data file. This item consists of the name of the data file and the letters "ID".
We are going to create the other items of this data file.
First, let's create the "Date" item. This item will contain the date of the order.
  1. In the item description window, double-click in the "Name" column of the first empty row. This column automatically becomes editable. Type "Date".
  2. Click the "Caption" column. The item name is automatically displayed. Click the item caption and type "Order date". In the "Type" column, the "Text" type is automatically selected. Expand the list and select the "Date" type.
    Description of items
  3. This item will be a key item (index) in the data file.
    Keys are used access and sort data faster.
    A key is part of the item characteristics. An item can be non-key, unique key, key with duplicates or primary key. For more details on the different types of key, see Key items.
  4. In this example, the "Date" item is a key with duplicates. This means the value of the key may be present several times in the data file.
    • Select the row of the "Date" item again to see its description on the right of the screen.
    • Choose "Key with duplicates".
      Description of items
  5. You can also define the default sort order of the key. In our case, the default sort order of this key will be "ascending".
We will create the "Status" item to get the order status.
  1. Position the cursor on a new table row. Enter the following values:
    • Name: Status
    • Caption: Status
    • Type: Radio Button, List Box, Combo Box. In the window that appears, you can select the type of control to be created by default for this item. In this case, select Radio Button. Validate the window.
  2. In the lower section of the screen, click the link to display the parameters of the control bound to the selected item.
    Control parameters
    The information typed in the new window that is displayed will be automatically used when creating windows linked to the data file. This window displays the type of control and the caption.
    We are going to type the following options in the "Content" tab:
    • Click the "Content" tab.
    • Click the "+" button to add the first option.
    • The option 1 corresponds to Pending. Type "Pending" in the first Edit control.
    • Click the "+" button to add the second option.
    • Type "Validated" instead of "Option 2".
    • Click the "+" button again.
    • Type "Canceled" instead of "Option 3".
      Control parameters
  3. Validate the description window of the control linked to the item.
Your turn:
Similarly:
  • Move the cursor to a new row and create the "TotalBT" item. Select the "Currency" type for this item.
  • Move the cursor to a new row and create the "TotalIOT" item. Select the "Currency" type for this item.

That's it, the description of the "Order" data file is complete. Validate the description window of items.
The "Order" data file appears in the data model editor.
To enlarge the data file in the diagram, click the data file and drag the bottom handle down.
Data files in the editor

Importing a CSV file

To create the "PaymentMethod" data file, which contains the payment characteristics, we will use a different method: we will import a CSV file.
A CSV file is a text file that uses a specific format. This file contains data on each line. Data is separated by a delimiter character (a comma, semicolon or tab).
From the CSV file containing the data, WINDEV will create:
  • the description of the data file in the analysis,
  • the HFSQL data file with the data in the CSV file.
To import a CSV file into the analysis:
  1. In the ribbon, on the "Analysis" tab, in the "Creation" group, expand "Import" and select "Import file/table descriptions...".
  2. The data file import wizard opens.
  3. Select the format of the files to import. In this case, select "Text file".
    Data file import wizard
    Proceed to the next step of the wizard.
  4. Enter the path of the file to be imported: "\Tutorial\WD\Exercises\WD My First Database\PaymentMethod.csv", located in the WINDEV installation directory.
  5. Proceed to the next step of the wizard.
  6. Specify the following import options:
    • The records are delimited by: "<Carriage Return/Line Feed>".
    • The columns are delimited by: "<Semicolon>".
    • The strings are delimited by: "<None>".
    • Decimal separator: "<Automatic: dot or comma>"
      Text file import options
  7. Don't forget to check "The first row contains the names of the columns".
  8. Go to the next step.
  9. The structure of the data file that will be created is displayed.
    Import options
    Keep the default options. Proceed to the next step of the wizard.
  10. The content of the CSV file will be automatically converted to HFSQL. The wizard suggests creating the HFSQL data file in the project directory.
    Create HFSQL data files
    Keep the default options and go to the next step.
  11. Finish the wizard. WINDEV creates the data file.
Let's examine the description of the imported data file:
  1. Select the "PaymentMethod" data file.
  2. Right-click to open the context menu and select "Data file description".
  3. In the window that appears, delete "(Imported)" from the data file caption.
  4. Click View data file items (bottom left) to open the description of the data file items.
  5. This data file does not have an automatic identifier or a unique key. We will set the "Code" item as a unique key:
    • Select the "Code" item if necessary.
    • On the right side of the screen, click "Unique key".
      Key type
  6. We get the following data:
    Description of items (PaymentMethod data file)
  7. Validate the item and data file description windows.

Importing existing data files directly

The last method for creating data files consists in importing the existing HFSQL data files. We will use this method to create the "Product" data file.

To import HFSQL data files:
  1. In Windows File Explorer, open the following WINDEV subdirectory: "Tutorial\WD\Exercises\WD My First Database".
  2. Select the "Product.fic" file.
  3. Drag the file "Product.fic" and drop it onto the WINDEV data model editor.
  4. The data file appears in the data model editor.
All necessary data files are now in the data model editor.
Warning
Only the description of the "Product" data file was imported into the analysis of our project. The data from the "Product" data file has not been imported into the project yet.
To manipulate the data in the data file you have just imported:
  1. Open the project directory. To do so, go to the "Home" tab, "General" group and click Browse project directory.
    Home tab
  2. Open a new file explorer and go to the "\Tutorial\WD\Exercises\WD My First Database" directory.
  3. Copy the "Product.fic", "Product.mmo" and "Product.ndx" files from "\Tutorial\WD\Exercises\WD My First Database" to the EXE subdirectory of your project directory.
    Note: There are 3 files to copy:
    • "Product.fic", which contains the data,
    • "Product.mmo", which contains the product images,
    • "Product.ndx", which contains the indexes to optimize searches in the data file.
Creating links
All data file descriptions required by the account management application have been created.
Data files in the data model editor
Now we will create the links between the data files.
A link is used to define the integrity constraints (cardinalities) between two data files.

First, let's create the link between the "Customer" and "Order" data files. We can consider that:
  • a customer can have one or more orders.
  • each order is linked to a customer.
To create the link:
  1. In the ribbon, on the "Analysis" tab, in the "Creation" group, click "New link". The mouse cursor turns into a pen.
  2. Click the "Customer" data file, then the "Order" data file.
  3. The link creation wizard opens.
  4. Answer the questions asked by the wizard:
    Link creation wizard
    • Each Customer has at least one Order: No
    • Each Customer can have several Orders: Yes
    • Each Order has at least one Customer: Yes
    • Each Order can have several Customers: No
      If you know the cardinalities, you can also specify the link cardinalities directly in the wizard.
      Defining the cardinalities
  5. Go to the next step. The wizard automatically shows the key used by the link (CustomerID).
    Link creation wizard
  6. Proceed to the next step of the wizard. The wizard proposes to create the "CustomerID" key in the Order data file to store the customer corresponding to the order.
    Link creation wizard
  7. Accept this option by going to the next step.
  8. This step defines the integrity rules that will be automatically applied. In our case, you can set the behavior when deleting a customer and when modifying the customer identifier.
  9. Validate the integrity rules by going to the next step of the wizard.
  10. Click "Finish". The link is automatically created in the data model editor.
Your turn:
Likewise, create a link between the "PaymentMethod" and "Order" data files. These two data files are linked as follows:
  • An order must have a payment method.
  • A payment method can be used in several orders. In the wizard:
  • The cardinalities are as follows: PaymentMethod (0, n), Orders (1, 1).
  • The link key corresponds to the "Code" item.

Now we will create a link between the "Product" and "Order" data files. This link will be used to create a junction file, which will be the data file that corresponds to the order lines.
  1. Likewise, create the link between the data files.
  2. Answer the questions asked by the wizard:
    • Each Product has at least one Order: No
    • Each Product can have several Orders: Yes
    • Each Order has at least one Product: No
    • Each Order can have several Products: Yes
      Link creation wizard
  3. Go to the next step. The wizard proposes to create a junction file. Keep "Automatically create junction file" and go to the next step.
  4. The wizard proposes the unique key of the Product data file. Select "Reference". Go to the next step.
  5. Validate the key creation by going to the next step.
  6. Keep the default options of the integrity rules and go to the next step.
  7. The wizard suggests using "OrderID", which is the unique key of the Order data file. Go to the next step.
  8. Validate the key creation by going to the next step.
  9. Keep the default options of the integrity rules and go to the next step.
  10. Click "Finish". The junction file is automatically created in the data model editor.
    Data model editor
We will modify the junction file created by WINDEV. This junction file will contain the order lines. We are going to:
  • Modify the name of the data file.
  • Modify the name of its items.
  • Add items to get the quantity of products ordered and the total of the order line.
First, we are going to rename the data file. We already did something similar when we changed the caption of the imported data file. However, in this case, we will also rename the physical file linked to the data file description.
  1. Select the "Product_Order" data file.
  2. Right-click to open the context menu and select "Data file description".
  3. In the window that appears, go to the "General" tab and change:
    • the name of the data file to "OrderLine".
    • the name on the disk to "OrderLine".
      Description of data files
We will now modify the items of this junction file.
  1. Click Description of items (at the bottom left of the file description window) to open the description of the data file items.
    Description of items
  2. This junction file has 3 items. Select the "Reference_OrderID" item. This item is a composite key.
    A composite key is a set of items that constitute an index.
    This type of key is used to loop through the data file based on complex criteria or to perform specific searches on several items at the same time.
  3. To rename this item:
    • Click the "Name" column.
    • Replace "Reference_OrderID" by "OrderLineID".
    • Click the "Caption" column.
    • Replace the current caption with "OrderLine ID".
Now, we will add 3 new items to this junction file: Quantity, TotalIOT and TotalBT.
  1. Move the cursor to a new row and create the "Quantity" item. Select the "Numeric" type for this item.
  2. Move the cursor to a new row and create the "TotalBT" item.
  3. A window indicates that the item already exists in the analysis and offers you to reuse its characteristics:
    Creating an item
    Keep the default options and validate ("OK").
  4. Move the cursor to a new row and create the "TotalIOT" item. Once again, use the existing description.
  5. The description of the "OrderLine" data file items is as follows.
    Description of items
  6. Validate the item description and the data file description (click "OK").
The analysis is as follows:
Data model editor
Generating the analysis
The generation of the analysis consists in validating the changes made to the analysis (create data files, add or delete items, etc.) and applying them to the entire project (pages, bound controls, reports, etc.). The project will thus "know" all the data files, items and links defined in the analysis. It will be very easy to handle these elements in the different editors of WINDEV.
If changes have been made to the analysis, a synchronization dialog box appears automatically when the data model editor is closed.
You can also generate the analysis manually. That's what we are going to do.
To generate the analysis:
  1. In the ribbon of the data model editor, go to the "Analysis" tab, "Analysis" group and click "Generation".
  2. The analysis generation starts automatically.
  3. Since we modified the description of the data files in the analysis, WINDEV automatically starts the data file update procedure. This operation updates the physical data files (".fic" files) based on their description in the analysis.
The automatic modification wizard opens.
  1. Validate the different steps until you reach the screen that lists the data files to take into account.
    • WINDEV detects that the PaymentMethod data file must be updated. Keep this data file selected.
    • WINDEV detects that the Product data file is out of sync. Select this data file.
      Automatic data modification
  2. Go to the next step.
  3. The wizard proposes to make a back up copy of the existing data files, don't change anything and go to the next step.
  4. The wizard allows you to define a password to protect the data files that were modified during the automatic modification. Keep the default options and go to the next step.
  5. The list of data files to modify is displayed. Finish the wizard.
The data files are updated.
Close the data model editor.
To sum up
We have covered the main steps to create an analysis:
  • Creating a data file using different methods.
  • Creating simple links between data files.
  • Creating a complex link.
Completed project
If you want to check the end result of the steps described here, you can open a completed version of the project. This project illustrates the expected end result.
To open the completed project, go to the WINDEV home page and click "Tutorial", then in "Tutorial - Create a WINDEV project and its analysis", click "Open completed project".
Further information
Once your analysis has been defined and generated, you can:
Previous LessonTable of contents
Minimum version required
  • Version 2025
Comments
Click [Add] to post a comment

Last update: 01/20/2025

Send a report | Local help