Thema: Delphi Save record to BLOB

Einzelnen Beitrag anzeigen

Benutzerbild von sx2008
sx2008

Registriert seit: 16. Feb 2008
Ort: Baden-Württemberg
2.332 Beiträge
 
Delphi 2007 Professional
 
#12

Re: Save record to BLOB

  Alt 5. Dez 2009, 17:43
Zitat von nanix:
I only save all data to 1 BLOB how can i loose performance with this.
Let's asume you want to read all sensors from one monitor with the name "Test2009".
Let's asume further there are 100 monitors and each monitor has 100 sensors.
And everything is stored in one single BLOB.
You have to read the BLOB on the whole and start a while-loop to find the monitor.
This is really unefficient.
You read a BLOB that could be huge only to use small parts of it.
On a network this would waste a lot of bandwith.

On the other side, if you have a well designed database you would emit this SQL query:
SELECT * FROM sensors WHERE MonitorName='Test2009' and within a few milliseconds you will get exactly what you are looking for.

Let's assume you want to extend the TMonitor structure:
Delphi-Quellcode:
TMonitor = record
  Name :String[20];
  Sensor :Array of TSensor
  Manufacturer : string; // new
end;
If you have a clean database this task is very easy; simply add a field to the table "monitors".
But with your design you will have big problems.
You need a TMonitorOld and a TMonitorNew record and a flag to indicate the old or the new structure.

Here are some argument against Blobs:
A clean designed database could be used without your application.
It has a value because it is open and portable.
But a table with a single BLOB is worthless without a working app.
If your app has a bug, everything could be destroyed and your data is lost.
fork me on Github
  Mit Zitat antworten Zitat