ORDA – From Beginner to Expert

ORDA, which stands for Object Relational Data Access, is a method of accessing data that combines the advantages of object-oriented programming with those of relational databases, allowing developers to focus on solving business problems rather than managing data access.

Whether you are new to ORDA or already familiar with it and want to expand your knowledge, consider this blog post a road map to guide you through the learning process.

This blog post includes the following:

Without further ado, let’s get down to business!

Why should I care about ORDA?

Before going through the technical details, let’s list some of ORDA’s benefits:

  Everything is an Object 

ORDA is a world where everything is an object, including the database. 

This approach allows one to access the entire 4D database using an object-oriented approach, which makes it easier to work with data and can help reduce the complexity of the code. ORDA maps data to real-world concepts so that using the data becomes simple and removes the need for an in-depth understanding of the relational structure. 

  Business-oriented Code with Classes 

ORDA comes with classes dedicated to the data model. Thanks to classes, the complexity of the data’s physical implementation can be hidden, and the application can easily expose services, be more manageable, easier to maintain, and seamlessly integrate with other applications.  

  Out-of-the-box Performance   

ORDA can help improve the performance of applications by providing several optimization techniques, such as contexts and lazy loading. These techniques can help reduce the number of database queries that need to be executed, leading to faster application response times. Best part? It’s all automatic; unlike SQL or an ORM tool, no programming is required.  

  Increased Scalability 

ORDA can help make applications more scalable by supporting distributed database architectures. This means that data can be spread across multiple database servers, which can help improve performance and handle more significant amounts of data.

  Open & Extensible 

ORDA allows the creation of seamless integration between different systems. It can be combined with the REST server to expose business logic with a controlled API (through your classes) for other tools, such as web frameworks like Angular or React. 

After learning some of ORDA’s benefits and how this technology can positively affect your application, let’s dive into technical details.

ORDA global overview

This schema shows a global overview of all ORDA usage:

  • ORDA provides APIs to work with your data and a robust abstraction layer that will be exposed as business APIs.
  • A complete system of permissions is available to filter access to your data.
  • With ORDA, you can work with the REST Server using remote data stores or the REST APIs.
  • You can use ORDA if you work in Client-Server mode.
  • ORDA code can also be used in a web application (4DACTION, 4D tags).

This diagram should give you an overview of how ORDA connects to different 4D parts. Once the idea is clear, follow the steps below to start your learning journey.

Let the learning journey begins!

step 1 – Main concepts

ORDA’s main concepts can be discovered here.

First, get familiar with the terms datastore, dataclass, entity, and entity selections. Understand the meaning of those concepts, as you will see them often when working with ORDA.

step 2 – ORDA APIs

Second, look at ORDA object-oriented APIs and discover how you can handle your data with those APIs.

For example, the most frequently used API is query() to run a query on your database.

To help you discover each API, here is a list of blog posts with demo applications you can play with.

  1. Query your database with an object-oriented approach
  2. Going back and forth between current selections to ORDA
  3. CRUD actions
  4. Logical operations
  5. Handle entities
  6. Work with objects and collections
  7. Compute statistics
  8. Order by formula
  9. Query with formulas
  10. Named placeholders for attribute paths
  11. Named placeholders
  12. Entity selection: extract() and refresh() methods
  13. Member methods to get structure information
  14. Compare two entity selections
  15. Optimistic locking mechanisms
  16. Locking entities
  17. Write generic code
  18. Example of generic code
  19. ORDA cheat sheet

  discover the power of relations with orda

As we stated earlier, ORDA is a method of accessing data that combines object-oriented programming with relational databases’ advantages.

If you want to go further and discover all the advantages you can take from the relations using ORDA, here is a series of demos where you’ll learn how to save many lines of code and build a user-friendly interface.

    1. Episode 1
    2. Episode 2
    3. Episode 3
    4. Episode 4

  Link it with classic 4D code

If you still use the classic 4D code (we all know and love), you can mix it with the ORDA code if needed.

This is useful for introducing ORDA concepts progressively in your application.

Check this blog post for details.

Step 3 – ORDA abstraction layer.

To go further with ORDA, take advantage of the abstraction layer.

In this layer, you will implement all your business logic through ORDA Data Model classes.

Handling classes goes a step further in object-oriented programming. Each class can take business logic in functions.

Discover the benefit of computed attributes and aliases. It is easy to set up a computed attribute defining its calculation formula and all its business logic. Or define an alias as any other attribute in your data model. 

Therefore, the developers will consume this abstraction layer instead of handling the physical implementation layer.

  1. Welcome to the world of ORDA classes
  2. ORDA Classes to handle your data model
  3. ORDA Data model classes and REST
  4. TIPS with ORDA Data Model Classes
  5. A magic show with computed attributes
  6. Say hello to aliases

 

step 4 – Working remotely

Now it’s time for the fun part 🙂 

client-server

You can use ORDA in client-server mode. Use the ds command to get the datastore object and start working with your data.

Here are more details about specific features to work in C/S.

  1. The local keyword
  2. Refresh entity selection

remote datastore

If you work in Client Server, you are limited to the current database, which requires a permanent network connection.

Thanks to the remote datastore, an application can get data from another remote 4D database exposed on a 4D server!

A lot of use cases are covered by this feature:

  • organize your applications to work offline and only synchronize local data when remote data is reachable
  • publish your data on multiple servers and switch from one to the other as necessary
  • Split your data model across different databases (e.g., local data, international data). Then you can have your data distributed in different places and still accessible through a single 4D client code (project methods and form objects)

 

Read those blog posts to learn more:

  1. Multiple 4D datasources, interested?
  2. Remote datastores, a practical use case

REST APIs

The REST server APIs rely on ORDA concepts.

Here are some valuable blog posts to learn how to use REST APIs.

    1. 4D Rest server and Postman
    2. 4D Rest server and ReactJs
    3. ORDA Data model classes and REST
    4. The exposed keyword

step 5 – requests optimization

When you work remotely with ORDA, be aware requests are automatically optimized to ask the server only the needed attributes. On top of that, you can also customize your own optimization rules to improve performance.

To learn more step by step, here is a list of blog posts.

  1. Use ORDA to boost performance
  2. Complete control over the REST requests
  3. Requests optimization and a demo
  4. Requests logging

 

And here is a live video demo that was done during the Summit 2020

step 6 – Permissions system to filter access to data

Filter access to data is a must-have feature to prevent malicious access to your application.

Since v19R8, you benefit from a powerful and fully customizable system to protect your data from unauthorized users. It is a system to protect your data depending on who is accessing it and which data is accessed.

It covers all web processes, such as REST requests, requests received on a remote datastore, and web processes like 4DACTION or 4D tags.

Read this blog post to learn more.

Step 7 – sharing data between processes

You might have worked with shared objects and shared collections. You can also share entity selections between several processes, increasing performance.

Read those blog posts to learn more:

  1. Share an entity selection between processes
  2. Move to shareable entity selections smoothly

web application

You can also use this when working with scalable web sessions. They can handle several processes in preemptive mode. This means that scalable web sessions can take several user-agent requests at the same time.

These new scalable web sessions can share data between these processes, even entity selections.

Those blog posts will help you if you work with entity selections in web processes.

    1. Scalable web sessions for advanced web applications
    2. Sharing leads to performance
    3. ORDA easy looping with 4D tag

To conclude

Remember, ORDA is a powerful tool that can make your development process and data access faster and more efficient.

We hope this blog post has helped you. Do not hesitate to ask questions on the forum.

We’ll be happy to help you with ORDA!

Avatar
• Product Owner • Marie-Sophie Landrieu-Yvert has joined the 4D Product team as a Product Owner in 2017. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Marie-Sophie graduated from the ESIGELEC Engineering School and began her career as an engineer at IBM in 1995. She participated on various projects (maintenance or build projects) and worked as a Cobol developer. Then she worked as an UML designer and Java developer. Lately her main roles were analyzing and writing functional requirements, coordinate business and development teams.