Before you learn about the concept of data-centric programming, you should understand the traditional approach for developing applications on IBM i: program-centric programming.
With this approach, the program has the following responsibilities:
Data Access
Determine the files that are needed and the data access method (usually, record access level (RLA) to retrieve data one row at a time). Also, the program itself determines the relationship between the files, making the database management system (DBMS) of little
help.
Business Logic
The program has all the business rules embedded into the code (either directly or through a copy member). Business logic enforces the referential integrity between files.
User Interface
Show the results of the processing of the data and business rules to the user.
Monolithic applications can be considered as program-centric, but you can also think of modular applications that are built as program-centric.
Example of the structure of an application that is designed using a program-centric approach:
As you might notice, the program-centric approach has many disadvantages
Conversely, data-centric programming can be understood as the strategy to solve business problems by taking advantage of the features of the DBMS. This approach proposes implementing more business logic in the database and separating the business logic from high-level application programs. Figure 3-2 shows the basic structure of a data-centric program
Data-centric programming aims to take advantage of the DBMS, specifically with the following
items:
Optimizing the access to the data
The application requests data through SQL statements. Then, the DBMS selects the best way to access the data and advises the usage of any indexes that are required to make it more efficient.
Using constraints
With the usage of constraints, you can move business rules from the applications to the DBMS.
Normalization
With the usage of the DBMS, it is easier to keep normalization at least to third normal form. The DBMS understands the relationships of the tables by use of primary key (PK) and foreign key (FK) constraints. PK/FK relationships are non-business data, usually through the usage of identity columns in each table. An identity column automatically increments when new rows are added to the table, and it is maintained by the DBMS, not by the programmer.
In summary, here are the primary goals of the data-centric approach:
The closer that your design meets the above data-centric goals, the more you can take advantage of advanced technology. Here can you see a comparison between program-centric and data-centric approaches