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:
- ORDA benefits
- ORDA overview
- Main concept
- ORDA APIs
- ORDA abstraction layer
- Working remotely
- Requests optimization
- Permissions system
- Sharing data between process
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.
- Query your database with an object-oriented approach
- Going back and forth between current selections to ORDA
- CRUD actions
- Logical operations
- Handle entities
- Work with objects and collections
- Compute statistics
- Order by formula
- Query with formulas
- Named placeholders for attribute paths
- Named placeholders
- Entity selection: extract() and refresh() methods
- Member methods to get structure information
- Compare two entity selections
- Optimistic locking mechanisms
- Locking entities
- Write generic code
- Example of generic code
- 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.
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.
- Welcome to the world of ORDA classes
- ORDA Classes to handle your data model
- ORDA Data model classes and REST
- TIPS with ORDA Data Model Classes
- A magic show with computed attributes
- 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.
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:
REST APIs
The REST server APIs rely on ORDA concepts.
Here are some valuable blog posts to learn how to use REST APIs.
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.
- Use ORDA to boost performance
- Complete control over the REST requests
- Requests optimization and a demo
- 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.
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!