ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WINDEV concepts / Part 3 - Databases
  • Overview
  • Creating an LDM (Logical Data Model)
  • Creating an analysis (or LDM)
  • Adding a data file to an analysis
  • Creating an item
  • Creating a link
  • Characteristics of the links defined in an analysis
  • Owner data file and member data file
  • Cardinalities
  • Advanced cardinalities
  • Referential integrity
  • Types of links
  • Possible operations in an analysis
  • Generating the analysis (LDM)
  • Analysis version management
  • Restoring an analysis
  • Undoing the last generation
  • Resetting the version number to 1
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
2. Analysis in practice
Previous pageTable of contentsNext page
Overview
When a project uses data files, it must be associated with an analysis. An analysis describes the structure of the data (data files, items, etc.) used in your project.
There are two methods to describe an analysis:
  • 1st method: Create the analysis (or Logical Data Model (LDM)) directly.
  • 2nd method: Create the Conceptual Data Model (CDM), then automatically create the analysis from the CDM. For more details, see the online help.
This chapter presents the first method.
Creating an LDM (Logical Data Model)
In WINDEV, the terms "LDM" and "Analysis" are interchangeably used to define the structure of the database associated with a project.

Creating an analysis (or LDM)

To create a LDM:
  1. Click in the quick access buttons. The new element window appears: click "Data" then "Analysis". The analysis creation wizard starts.
  2. Specify the general details of the analysis:
    • the analysis name and directory. The analysis corresponds to a ".WDA" file. By default, this file will be created in the directory of the project analysis (<Project name>.ANA directory). This directory must be accessible in read/write mode.
    • the analysis description to briefly explain what the analysis is about.
  3. In the next step, select the type of database:
  4. In the next step, specify if necessary the connection information.
  5. Finish the analysis creation wizard. A wizard to create the first data file appears automatically.
  6. Create all the elements of the analysis (data files, items and links).

Adding a data file to an analysis

The analysis defines the structure of the data files used by the project. In the analysis, a data file can be:
  • A new data file.
  • A preset data file, provided with WINDEV, WEBDEV or WINDEV Mobile.
  • A data file imported from an existing database (using a specific format, for example).
The following paragraphs explain how to create a data file.
To create a new data file:
  1. On the "Analysis" tab, in the "Creation" group, click "New file". The data file creation wizard starts.
  2. Select "Create a new data file description".
  3. Specify:
    • the name of the data file. This name is the logical name of the data file. It will be used to handle the data file.
    • the caption of the data file that briefly describes the file subject.
    • the representation of a record in the data file. This representation makes the questions asked when describing the links easier to understand. This option must be preceded by an indefinite article (A or AN).
    • whether the data file includes an "Automatic identifier" item. The value of this item is unique for each record and is automatically calculated by WINDEV, WEBDEV or WINDEV Mobile.
    • the type of database associated with the data file: Depending on the type selected, this data file will be handled by the HFSQL engine, an OLE DB driver or one of WINDEV or WEBDEV's Native Connectors (SQL Server, Oracle, etc.).
  4. The new data file becomes the current data file. The description window of the data file items opens automatically. It allows you to describe the file items.
To import a preset description of a data file:
  1. On the "Analysis" tab, in the "Creation" group, click "New file". The data file creation wizard starts.
  2. Select the option "Select a preset data file description".
  3. Choose the preset data file to be created (you can select multiple data files). This data file will be imported into the current analysis. This data file can be modified later.
  4. Select the items you want to keep. These items can be modified later.
  5. The imported data file is automatically inserted into the current analysis.
Remark: To modify a data file or the items in a data file:
  1. Select the data file.
  2. Select "Data file description" or "Description of items" in the context menu.
Two solutions can be used to import an existing data file description:
Solution 1: From the data model editor
  1. On the "Analysis" tab, in the "Creation" group, click "New file". The data file creation wizard starts.
  2. Select "Use the data files from an existing database" and select the type of database.
  3. Specify the source database containing the descriptions to be imported and the type of database. Depending on the selected type, specify the requested information.
  4. Select the tables or data files whose description must be imported and validate.
  5. The imported data file is automatically inserted into the current analysis.
Solution 2: From the Windows explorer
Drag the data file description from the Windows explorer and drop it onto the data model editor.
For example:
The image above shows an Oracle database on the server. SImply drag the name of the database and drop it onto the data model editor to transfer its description.

Creating an item

To create an item:
  1. Double-click the data file where the item will be created. The description window of the data file items opens.
  2. Click the first empty row in the table.
  3. Specify the name, caption and type of the item.
  4. In the right section of the window, indicate the details of the new item (type, size, default value, iteration direction, etc.).
  5. Specify the details about the shared information: click "Parameters of the control bound to the selected item (shared information)".
  6. Validate the item description.
Remark: you can also create an item from the metatypes available in WINDEV. To do so, click the button. The list of available metatypes appears.

Creating a link

Different types of links can be created between data files. For more details on links, see Characteristics of the links defined in an analysis.
To create a link:
  1. On the "Analysis" tab, in the "Creation" group, click "New link". The mouse cursor turns into a pen.
  2. Select the two data files to be linked. The link description window opens automatically.
  3. To define the cardinalities between the two data files:
    • select the desired cardinalities (0, 1; 1, 1; 0, N; 1, N).
    • answer the questions. The cardinalities will be automatically updated.
  4. To define the advanced cardinalities, check "Display advanced cardinalities" and answer the questions.
  5. Specify the link caption and briefly describe the purpose of the link.
  6. Specify the keys to be linked.
  7. Define the integrity rules. These rules ensure data integrity when one of the keys of the relationship is modified or deleted.
  8. Validate. The link is automatically created.
Characteristics of the links defined in an analysis

Owner data file and member data file

When a link is defined between two data files, there is an owner data file and a member data file:
  • the owner data file is the owner of the key.
  • the member data file is a member of the analysis data files containing a copy of the key.
To set the link between two data files, the key of the owner data file is copied to the member data file.
For example, the key of the Supplier data file is copied to each record of the Product data file. Several records of the Product data file can have the same key of the Supplier data file:
  • Supplier is the owner data file,
  • Product is the member data file.
This type of link is represented as follows:

Cardinalities

Cardinalities are used to count the relationships between two data files.
Cardinalities are defined according to the answers to the two following questions:
  1. For each record of the data file, what is the minimum number of records in the other data file this record is linked to?
    The answer provides the first part of the cardinality (minimum cardinality):
    • if the answer is "none", the cardinality is 0,X.
    • if the answer is "a single one", the cardinality is 1,X.
  2. For each record of the data file, what is the maximum number of records in the other data file this record is linked to?
    The answer provides the second part of the cardinality (maximum cardinality):
    • if the answer is "a single one", the cardinality is X,1.
    • if the answer is "several", the cardinality is X,N.
The answer to these two questions defines the cardinality that can be: 0,1 ; 0,N ; 1,1 ; 1,N
The description of cardinalities is essential: it is the basis for respecting the referential integrity of the database.
To put it simply, these two questions can be broken down into four questions. For example, to describe a link between the Club data file and the Person data file:
  • each "Club" has at least one "Person": Yes/No?
  • each "Club" can have several "Persons": Yes/No?
  • each "Person" has at least one "Club": Yes/No?
  • each "Person" can have several "Clubs": Yes/No?
Example of cardinalities:
This example presents two different cardinalities:
  • 0,1 cardinality: A person can be a member of a single sport club. This person does not have to belong to a sport club.
  • 0,N cardinality: A club can have no member or several members.

Advanced cardinalities

Cardinalities can be defined more precisely. This is referred to as advanced cardinalities.
These cardinalities allow you to specify exactly the minimum and maximum cardinality.
To define the advanced cardinalities, check "Display advanced cardinalities" in the link description.
Example of advanced cardinalities:
This example presents two different cardinalities:
  • 0,1 cardinality: A person can be a member of a single sport club. This person does not have to belong to a sport club.
  • 0,10 cardinality: A club can have 0 to 10 members.

Referential integrity

Referential integrity in a database is a set of constraints that maintains consistency of data in a relationship between two data files.
Referential integrity checks that:
  • if a record is deleted from the owner data file, the matching records in the member data files are also deleted,
  • if a record is added to a member data file, there is a matching record in the owner data file,
  • if a record is updated in the owner file, the unique key doesn't change, etc.The referential integrity is checked based on the nature of the link between the data files.
For more details on referential integrity, see the online help.

Types of links

There are different types of links between data files:
  • parallel
  • optional
  • complement
  • shared
  • complex
Parallel link
In a parallel link, each record found in a data file (Product) is linked to a record in another data file (Info), and conversely.
In a parallel link, the identifier of the Product data file is copied to the Info data file. This identifier is also a unique key in the Info data file.
Product is the owner data file and Info is the member data file.
Remark: This type of link is rare because the two data files can be combined into one.
The parallelism of records in the data file is respected if the following operations are run simultaneously on the two data files:
  • creation of a record.
  • deletion of a record.
  • reindexing with compression.
Optional link
For an optional link:
  • Each record of a data file (Category) has no matching records or has one matching record in the other data file (Group).
  • Each record of the other data file (Group) is associated with no record or with a single record in the first data file (Category).
An optional link is established by copying the identifier from one data file to the other.
Complement link
For a complement link:
  • Each record from a data file (Product) has no matching records or has one matching record in another data file (Details).
  • Each record in the other data file (Details) has a matching record in the first data file (Product).
Complement links are quite common. They are used when a record can have additional optional information.
In a complement link, the key of the Product data file is copied to the Details data file. To ensure the maximum cardinality of 1, it remains a unique key. Since this key is unique, it is not possible to insert more than one record in the Details data file for a record in Product.
Product is the owner data file and Details is the member data file.
Shared link
For a shared link, the same record in a data file (Supplier) can be shared by several records in another data file (Product). In a shared link, the key of the Supplier data file is copied to the Product data file. It becomes a multiple key to optimize the speed of the integrity check.
Supplier is the owner data file and Product is the member data file.
Depending on the cardinality, we can distinguish between four types of shared links:
  • Shared link with a 0,n - 0,1 cardinality.
  • Shared link with a 0,n - 1,1 cardinality.
  • Shared link with a 1,n - 0,1 cardinality.
  • Shared link with a 1,n - 1,1 cardinality.
Shared link with a 0,n - 0,1 cardinality
With this type of link:
  • an owner may have no member (a supplier does not necessarily have a product).
  • a member may have no owner (a product does not necessarily have a supplier).
Shared link with a 0,n - 1,1 cardinality
With this type of link:
  • an owner may have no member (a supplier may have no product).
  • each member has a single owner (each product has a single supplier).
Remark: This type of link is quite common. WINDEV allows you to automatically create windows that manage data files with a 0,N - 1,1 relationship.
Shared link with a 1,n - 0,1 cardinality
With this type of link:
  • each owner has at least one member (a supplier has at least one product).
  • a member may have no owner (a product may have no supplier).
Shared link with a 1,n - 1,1 cardinality
With this type of link:
  • each owner has at least one member (each supplier has at least one product).
  • each member has a single owner (each product has a single supplier).
Complex link
For a "complex" link, you need to define a relationship file.
The relationship file will be automatically created. It will contain a unique key that includes the two keys of the related data files.
The relationship file can also contain information specific to the link.
A complex link includes two shared links.
Example of complex link
An order (Orders data file) can contain one or more products. A product (Product data file) can be used in several orders.
In this case, a relationship file is required (OrderLine data file).
The OrderLine data file contains:
  • a unique key containing the keys of Product and Orders.
  • the number of products ordered.
The links between the data files are as follows:
Possible operations in an analysis
WINDEV allows you to perform the following operations on an analysis:
  • Duplicate/Copy an LDM: Duplicating an LDM allows you to have two identical LDMs with different names.
  • Delete an LDM.
  • Rename an LDM.
  • Associate an LDM with a project.
  • Enlarge or reduce a LDM in the editor.
  • Move a LDM in the editor.
WINDEV allows you to perform the following operations on a data file in the data model editor:
  • Duplicate/Copy a data file.
  • Delete a data file.
  • Rename a data file.
WINDEV allows you to perform the following operations on an item of a data file in the data model editor:
  • Duplicate/Copy an item.
  • Delete an item.
  • Rename an item.
For more details, see the online help.
Generating the analysis (LDM)
The analysis is generated before the programming cycle and after describing the data files. This generation is used to:
  • validate the changes made on the analysis (LDM).
  • create the modules required for programming.
  • automatically update the data files if necessary.
As long as the analysis (the LDM) is not generated, the analysis description (the data files) cannot be used in the project.
To generate the analysis, go to the "Analysis" tab, "Analysis" group and click "Generation".
The generation includes three steps:
  • Verification of the changes made and generation of the physical files corresponding to the analysis description.
  • Automatic modification of accessible data files (files in the "EXE" directory of the project).
  • Project synchronization.
Analysis version management
To manage the different versions of the analysis:
  1. On the "Analysis" tab, in the "Analysis" group, click "Generation".
  2. Select "Manage versions".
  3. In the wizard, specify whether you want to work on the current analysis or on a specific analysis.
Remark: when an analysis is damaged, you can select the damaged analysis to restore one of the earlier versions, for example.
All the versions of the analysis are displayed as a graph. The yellow box indicates the version number of the analysis and the text on the right shows the generation date.
The "small rectangles" displayed between two versions indicate:
  • a rectangle: few changes were made between the two versions.
  • several rectangles: several changes were made between the two versions.
To see the details of the changes made between two versions: Double-click the row containing the "small rectangles" or click [Changes].
The options available in the version manager are as follows:
  • Restoring an analysis.
  • Undoing the last generation.
  • Resetting the version number to 1.

Restoring an analysis

To restore an analysis from the version manager:
  1. Select the version to restore.
  2. It is possible to:
    • restore the version in the specified directory. An independent analysis corresponding to the selected version is created. This option is selected by default.
    • overwrite the current analysis.
  3. Validez. The restore operation is performed.
Caution: The data files of an analysis whose version number is more recent than the restored version cannot be reopened. In this case, you must also restore the data files of the restored analysis version or delete the existing data files and create them again.

Undoing the last generation

Undoing the last generation of the analysis allows you to restore the analysis to its state before the last generation. All changes made since then are not applied.

Resetting the version number to 1

The analysis generation number can be reset to "1": on the "Analysis" tab, in the "Analysis" group, click "Generation" and select "Reset analysis version to 1".
In this case, the analysis version number is reset to one. No specific action is performed on the data files.
Previous pageTable of contentsNext page
Comments
Click [Add] to post a comment

Last update: 02/20/2024

Send a report | Local help