France,
Toulouse,
Friday, May, 5th, 2006,
4:36 pm.
Hi José,
Well, it's a big and interesting yard you are opening. ;-)
I think you are trying to build a kind of caching system.
Here are some idea:
You should create a class that represent the actual database file.
This class should have some method like inserting, deleting, updating data.
An important method could be the "Save" method that would save all
modifications into the actual database file.
Another idea: internally (I mean the core of the class), use dictionary to
store data. It's fast, easier to retrieve data (a little bit like do SQL
statements), no type to define, and don't consume a lot of memory.
So here is a schema of this first attempt:
Your application <-> Your Class <-> The Actual Database File
Another idea is to upload data in memory (so, in your class) from the actual
database file when these data are solicited by your application. I'm talking
about the cache system.
For example, if your application ask data stored in the record number 10 of
the table Table1, then the class would upload in memory the content of this
record and then pass the desired data to your application. The class would
maintains this record in memory until the application quit (or a kind of
time out system). If your application want to modify the content of this
record, then your class update this record stored in the class, not in the
database. It will be saved into the file when the "Save" method is called.
So, the class upload data only if your application try to retrieve one of
them. Whenever necessary.
Advantages:
Your application consume less memory.
You don't have to upload the entire database at startup (imagine if the size
of the database file is very very big, your users could wait several
minutes). So your application is faster. And why to upload useless data ?
You don't waste read operations.
It's more secure.
You know what to save if data has been modified in memory.
And so on.
To be short, you are more efficient.
Note:
If your class is specific to your project, then you are not obliged to mimic
SQL statements, hence the database engine. For example, try to build method
which has the same name as tables.
For example:
UpdateUserName( anID As Integer, aName As String, aLogin As String,
aPassword As String)
This method mimic the following SQL statement:
"INSERT INTO Users ( ID, Name, Login, Password ) VALUES ( " + Str( anID
) + ", """ + aName + """, """ + aLogin + """, """ + aPassword + """ )"
You will do this at the end when the "Save" method will be called by your
application before quitting.
Hope that will help you.
Nils
----
Nils Frisch
http://www.nils-frisch.com/
Toulouse,
France.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>