#1 2014-12-03 12:19:23

AOG
Member
Registered: 2014-02-24
Posts: 490

Runtime tables

Hello,
I am using mORMot for storing project data.
The (simplified) model looks like this

  TSQLProject = class(TSQLRecord)
  protected
    fName: RawUTF8;
  published
    property Name: RawUTF8 read fName write fName stored AS_UNIQUE;
  end;
  TSQLProjectID = type TID;

  TSQLProduct = class(TSQLRecord)
  protected
    fModel: RawUTF8;
    fProject: TSQLProjectID;
    fCreatedAt: TDateTime;
  published
    property Model: RawUTF8 read fModel write fModel;
    property Project_ID: TSQLProjectID read fProject write fProject;
    property CreatedAt: TDateTime read fCreatedAt write fCreatedAt;
  end;

At this moment, all product are stored into this single Product table.

I would like to change this.
Is it possible to use runtime created tables ?

E.g:
I would like to store Products from 5 years and older into separate tables.
A single table for each year.
The old tables will be stored on a standard disk.
The more recent tables will be stored on SSD.
Backups will also be made different, depending on age of product (table date).

Thanks !

Offline

#2 2014-12-03 12:23:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,231
Website

Re: Runtime tables

Inherit from TSQLProduct to define a new class, then use this new class to define a table with older data.

type
  TSQLProductArchived = class(TSQLProduct);

Then register this TSQLProductArchived as external table on another SQLite3 instance, which file would be stored on a standard disk.

Your application has to perform the archival process, i.e. moving data from TSQLProduct to TSQLProductArchived, on itself, e.g. every end of month.
Use a BatchAdd() to insert the archived products on the TSQLProductArchived table with maximum speed.

Offline

#3 2014-12-03 12:34:01

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: Runtime tables

Thanks ! I will give it a go !!

Offline

Board footer

Powered by FluxBB