ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

New WEBDEV 2024 feature!
Help / WEBDEV Tutorial / Tutorial - Creating a WEBDEV project and its analysis
  • Lesson 2 - Creating files in the analysis
  • Next steps
  • Creating a data file
  • Creating a data file: using a preset data file
  • Creating a data file: creating the data file and items
  • Importing a CSV file
  • Importing existing data files directly
  • Creating the links
  • Generating the analysis
  • To sum up

Tutorial - Creating a WEBDEV project and its analysis

Lesson 2 - Creating files in the analysis
We will cover the following topics:
  • Creating a data file description
  • Creating items
  • Creating links between 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.
Lesson analysis
We are going to:
  • Create the data files of this analysis using the different methods available in WEBDEV:
    • use a preset file.
    • create a 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.
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 file available in WEBDEV:
  1. In the data model editor, go to the "Analysis" tab, "Analysis" group, and click "New file".
    Creating a file description
    The data file creation wizard opens.
  2. In the wizard, select "Select a preset data file description".
    Data file creation wizard
    Proceed to the next step of the wizard.
  3. In the list of preset data files, select "Customer". Go to the next step.
  4. The list of items to be included in the Customer data file is displayed.
    Preset data file creation wizard

    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, StateCounty, Country, Phone, Cell, Email.
  5. Finish the wizard.
The "Customer" data file is automatically created in the data model editor.
Data file created in the data model editor

Creating a data file: creating the data file and items

Now, let's create the Order file without using the wizard:
  1. On the "Analysis" tab, in the "Creation" group, click "New file". The data file creation wizard starts.
  2. In the wizard, select "Create a new data file description".
    Data file creation wizard
    Go to the next step of the wizard.
  3. Enter the name of the "Order" file in the wizard. 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 - Data file name
  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 WEBDEV.
    Each time a record is added to the data file, WEBDEV automatically assigns a value to the file identifier. This value is unique.
  5. In the next step of the wizard, you can 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 analysis. The item description window opens.
Data file item description window
We are going to create the items of the "Order" data file. In the description window of the items, you will notice that an item has already 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 caption of the item to modify it: type "Order date". In the "Type" column, the "Text" type is automatically selected. Expand the list and select the "Date" type.
    Date item description
  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: the value of the key can be multiple times in the data file.
    • Select the row of the "Date" item again to see its description on the right of the screen.
    • Specify the type of key used: Key with duplicates.
      Key characteristics
  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. Move the cursor to a new row in the table of items. Enter:
    • the name: Status
    • the caption: Order status
    • the 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.
    Link to display shared information
    The information in the window displayed will be automatically used when creating pages linked to the data file. This window displays the type of control and the caption.
    We will define the different options corresponding to the order status in the "Content" tab:
    • Click the "Content" tab.
    • Option 1 corresponds to "Pending". Type "Pending" in the Edit control to the right of number 1.
    • Type "Confirmed" in the Edit control to the right of number 2.
    • Click the "+" icon to add a new option.
    • Delete "Option 3" and type "Canceled".
      Entering the shared information
  3. Click "OK" to confirm and close the window.
It's 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.
Customer and Order data files in the data model editor

Importing a CSV file

A different method will be used to create the "PaymentMethod" data file, which contains the payment characteristics: importing a CSV file.
A CSV file is a text file that uses a specific format. This file contains data on each line. The data is separated by a separator character (usually a comma, a semi-colon or a tab).
Based on the CSV file containing the data, WEBDEV will create:
  • the description of the data file in the analysis,
  • the HFSQL data file with the data in the CSV file.
To import the CSV file into the analysis editor, follow these steps:
  1. In the ribbon, on the "Analysis" tab, in the "Creation" group, expand "Import" and select "Import file/table descriptions...".
  2. The file import wizard starts.
  3. Select the format of the data file to import. In this case, select "Text file".
    Analysis - Type of data to import
    Go to the next step of the wizard.
  4. Specify the path of the file to import: "\Tutorial\WB\Exercises\My_WEBDEV_Site\PaymentMethod.csv" located in the WEBDEV installation directory. Proceed to the next step of the wizard.
  5. Specify the following import options:
    • Records delimited by: "<Carriage return/Line feed>"
    • Columns delimited by: "<Semicolon>"
    • Strings delimited by: "<None>"
    • Decimal separator: "<Automatic: dot or comma>"
      Text file import options
  6. Don't forget to check "The first row contains the names of the columns". Go to the next step.
  7. The wizard displays the structure of the new data file. Keep the default options. Go to the next step.
    Structure of the imported data file
  8. The content of the CSV file will be automatically converted to HFSQL. By default, the wizard proposes the project directory for the new HFSQL data file.
    Data conversion
    Keep the default options and go to the next step.
  9. Finish the wizard. WEBDEV creates the data file.
Let's examine the description of the imported data file:
  1. Select the "PaymentMethod" data file, and then select "Data file description" in the context menu.
  2. Change the data file caption in the window that appears: delete "(Imported)".
  3. Click View data file items (bottom left) to open the description of the data file items.
  4. 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 characteristics
      We will get the following data:
      Items of the imported CSV file
  5. Validate the item and data file description windows.

Importing existing data files directly

Let's look at the last file creation method presented in this lesson: Importing existing HFSQL data files. We will use this method to create the "Product" data file.
The following operations must be performed:
  1. In the Windows file explorer, open the following WEBDEV subdirectory: "\Tutorial\WB\Exercises\My_WEBDEV_Site".
  2. Select the "Product.fic" file.
  3. Drag the "Product" data file and drop it onto the WEBDEV 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 from the file that has been just imported:
  1. Open the project directory: on the "Home" tab, in the "General" group, click Browse project directory.
  2. Open a new file explorer and go to the "\Tutorial\WB\Exercises\My_WEBDEV_Site" directory.
  3. Copy the "Product.fic", "Product.mmo" and "Product.ndx" files from "\Tutorial\WB\Exercises\My_WEBDEV_Site" and paste them into the EXE subdirectory of the project directory.
    Remark: Three files must be copied:
    • "Product.fic": file containing the data,
    • "Product.mmo": memo file containing the product images,
    • "Product.ndx": file containing the indices to optimize searches in the data file.
Creating the links
We have created all the necessary data file descriptions:
Data files in the analysis
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 starts.
  4. Answer the questions that appear in 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.
      Entering 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.
It's 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), Order (1, 1).
  • The link key corresponds to the "Code" item.

Now we will create a link between the "Order" and "Product" data files. This link will be used to create a link file, the data file that corresponds to the order lines.
  1. Likewise, create the link between the "Order" and "Product" data files.
  2. Answer the questions asked by the wizard:
    • Each Order has at least one Product: No
    • Each Order can have several Products: Yes
    • Each Product has at least one Order: No
    • Each Product can have several Orders: Yes
      Link between the
  3. Go to the next step. The wizard proposes to create a relation file. Keep "Create the relation file automatically" and go to the next step.
  4. The wizard proposes to use the unique key of the Order data file: "OrderID". 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 proposes the unique key of the Product data file. Select "Reference". 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 relation file is automatically created in the data model editor.
    Analysis with links
We will modify the relation file created by WEBDEV. This file will contain the order lines.
First, we will rename the relation file. We already did something similar when we changed the caption of the imported data file. However, in this case, not only the caption will be modified: we will also rename the physical file linked to the data file description.
  1. Select the "Order_Product" data file. In the context menu, select "Data file description".
  2. In the window that appears, change:
    • the name of the data file to "OrderLine".
    • the name on the disk to "OrderLine".
      Modifying the data file name
We will now modify the items of this relation file.
  1. Click View the description of the items (bottom left) to open the description of the data file items.
    Description of the data file items
  2. This data file has 3 items. Select the "OrderID_Reference" 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 "OrderID_Reference" with "OrderLineID".
    • Click the "Caption" column.
    • Replace the current caption with "OrderLine ID".
Now, we will add 3 new items to this relation 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 table row and create the "TotalIOT" item.
  3. A window appears, indicating that the item already exists in the analysis and prompts you to use its characteristics:
    Item in the analysis
  4. Keep the default options and validate ("OK").
  5. Move the cursor to a new table row and create the "TotalBT" item. Once again, use the existing description.
  6. The description of the "OrderLine" data file items is as follows.
    Description of items of OrderLine
  7. Validate the item description and the data file description (click "OK").
The analysis is as follows:
Analysis of the exercise
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.).
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, WEBDEV suggests synchronizing the structure of the deployed data to update the data files of the application (this also referred to as "data file update procedure"). This operation updates the physical data files (".fic" files) based on their description in the analysis.
  4. Click the "Start" button.
The automatic modification wizard starts.
  1. Validate the different steps of the wizard until you reach the list of data files to be taken into account:
    Automatic data file modification
    • The PaymentMethod data file must be updated. Keep this file selected.
    • The Product data file was copied into the project directory. WEBDEV prompts you to associate it with the analysis. Check the data file.
  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 files.
  • Creating a complex link.
Once the analysis has been described and generated, you can:
  • Create a full website via the RAD (Rapid Application Development) methodology.
    For more details, see Creating an application using the RAD methodology.
  • Create a full custom website. We will use this method to develop a full website based on a database in part 3 of this tutorial. This website will be based on the analysis you created in this part.
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 WEBDEV home page and click "Tutorial", then in "Tutorial - Create a WEBDEV project and its analysis", double-click "My WEBDEV site - Answers".
Previous LessonTable of contents
Minimum version required
  • Version 2024
Comments
Click [Add] to post a comment

Last update: 12/19/2023

Send a report | Local help