0.4The concept of analysis (database)
The essentials in 30 seconds
- The analysis is the model (schema) of the database; WinDev vocabulary: file = table, item = column, link = relationship.
- Everything follows from it: RAD generates windows and reports from the analysis, and fields bind to items.
- Primary key = unique identifier; golden rule: take care of the analysis before drawing the windows.
Mini-case thread — Yacine draws the analysis of his trading business
Before drawing the slightest window, Yacine designs the analysis of his electrical equipment trading management application in Oran. In the analysis editor, he creates the files corresponding to his business entities: Customer, Product, Order, OrderLine, Invoice and Stock. For each one, he describes the items (name, type, size) — CodeClient, Nom, Ville; Reference, Designation, PrixUnitaireHT; NumeroCommande, DateCommande, CodeClient — and sets the primary key (the unique identifier, often automatic). He then draws the links that translate the real rules: a customer places several orders, an order contains several lines, an order produces one invoice. He keeps the golden rule in mind: if the analysis is shaky, everything that follows (windows, queries, reports) will be shaky too — and fixing it afterwards costs a lot.
Standalone case for this section: it returns in the course, the diagram, the script and the 48h challenge of section 0.4.
1. The analysis, data model
The analysis is THE central concept of WinDev: it is the description of the data structure, in other words the model (schema) of the database. There you describe the files (the equivalent of “tables”), the items (the equivalent of “columns”) and the links (the relationships between files). Watch out for PC SOFT's own vocabulary: what other tools call table / column / relationship is called here file / item / link. Yacine describes customers, products, orders and stock there.
2. Why everything follows from it
The analysis is decisive because everything follows from it. RAD relies on it and can generate windows, reports and code from it. The fields of the windows bind directly to the items: input, reading and saving become almost automatic. Queries and reports rest on the files and links. A correct model saves an enormous amount of time; a shaky model contaminates the whole application, as Yacine observes.
3. Primary key, links and golden rule
Two fundamental notions: the primary key (the item that uniquely identifies each record, often an automatic identifier) and the links, which express the real business relationships (a customer has several orders). Golden rule: take care of the analysis BEFORE drawing the windows. It is the most profitable investment of the whole project: fixing a structure afterwards forces you to redo windows, queries, reports and code, and to migrate existing data.
🔎 Concrete example — 🔎 Concrete example — browsing a customer's orders
Thanks to the Customer → Order link, Yacine lists the orders of the customer being searched for:
// List the orders of the selected customer (1-N link)
TableSupprimeTout(TAB_Commandes)
POUR TOUT Commande
SI Commande.CodeClient = Client.CodeClient ALORS
TableAjouteLigne(TAB_Commandes, Commande.Numero, Commande.DateCommande, Commande.MontantHT)
FIN
FIN
Reading: the link translates the rule “a customer has several orders” and allows navigation between files.
Lesson: a good link prevents duplicates and wrong totals — the worst bugs, because they do not crash, they lie.
Section vocabulary
- Analysis
- Model (schema) of the database: description of the data structure.
Simple example: Yacine describes his customers, products and orders there.
What it is not: an input window of the application.
Reflex: data structure → analysis.
- File (= table)
- Set of records of the same nature in the analysis (e.g. the Customer file).
Simple example: Yacine creates the Product file.
What it is not: a document on the hard disk.
Reflex: data table → file.
- Item (= column)
- Elementary piece of information described in a file, with a name, a type and a size.
Simple example: Yacine describes the Stock item as a numeric type.
What it is not: an entire window of the application.
Reflex: table column → item.
- Link (= relationship)
- Connection between two files expressing a business reality and ensuring consistency.
Simple example: A customer has several orders at Yacine's.
What it is not: a simple field color.
Reflex: business relationship → link.
- Primary key
- Item uniquely identifying each record of a file (often automatic).
Simple example: Yacine sets CodeClient as the primary key.
What it is not: an item with no identification role.
Reflex: unique identifier → primary key.
In practice — In practice — understanding and creating an analysis
- Open the analysis editor and create your files (= tables) corresponding to your business entities: Customer, Product, Order…
- Describe the items of each file (name, type, size), choosing the right type for each piece of information.
- Define the primary key of each file (often an automatic identifier) to identify each record.
- Draw the links between files, translating the real business rules (as Yacine does between Customer and Order), then generate the analysis before building the windows.
Step-by-step script — describing Yacine's analysis
// Analysis of Yacine's trading management application // Customer file : CodeClient (primary key), Nom, Ville, Solde // Product file : Reference (primary key), Designation, Stock // Order file : Numero (primary key), DateCommande, CodeClient // Invoice file : NumeroFacture (primary key), NumeroCommande // Links: Customer → Order → Invoice; Order → OrderLine // Golden rule: generate the analysis BEFORE drawing the windows
The vocabulary is WinDev's own: file = table, item = column, link = relationship.
Copy-paste template — adding a customer (automatic primary key)
// Yacine's template — BTN_Ajouter button of the FEN_Clients window
HRAZ(Client)
Client.Nom = SAI_Nom
Client.Ville = SAI_Ville
Client.Telephone = SAI_Telephone
Client.Solde = 0
HAjoute(Client)
Info("Client ajouté, code = " + Client.CodeClient)
Business files
Yacine creates Customer, Product, Order, OrderLine, Invoice and Stock in the analysis.
Primary key
Yacine sets CodeClient as the unique identifier, often automatic.
Business link
Yacine translates the rule “a customer has several orders” as a 1-N link.
Golden rule
Yacine completes and generates the analysis before drawing the first window.
✓ Best practices
- Start from the business: each file corresponds to a real entity.
- Set a primary key per file (often automatic).
- Take care of the analysis before the windows: it is the most profitable investment.
✗ Common pitfalls
- Confusing a file in the analysis with a file on disk.
- Drawing the windows before the analysis is stable.
- Neglecting the links: duplicates and wrong totals follow.
Key takeaways
- The analysis is the database model: files (= tables), items (= columns), links (= relationships).
- Everything follows from it: RAD generates windows and reports from the analysis, and fields bind to items.
- The primary key uniquely identifies each record; links translate business rules.
- Golden rule: take care of the analysis before drawing the windows.
48h challenge — apply it tomorrow
Like Yacine, draw a mini-analysis on paper: three or four files (e.g. Customer, Product, Order), their main items with a type, a primary key per file and at least one link translating a business rule. Do not touch the windows yet: the exercise is to think about the model before the interface.
- I know what the analysis is and its vocabulary (file, item, link).
- I understand why everything follows from the analysis in WinDev.
- I set a primary key and links before building the windows.
Frequently asked questions
Why should you take care of the analysis before starting the windows?
Because in WinDev everything follows from the analysis: RAD generates windows and reports from it, fields bind to items, and queries and reports rely on it. A shaky model contaminates the whole application, and fixing the structure afterwards requires a domino effect plus a risky data migration. It is the most profitable investment of the project, as Yacine does.
Why does WinDev talk about “files” and “items” rather than tables and columns?
It is a historical vocabulary choice by PC SOFT: the concepts are those of classic relational databases (file = table, item = column, record = row, link = relationship, analysis = schema). You need to know this correspondence so you do not get lost — and above all not confuse the “file” of the analysis (= a data table) with a file on disk.
What is called the analysis in WinDev?