PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
New WINDEV 24 feature!
  • This lesson will teach you the following concepts
  • Overview
  • Creating the project
  • Creating the analysis
  • Creating the description of data files
  • Creating a data file: using a preset data file
  • Creating a data file: creating the data file and items
  • Importing a CSV file
  • Direct import of existing data files
  • Creating links
  • Generating the analysis
Lesson 3.3. Project and analysis
This lesson will teach you the following concepts
  • Creating a project.
  • Creating an analysis.

Estimated time: 40 mn
Previous LessonTable of contentsNext Lesson
Overview
To create an application with database, you must:
  • Create the project linked to the application. This project will group all application elements (windows, codes, queries, reports, ...).
  • Create the analysis linked to the project. The analysis is used to describe all data files handled by the application.

Note

This lesson is used to create an application with HFSQL database. As already seen in the previous lesson, WINDEV allows you to create applications that handle other databases.
The "Appendix 2: Using SQL data" lesson presents the operations that must be performed to create a project and an analysis based on an SQL database (via OLE DB or via Native Connector).
Creating the project
  • To create the project:
    1. Start WINDEV (if not already done).
    2. Display the WINDEV home page if necessary (Ctrl + <).
    3. In the home page, click "Create a project" and select "Windows or Linux application". The wizard for project creation starts. The different wizard steps help you create your project. The information specified in this wizard can be modified later.

      Tip

      To create a project, you can also:
      1. Click on New among the quick access buttons.
      2. The window for creating a new element is displayed: click "Project".
    4. The first wizard screen is used to type the project name, location and description. In our case, this project will be named "WD My First Database". WINDEV proposes to create this project in the "\My projects\WD My First Database" directory. You can keep this location or modify it via the [...] button. For the project summary, type "The purpose of project is to manage the customers and their orders".
      Project creation
    5. The different wizard steps are specified on the left of wizard. These steps can be clicked directly. Since the other steps in the "Description" are not essential, you can click "Charters" directly.. The different wizard steps are specified on the left of wizard. These steps can be clicked directly. Since the other steps in the "Description" are not strictly necessary, you can click "Guidelines" directly.
    6. This step is used to define the programming charter. Don't modify the suggested options. Go to the next step via the arrows found at the bottom. This step is used to define the code style. Don't modify the suggested options. Go to the next step via the arrows found at the bottom.
    7. This step is used to define the style book. Select "Gensteel".
      Go to the next step via the arrows found at the bottom.
    8. Click the "Database" step. We are now going to specify the information regarding the database.
    9. Select "Yes, create a new database" and validate. The wizard for analysis creation starts.

Note

To better understand the lessons found in this section and to optimize your training, we advise you to create the "WD My First Database" project.
A corrected example can be accessed at any time to check the validity of operations performed.
To open this corrected project, in the WINDEV home page (Ctrl + <), click "Tutorial" and select "My first database (Answer)".
Creating the analysis
  • The wizard steps for creating the analysis are as follows:
    1. Specify the analysis name and directory. By default, the analysis name corresponds to the project name and the analysis directory is a ".ana" directory in the project directory. We will keep these default parameters. Go to the next wizard step.
      Creating the analysis
    2. You now have the ability to choose the types of databases used by the project. Select HFSQL Classic (the database proposed by default with WINDEV).
      Choosing the database
      Go to the next wizard step.
    3. Validate. The wizard for creating a data file is automatically started.
Creating the description of data files
Our application for managing customers and orders will be associated with the following analysis. This analysis includes five different data files (tables):
  • Customer,
  • Orders,
  • PaymentMode,
  • OrderLine,
  • Product.
Data model editor
To create the data files of this analysis, we will be using the different methods proposed by WINDEV.

Creating a data file: using a preset data file

  • The wizard steps for creating a data file are as follows:
    1. In the wizard, select "Select a description among the preset data files". Go to the next wizard step (arrow at the bottom of wizard).
      Creating a data file
    2. The list of preset data files is displayed. We are going to create the "Customer" data file. In the list of data files, select "Customer". Go to the next step.
    3. The wizard proposes the list of items that will be included in Customer data file. This list is very impressive because it allows you to manage several types of Customer data files.
      Creating a data file
    4. Check the following items: CustomerID, Company, LastName, FirstName, Address, ZipCode, City, StateDep, Country, Phone, Cell, Email.
    5. Validate the wizard.
    6. The "Customer" data file is automatically created in the data model editor.
      Data file in the editor
    7. The window for creating a new element is displayed. We are now going to create the data file containing the orders.

Creating a data file: creating the data file and items

  • To create a data file from the window for creating a new element:
    1. Click "Data" then "Data file".

      Note

      You also have the ability to create a data file from the data model editor: on the "Analysis" pane, in the "Creation" group, click "New file".
    2. The wizard for creating a new data file starts.
    3. In the wizard, select "Create a new description of data file".
      Creating a data file
    4. Go to the next wizard step.
    5. We are going to create the "Orders" data file. Type its name ("Orders") in the wizard. This name will be used:
      • to handle the data file by programming. The variable associated with the data file will be "Orders".
      • to build the name of associated physical data file ("Orders.fic" file). The caption and description of elements represented by the file records are automatically displayed.

        Note

        In the wizard, the control "A record represents" is used to get an understandable caption during the description of links between data files. A caption is automatically proposed from the data file name.
        In our case, type "An order".
        General parameters
    6. In the "Automatic identifier" area, keep "Automatic identifier on 8 bytes". If an automatic identifier is defined on the data file, it means that the data file includes a unique key, automatically managed by WINDEV.

      Note

      To create the identifier (an identifier is a unique key), you have the ability to create a numeric item whose type is "Automatic identifier".
      This identifier is automatically managed by WINDEV. Whenever a record is added to the data file, WINDEV automatically assigns a value to the data file identifier. This value is unique.
    7. 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. Go to the next step.
    8. Click the green button to validate. The data file is automatically created in the analysis. The description window of items and indexes opens up.
      Description of a data file
We are going to create the items of the "Orders" data file. In the description window of data file, you will notice that an item was automatically created: "OrdersID". This item corresponds to the automatic file identifier. This item consists of the letters "ID" and the name of the data file.
We are going to create the other items of this data file.
  • First, we are going to create the "Date" item. This item will contain the order date.
    1. In the description window of items, double-click in the "Name" column of first empty row. This column automatically becomes editable. Type "Date".
    2. Click the "Caption" column. The item name is automatically displayed. We are going to modify the item caption by clicking on it: type "Order date". In the "Type" column, the "Text" type is automatically selected. Expand the list and select the "Date" type.
      Describing items
    3. This item will be a key item (index) in our data file: the keys are used to accelerate the accesses to data and the sorts.
      • For a database in SQL format, the engine is using the indexes at the best.
      • For a sequential browse of a data file, all you have to do is specify the browse index (which means the key).

        Note

        The concept of key is part of the item characteristics. When creating an item, you have the ability to specify whether it is:
        • not key,
        • unique key: the value of this key will be unique in the entire data file (i.e. in all the data file records).
        • key with duplicates: the value of this key can be found several times in the data file.
    4. The key definition is performed as follows: re-select the line of "Date" item to enable the description controls found on the right of screen. Then, all you have to do is specify the type of key used. In our case, the date is a key with duplicates.
      Describing items
    5. You must also define the search direction of the key. The search direction is used to define the default sort for this item. In our case, when a browse is performed on this key, the default sort order will be "ascending".
  • We are now going to create the "Status" item that is used to find out the order status.
    1. Position on a new table row. Enter:
      • the name: Status
      • the caption: Order status
      • the type: Radio Button, List Box, Combo Box. In the window that is opened, you have the ability to select the type of control created by default for this item. It will be a radio button in this case. Validate the window.
    2. In the lower section of the screen, click the link to display the parameters of the control linked 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. You will find here the control type 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 edit control found on the right.
      • 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.
    4. Similarly:
      • Position on a new table row and create the "TotalBT" item. This item is a "Currency" item.
      • Position on a new table row and create the "TotalIOT" item. This item is a "Currency" item.
    5. That's it, the description of "Orders" data file is complete. Validate the description window of items.
    6. The "Orders" data file appears in the data model editor. It is possible to enlarge the displayed data file. Simply click on the data file, select the black handle at the bottom of the data file and move the mouse down.
      Data files in the editor

Importing a CSV file

A different method will be used to create the "PaymentMode" data file, which contains the payment characteristics: importing a CSV file.

Note

A CSV file is a text file that is using a specific format. This file contains data on each line. The data is separated by a separation character (a comma, a semi-colon or a tabulation).
From the CSV file containing the data, WINDEV will create:
  • the description of data file in the analysis,
  • the HFSQL data file with the data found in the CSV file.
  • To import a CSV file into the analysis:
    1. On the "Analysis" pane, in the "Creation" group, expand "Import" and select "Import the descriptions of files/tables".

      Tip

      To import a CSV file (or any other file) into the analysis, you also have the ability to Drag and Drop the CSV file (from the Windows explorer) to the data model editor. This will be presented in the next paragraph.
    2. The wizard for importing files starts.
    3. Go to the next step.
    4. Select the format of files to import. In this case, select "Text file".
      Importing data
      Go to the next wizard step.
    5. Specify the path of file to import: "\Tutorial\WD\Exercises\WD My First Database\PaymentMode.csv" in the WINDEV setup directory.
    6. Go to the next wizard step.
    7. Specify the following import parameters:
      • Records delimited by: "<Carriage Return/Line Feed>".
      • Columns delimited by: "<Semicolon>".
      • Strings delimited by: "<None>".
      • Decimal separator: "<Automatic: dot or comma>"
        Import parameters
    8. Don't forget to check "The first row contains the names of columns".
    9. Go to the next step.
    10. The structure of data file that will be created is displayed. Keep the default options.
      Import options
      Go to the next step of the wizard.
    11. The content of CSV file will be automatically converted to HFSQL format. The wizard offers you to create the HFSQL file in the project directory.
      Creating the HFSQL files
      Keep the proposed options and go to the next step.
    12. Validate the wizard. WINDEV creates the data file.
  • Let's study the description of imported data file:
    1. Select the "PaymentMode" data file.
    2. In the popup menu (right mouse click), select "Description of data file".
    3. Change the data file caption in the window that opens up: delete "(Imported)".
    4. Click the Describing items icon to display the description of the data file items.
    5. This data file contains no automatic identifier and no unique key. We are going to switch the "Code" item to unique key:
      • Position the selection bar on the code item if necessary.
      • In the right section of screen, click "Unique key".
        Managing keys
    6. We get the following data:
      Describing items
    7. Validate the item description window and the data file description window.

Direct import of existing data files

The last method for creating data files consists in importing the existing HFSQL data files. This method will be used to create the "Product" data file.
  • To import HFSQL data files:
    1. In the 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 in the WINDEV data model editor.
    4. The import wizard starts. Validate the different steps. The data file appears in the data model editor.
All necessary data files are now found in the data model editor.

Caution!

Only the description of the "Product" data file was imported into the analysis of our project. The data found in the "Product" data file was not imported into the project.
  • To handle the data found in the file that was just imported:
    1. Open the file explorer on the directory of your project: on the "Home" pane, in the "General" group, click Project directory.
    2. Open a new file explorer on the "\Tutorial\WD\Exercises\WD My First Database" directory.
    3. Copy the the files "Product.fic", "Product.mmo" and "Product.ndx" from "\Tutorial\WD\Exercises\WD My First Database" to your project's EXE subdirectory via the file explorer.
      Note: Three files must be copied:
      • "Product.fic": file containing the data,
      • "Product.mmo": memo file containing the product images,
      • "Product.ndx": file containing the indexes to optimize the searches performed in the data file.
Creating links
All data file descriptions required by the account management application have been created.
Data files in the editor
We are now going to create the links between 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 "Orders" data files: a customer can have one or more orders and each order is linked to a customer.
    1. On the "Analysis" pane (found in the ribbon), in the "Creation" group, click "New link". The mouse cursor turns into a pen.
    2. Click on the "Customer" data file, then on the "Orders" data file.
    3. The wizard for link creation starts.
    4. Answer the questions asked by the wizard:
      Wizard for link creation
      • 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

        Note

        You can also specify the link cardinalities directly in the wizard.
        Modifying cardinalities
    5. Go to the next step. The wizard automatically proposes the key used by the link (CustomerID).
      Wizard for link creation
    6. Display the next wizard screen. The wizard offers to create the "CustomerID" key in the Orders data file to store the customer corresponding to the order.
      Wizard for link creation
    7. Accept this option by going to the next step.
    8. This screen is used to define the integrity rules that will be automatically applied. In our case, you have the ability to choose the requested behavior when deleting a customer as well as the requested behavior when modifying the customer identifier.
    9. Validate the integrity rules by going to the next screen.
    10. Click the green arrow. The link is automatically created in the data model editor.
  • Likewise, create a link between the PaymentMode and Orders data files. These two data files are linked as follows:
    • An order must have a payment mode.
    • A payment mode can be used in several orders.
    In the wizard:
    • The cardinalities are as follows: PaymentMode (0,n), Orders (1,1)
    • The link key corresponds to the "Code" item.
  • We are now going to create a link between the "Product" and "Orders" data files. This link will be used to create a link file, the file of 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
        Wizard for link creation
    3. Go to the next step. The wizard proposes to create a relation file. Keep the option "Create the relation file automatically" 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 regarding the integrity rules and go to the next step.
    7. The wizard proposes the unique key of the Orders data file to use: "OrdersID". Go to the next step.
    8. Validate the key creation by going to the next step.
    9. Keep the default options regarding the integrity rules and go to the next step.
    10. Click the green arrow. The relation file is automatically created in the data model editor.
      Data model editor
We are now going to modify the relation file that was created by WINDEV. Indeed, this relation 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 find out the quantity of products ordered and the total of 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, not only the caption will be modified: we will also rename the physical file linked to the data file description.
    1. Select the "Product_Orders" data file.
    2. In the popup menu (right mouse click), select "Description of data file".
    3. In the window that is displayed, modify:
      • the name of data file: "OrderLine".
      • the name on disk: "OrderLine".
        Describing data files
  • We are now going to modify the items of this relation file.
    1. Click Describing items to display the description of file items.
      Describing items
    2. This relation file has 3 items. Position the selection bar on the "Reference_OrdersID" item. This item is a composite key.

      Note

      A composite key is a set of items that constitute an index.
      This type of key is used to browse the data file according to 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_OrdersID" by "OrderLineID".
      • Click the "Caption" column.
      • Replace the current caption by "Identifier of OrderLine".
  • We are now going to add 3 new items into this relation file: Quantity, TotalIOT and TotalBT.
    1. Position on a new row and create the "Quantity" item. This item is a "Numeric" item.
    2. Position on a new table row and create the "TotalIOT" item. This item is a "Currency" item.
    3. A window is displayed, indicating that the item already exists in the analysis and proposing to re-use its characteristics:
      Creating an item
      Keep the options selected by default and validate (green button).
    4. Position on a new table row and create the "TotalBT" item. This item is a "Currency" item. Once again, use the existing description.
    5. The description of the "OrderLine" data file items is as follows.
      Describing items
    6. Validate the item description (green button at the bottom of the screen) and the data file description.
  • The analysis is as follows:
    Data model editor
Generating the analysis
Generating the analysis consists in validating the modifications performed in the analysis (creation of data files, addition or deletion of items, etc.) and to apply them to the entire project (pages, linked controls, reports, etc.).
The generation is automatically proposed when closing the data model editor while modifications have been performed.
You also have the ability to generate the analysis manually. That's what we are going to do.
  • To generate the analysis:
    1. In the data model editor, on the "Analysis" pane, in the "Analysis" group, click "Generation".
    2. The analysis generation is automatically started.
The descriptions of data files found in the analysis have been modified.
To update the data files of the application, WINDEV automatically starts the procedure for modifying the data files. This operation is used to update the data files (".fic" files) according to their description in the analysis.
  • The wizard for automatic modification starts. Validate the different steps until you reach the screen that lists the data files to take into account.
    • WINDEV detects that the PaymentMode 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
    • Go to the next step.
    • The wizard proposes to save the existing data files, don't change anything and go to the next step.
    • The wizard proposes to type the passwords for protecting the data files modified by the automatic modification. Keep the default options and go to the next step.
    • The list of data files to modify is displayed. Validate the wizard.
    • The data files are updated.
  • Close the data model editor.
The main steps for creating an analysis have been presented.
When your analysis is described and generated, you also have the ability to:
  • Create a full application via RAD (Rapid Application Development). The application corresponding to the analysis will be created according to this method in the next lesson.
  • Create a full custom application. This method will be used to develop a full application based on a database in part 4 of this tutorial. This application will be based on an analysis corresponding to the one that was created in this part.
Previous LessonTable of contentsNext Lesson
Minimum version required
  • Version 24
Comments
Click [Add] to post a comment