- Overview
- Creating an analysis (LDM)
- 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
- Managing the analysis versions
- Restoring an analysis
- Undoing the last generation
- Resetting the version number to 1
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 define an analysis: - 1st method: Creating the analysis (or Logical Data Model (LDM)) directly.
- 2nd metod: Creating the Conceptual Data Model (CDM), then creating the analysis from the CDM. For more details, see Generating the LDM from the CDM.
This chapter presents the first method. Creating an analysis (LDM) In WINDEV, the terms "LDM" and "Analysis" are used interchangeably to define the structure of the database associated with a project. Creating an analysis (or LDM) To create an analysis: - Click
in the quick access buttons. In the window that appears, click "Data", then "Analysis". The analysis creation wizard opens. - 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.
- In the next step, select the type of database:
- In the next step, specify if necessary the connection information.
- Finish the analysis creation wizard. A wizard to create the first data file appears automatically.
- Create all the elements of the analysis (data files, items and links).
Adding a data file to an analysis The analysis allows you to define the structure of 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: - On the "Analysis" tab, in the "Creation" group, click "New
data file". The data file creation wizard opens.
- Select "Create a new data file description".
- 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.).
- 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: - On the "Analysis" tab, in the "Creation" group, click "New
data file". The data file creation wizard opens.
- Select the option "Select a preset data file description".
- 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.
- Select the items you want to keep. These items can be modified later.
- The imported data file is automatically inserted into the current analysis.
Note: To modify a data file or the items in a data file: - Select the data file.
- 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 - On the "Analysis" tab, in the "Creation" group, click "New
data file". The data file creation wizard opens.
- Select "Use the data files from an existing database" and select the type of database.
- Specify the source database containing the descriptions to be imported and the type of database. Depending on the selected type, specify the requested information.
- Select the tables or data files whose description must be imported and validate.
- The imported data file is automatically inserted into the current analysis.
Solution 2: From Windows explorer Drag the data file description from the Windows explorer and drop it onto the data model editor. For example: This is 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: - Double-click the data file where the item will be created. The description window of the data file items opens.
- Click the first empty row in the table.
- Specify the name, caption and type of the item.
- In the right section of the window, indicate the details of the new item (type, size, default value, iteration direction, etc.).
- Enter the details of the shared information by clicking"Parameters of the control bound to the selected item (shared information)".
- Validate the item description.
Note: You can also create an item using the meta-types provided by 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: - On the "Analysis" tab, in the "Creation" group, click "New link". The mouse cursor turns into a pen.
- Select the two data files to be linked. The link description window opens automatically.
- 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.
- To define the advanced cardinalities, check "Display advanced cardinalities" and answer the questions.
- Specify the link caption and briefly describe the purpose of the link.
- Specify the keys to be linked.
- Define the integrity rules. These rules ensure data integrity when one of the keys of the relationship is modified or deleted.
- Confirm. 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: - 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.
- 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 Cardinalities are essential because they ensure referential integrity in a database. To put it simply, these two questions can be broken down into four questions. For example, to describe a link between the Club and Member data files:
- each "Club" has at least one "Member": Yes/No
- each "Club" can have several "Members": Yes/No?
- each "Member" has at least one "Club": Yes/No?
- each "Member" can have several "Clubs": Yes/No?
Example of cardinalities: This example presents two different cardinalities: - 0,1: A person can be a member of a single sport club. This person does not have to belong to a sport club.
- 0,N: A club can have zero 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: A person can be a member of a single sport club. This person does not have to belong to a sport club.
- 0,10: A club can have from 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.
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 For a parallel link, each record in a data file (Product) is linked to a record in another data file (Info), and vice versa. 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. Note: This type of link is rare, as the two data files can be combined into a single file. 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 found in the other data file (Details) necessarily has an associated 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 cardinalityWith 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 cardinalityWith 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).
Note: This is a common type of link. 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 cardinalityWith 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 linkFor 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 (LDM): - Duplicate or copy an analysis. This makes it possible to have two identical analyses with different names.
- Delete an analysis.
- Rename an analysis.
- Associate an analysis with a project.
- Zoom in and zoom out an analysis in the editor.
- Move around the view of the analysis 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 a data file item in the data model editor: - Duplicate/Copy an item.
- Delete an item.
- Rename an item.
For more details, see Manipulating an 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.
Managing the analysis versions To manage the different versions of the analysis: - On the "Analysis" tab, in the "Analysis" group, click "Generation".
- Select "Manage versions".
- In the wizard, specify whether you want to work on the current analysis or on a specific analysis.
Note: If an analysis is damaged, you can select it and restore one of its previous 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: - one rectangle: few changes were made between the two versions.
- several rectangles: several modifications have been made between the two versions.
To view details of changes made between two versions: Double-click the line 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: - Select the version to restore.
- You can:
- 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.
- Confirm. The restore operation is performed.
Caution: Data files from an analysis that is more recent than the restored version can no longer be opened. 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 You can reset the analysis generation number to "1". To do so, go to the "Generation" tab, "Analysis" group, click "Analysis" 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.
|
|
|