The MAIN reason to use datamodule is to separate your data communication from your form.
Example 1:
You put a connection, some datacomponents, a dbgrid and some DBEdits on your form.
Before you save your record to the database, you want to make some calculations or changes. All these things are on your form. Always easy to get it together. Now you have a whole new form or you want to develop with another framework, all the code must be copied. You're not transparent.
If all your calculations and datachanges were on a datamodule, you only have to create a new form, connect the datamodule to your form and you're done.
Example 2:
Create a datamodule for your connection to a database. Each datamodule has these variable declared.
var Datamodule1: TDatamodule1;
This means that your datamodule can be reached globally if you put the unit (datamodule) in your uses clause
uses
Classes, SysUtils, Forms, FileUtil, dialogs, datamodule1;
In your form you can access your connection as datamodule.connection.open.
Example 3:
Create your datamodule as example 2. Create a new datamodule for your tables/queries. Put the datamodule of your connection in the uses of your new datamodule. This datamodule also has a variable declared can be reached globally if you put the datamodule to the uses of your form. The form doesn't have to know where the connection is made. The datacomponments knows it and you can access your data in your form.
There's a fourth way to create your form as follows: form <--> unit <--> datamodule. In this way the only thing the form wants to know is the datalink from your data to GUI-DBComponents.
In the early das of my development (Delphi 1), I also put all my components on a form and sometimes lost the survey.
tiOPF or other ORM helpers has another approach to your database, but also separate your data from your form.
I've created an example for another person, who also put all the non-DBComponenten on his form. Sometimes he was lost the way to communicate with the database. The main problem was putting several forms in the uses clause to get his data.
I don't say you have to do it as the most developers do. It's just a way of thinking of using datamodules. Have you read
this?
I'll put a link of a demo from me on
wetransfer. It's has the source, database and some dll of Embedded firebird.