PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • 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 2.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 a site with 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 (if not already done).
    2. Display the WEBDEV home page if necessary (Ctrl + <).
    3. In the home page, click the "Create a project" button and select "Site". 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.

      Note

      Tip: To create a project, you can also:
      1. Click among the quick access buttons of WEBDEV menu.
      2. The window for creating a new element is displayed: click "Project".
    4. First, the wizard allows you to type the project name, its location and its description. In our case, this project will be named "My_WEBDEV_Site".
    5. 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".
    6. The different wizard sections are indicated in the left margin. You can easily go from a section to another one by clicking on it. The other steps of the "Description" part being not fundamental, click "Charters" directly.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.
    7. This section is used to define the different charters associated with the project. For the programming charter, don't modify the suggested options. Go to the next step via the "Next" arrow found at the bottom.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 via the "Next" arrow at the bottom.
    8. This step is used to define the style book (also called "Skin"). The style book is used to define the site style.

      Note

      The skins are used to standardize the visual aspect of a site and they allow you to easily change style.
      The skin provides the images, the fonts, the texture, the shape of buttons and the styles available for the project.
      Select "Evolution".
    9. We are now going to specify the information regarding the database. Click "Database" directly.
    10. 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 "My_WEBDEV_Site" project.
      A corrected example can be accessed at any time to check the validity of operations performed.
      To open this corrected project, in the WEBDEV home page (Ctrl + <), click "Tutorial" and select "My WEBDEV site (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.
    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 WEBDEV).
      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.
To create the data files of this analysis, we will be using the different methods proposed by WEBDEV.

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 step (arrow at the bottom 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.
    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 wizard step.
    6. Validate the wizard. The "Customer" data file is automatically created in the data model 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". Go to the next wizard step.
    4. 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".
    5. 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 WEBDEV.

      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 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 the green button to validate. The data file is automatically created in the analysis. The description window of items is opened.
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 name of the file and the letters "ID".
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.
    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.

      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.
      • 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).
    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.
    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.
      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".
    3. Validate the parameter window (green button).
    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.

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 tab in most cases).
From the CSV file containing the data, WEBDEV 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 a file starts.
    3. Go to the next step.
    4. Select the format of file to import. In this case, select "Text file". Go to the next wizard step.
    5. Specify the path of file to import: "\Tutorial\WB\Exercises\My_WEBDEV_Site\PaymentMode.csv" found in the WEBDEV 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>"
    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. Go to the next step.
    11. The content of CSV file will be automatically converted to HFSQL format. The wizard proposes to create the HFSQL data file in the project directory. Keep the proposed options and go to the next step.
    12. Validate the wizard. WEBDEV creates the data file.
  • Let's study the description of imported data file:
    1. Select the "PaymentMode" data file then select "Description of data file" in the popup menu.
    2. Change the data file caption in the window that opens up: delete "(Imported)".
    3. Click the icon to display 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.
      • In the right section of the screen, click "Unique key".
    5. We get the following data:
    6. 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 WEBDEV subdirectory: "\Tutorial\WB\Exercises\My_WEBDEV_Site".
    2. Select the "Product.fic" file.
    3. Drag and Drop the "Product" file to the data model editor of WEBDEV.
    4. The import wizard starts. Validate the different screens. 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 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 on the directory of your project, on the "Home" pane, in the "General" group, click .
Creating links
We have created all the descriptions of the data files necessary for the product management application.
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:
      • 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.
    5. Go to the next step. The wizard automatically proposes the key used by the link (CustomerID).
    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.
    7. Accept this option by going to the next screen.
    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 "Orders" and "Product" 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 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
    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 to use the unique key of the Orders data file: "OrdersID". 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 the green arrow. The relation file is automatically created in the data model editor.
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 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 "Orders_Product" data file. Select "Description of data file" from the popup menu.
    2. In the window that is displayed, modify:
      • the name of data file: "OrderLine".
      • the name on disk: "OrderLine".
  • We are now going to modify the items of this relation file.
    1. Click the icon to display the description of file items.
    2. This data file has 3 items. Position the selection bar on the "OrdersID_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 "OrdersID_Reference" 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:
    4. Keep the options selected by default and validate (green button).
    5. Position on 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.
    7. Validate the item description (green button at the bottom of the screen) and the data file description.
  • The analysis is as follows:
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 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 wizard for automatic modification starts. Validate the different steps until you reach the screen that lists the data files to consider:
    • 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. 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 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 24
Comments
Click [Add] to post a comment