PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
New WEBDEV 26 feature!
  • In this lesson you will learn 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 2.2. Project and analysis
In this lesson you will learn the following concepts
  • Creating a project.
  • Creating an analysis.
Lesson duration

Estimated time: 40 mn
Previous LessonTable of contentsNext Lesson
Overview
To create a site with a database, you must:
  • Create the project linked to the site. This project will group all site elements (pages, codes, queries, reports, etc.).
  • Create the analysis linked to the project. The analysis is used to describe all data files handled by the site.
Creating the project
  • To create the project:
    1. Start WEBDEV.
    2. Go to the WEBDEV home page if necessary (Ctrl + <).
    3. In the home page, click the "Create a project" button and select "Site". The project creation wizard starts. The different steps of the wizard will help you create your project. The information specified in this wizard can be modified later.

      Note

      Tip: To create a project, you can also:
      1. Click Creating an element in the quick access buttons of the WEBDEV menu.
      2. The element creation window appears: click "Project".
    4. The wizard proposes to create a blank project or a project based on an example. Select "Create a blank project" and go to the next step ("Next").
    5. Specify the type of site to create. Select "WEBDEV site" and go to the next step.
    6. The wizard proposes two generation modes. Select "Session mode" and go the next step.
    7. The wizard allows you to enter the name of the project, its location and description. In our case, this project will be named "My_WEBDEV_Site".
      Project creation wizard - General information
    8. By default, WEBDEV proposes to create this project in the "\My Sites\My_WEBDEV_Site" directory. You can keep this location or modify it via the [...] button.

      Note

      When you develop for the Web, avoid using accented characters in the names of elements (projects, pages, etc.).
      For the project summary, type "The purpose of project is to manage products".
    9. The different wizard sections are indicated in the left margin. You can easily go from a section to another one by clicking on it. Since the other steps of the "Description" are not strictly necessary, you can click "Guidelines" directly.
    10. This section is used to define the different guidelines associated with the project. For the code style, don't modify the suggested options. Go to the next step.
    11. This step is used to define the style book (also called "Skin"). The style book is used to define the site style.

      Note

      Skins are used to standardize the visual aspect of a site and easily change styles.
      The skin provides images, fonts, texture, button shapes and styles available for the project.
      Select "Phoenix".
      Project creation wizard - Choosing the skin template
    12. We are now going to specify the database information. Click "Database" directly.
    13. Select "Yes, create a new database" and validate. The analysis creation wizard starts.

      Note

      To better understand the lessons found in this section and to optimize your training, we advise you to create the "My_WEBDEV_Site" project.
      A corrected example is available at any time to check the validity of the operations performed.
      To open the corrected project, go to the WEBDEV home page (Ctrl + <), click "Tutorial" and select "My WEBDEV site (Answers)".
Creating the analysis
  • The steps of the analysis creation wizard 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.
      Analysis creation wizard - Name of the analysis
      Go to the next step of the wizard.
    2. You can then choose the type of database used by the project. Select "HFSQL Classic".
      Analysis creation wizard - Type of database
      Go to the next step of the wizard.
    3. Validate. The data file creation wizard starts automatically.
Creating the description of data files
Our customer and order management application will be associated with the following analysis. This analysis includes five different data files (tables):
  • Customer,
  • Order,
  • PaymentMode,
  • OrderLine,
  • Product.
Lesson analysis
To create the data files of this analysis, we will use the different methods proposed by WEBDEV.

Creating a data file: using a preset data file

  • The steps of the data file creation wizard are:
    1. In the wizard, select "Select a description among the preset data files".
      Data file creation wizard
      Go to the next step of the wizard.
    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.
      Preset data file creation wizard
    4. Click "None" to deselect all items. Then, check the following items: CustomerID, Company, LastName, FirstName, Address, ZipCode, City, StateDep, Country, Phone, Cell, Email.
    5. Go to the next step of the wizard.
    6. Validate the wizard. The "Customer" data file is automatically created in the data model editor.
      Data file created in the data model editor
    7. The element creation window appears. 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 element creation window:
    1. Click "Data" then "Data file".

      Note

      You can also create a data file from the data model editor: in the ribbon, go to the "Analysis" tab, "Creation" group and click "New file".
    2. The data file creation wizard starts.
    3. In the wizard, select "Create a new data file description".
      Data file creation wizard
      Go to the next step of the wizard.
    4. We are going to create the "Order" data file. Name the data file "Order" in the wizard.
      This name will be used:
      • to manipulate the data file in the code. The variable associated with the data file will be "Order".
      • to build the name of associated physical data file ("Order.fic" file).
      The caption and description of the elements represented by the records in the data file appear automatically.

      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 created from the data file name.
      In our case, type "An order".
      Data file creation wizard - Data file name
    5. 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.

      Note

      To create the identifier (an identifier is a unique key), you can create an item of type "Automatic ID".
      This identifier is automatically managed by WEBDEV. Whenever a record is added into the data file, WEBDEV automatically assigns a value to the file identifier. This value is unique.
    6. 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.
    7. Click "Finish" to validate. The data file is automatically created in the analysis. The description window of items is opened.
      Description window of items of a data file
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 already been automatically created: "OrderID". 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 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. 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.
      Date item description
    3. This item will be a key item (index) in our data file: keys are used access and sort data faster.

      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 multiple times in the data file.
      • In the case of an SQL database, the engine makes the best use of indexes.
      • For a sequential browse of a data file, all you have to do is specify the browse index (which means the key).
    4. The key can be defined as follows: re-select the line of "Date" item to enable the description controls found on the right of screen. Then, simply specify the type of key used. In our case, the date is a key with duplicates.
      Key characteristics
    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 the cursor on a new row in the array 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 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 bound to the selected item.
      Link to display shared information
      The information typed in the new window that is displayed will be automatically used when creating pages linked to the data file. You will find here the control type and the caption.
      We are going to type the different options corresponding to the order status in the "Content" tab:
      • Click the "Content" tab.
      • The option 1 corresponds to "Pending". Type "Pending" in the edit control found on the right of number 1.
      • Type "Validated" in the edit control found on the right of number 2.
      • Click on "+" to add a new option in the radio button.
      • Type "Canceled" instead of "Option 3".
        Entering the shared information
    3. Validate the parameter window ("OK").
    4. Similarly:
      • Move the cursor to a new row and create the "TotalBT" item. This item is a "Currency" item.
      • Move the cursor to a new row and create the "TotalIOT" item. This item is a "Currency" item.
    5. That's it, the description of the "Order" data file is complete. Validate the description window of items.
    6. The "Order" data file appears in the data model editor.
      Customer and Order data files in the data model 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 uses 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 tab in most cases).
From 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 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...".

      Tip

      To import a CSV file (or any other file) into the analysis, you can also drag the CSV file from Windows explorer and drop it onto the data model editor. This will be presented in the next paragraph.
    2. The file import wizard starts.
    3. Go to the next step.
    4. Select the format of the data file to import. Select "Text file".
      Analysis - Selecting the type of data to import
      Go to the next step of the wizard.
    5. Specify the path of the file to import: "\Tutorial\WB\Exercises\My_WEBDEV_Site\PaymentMode.csv" located in the WEBDEV setup directory.
    6. Go to the next step of the wizard.
    7. 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
    8. Don't forget to check "The first row contains the names of the columns".
    9. Go to the next step.
    10. The structure of the data file that will be created is displayed. Keep the default options. Go to the next step.
      Structure of the imported data file
    11. The content of the CSV file will be automatically converted to HFSQL. The wizard proposes to create the HFSQL data file in the project directory.
      Converting the data
      Keep the default options and go to the next step.
    12. Validate the wizard. WEBDEV creates the data file.
  • Let's examine the description of the imported data file:
    1. Select the "PaymentMode" data file and select "Data file description" in the context menu.
    2. Change the data file caption in the window that appears: delete "(Imported)".
    3. Click Display data file items to open the description of the data file items.
    4. 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.
      • On the right side of the screen, click "Unique key".
        Key characteristics
    5. We get the following data:
      Items of the imported CSV file
    6. Validate the item and data file description windows.

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 WEBDEV subdirectory: "\Tutorial\WB\Exercises\My_WEBDEV_Site".
    2. Select the "Product.fic" file.
    3. Drag the "Product" file and drop it onto the WEBDEV data model editor.
    4. The import wizard starts. Validate the different steps of the wizard. The data file appears in the data model editor.
All necessary data files are now in the data model editor.

Caution!

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 handle the data in the data file has just been imported:
  1. Open the Windows file explorer.
  2. Select the following WEBDEV subdirectory: "\Tutorial\WB\Exercises\My_WEBDEV_Site".
  3. Copy "Product.fic", "Product.mmo" and "Product.ndx" to the EXE subdirectory of your project directory.
Remark: To open the file explorer directly on the directory of your project, go to the Home" pane, "General" group and click Open project directory.
Creating links
We have created all the descriptions of the data files necessary for the product management application.
Data files in the analysis from this exercise
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 "Order" data files: a customer can have one or more orders, and each order is linked to a customer.
    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 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

        Note

        You can also specify the link cardinalities directly in the wizard.
        Entering cardinalities
    5. Go to the next step. The wizard automatically proposes the key used by the link (CustomerID).
      Link creation wizard
    6. Go 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.
  • Likewise, create a link between the "PaymentMode" and "Order" 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), Order (1, 1).
    • The link key corresponds to the "Code" item.
  • We are now going to 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 regarding 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 regarding 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 are now going to modify the relation file that was created by WEBDEV. This file will contain the order lines.
We are going to:
  • Modify the name of the relation file.
  • Modify the name of its items.
  • Add items to find out the quantity of products ordered and the total of the order line.
  • First, we are going to 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 are now going to modify the items of this relation file.
    1. Click Display item description to open the description of the data file items.
      Description of the data file items
    2. This data file has 3 items. Position the selection bar on the "OrderID_Reference" 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 "OrderID_Reference" with "OrderLineID".
      • Click the "Caption" column.
      • Replace the current caption with "Identifier of OrderLine".
  • Now we are now going to 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. This item is a "Numeric" item.
    2. Move the cursor to 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:
      Item in the analysis
    4. Keep the options selected by default and validate ("OK").
    5. Move the cursor to a new table row and create the "TotalBT" item. This item is a "Currency" 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
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.).
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 is automatically started.
The descriptions of the analysis data files have been modified.
  • To update the data files of application, WEBDEV proposes to synchronize the structure of deployed data (also called "modification procedure of data files"). This operation is used to update the physical data files (".fic" files) according to their description in the analysis.
  • Click the "Start" button.
  • The automatic modification wizard starts.
    1. Validate the different steps of the wizard until you reach the the list of the data files to take into account:
      Automatic data file modification
      • The PaymentMode data file must be updated. Keep this file selected.
      • The Product data file was copied into the project directory. WEBDEV proposes to associate it with this 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 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.
    5. The list of data files to modify is displayed. Finish the wizard.
    6. The data files are updated.
  • Close the data model editor.
We have covered the main steps to create an analysis.
When your analysis is described and generated, you can:
  • Create a full site via RAD (Rapid Application Development).
    See Creating an application by RAD for more details.
  • Create a full custom site. This method will be used to develop a full site based on a database in section 3 of this tutorial. This site will be based on an analysis corresponding to the one that was created in this section.
Previous LessonTable of contentsNext Lesson
Minimum version required
  • Version 26
Comments
Click [Add] to post a comment