Table of Contents
RecID as a Perfect Machine
In this section you will see how the RecID field of Valentina Database is a true, perfect machine. It performs all of the tasks associated with a primary key but does so using zero disk space.
Perfect Machine is a machine, which do its job but not exists.
RecID - Logical Level
- Each Valentina DB Table have one RecID field.
- RecID plays role of a UNIQUE identifier of a table record.
- Corresponds to 4 bytes ULONG type field, which is read-only.
- We can jump to record with RecID = N directly.
- RecID of a record is never changed during its lifetime (except refactoring commands).
- RecID value of deleted records can be reused.
RecID - Physical Level
- RecID value is a physical number of a record.
- The first physical record has RecID = 1.
- A deleted record is marked as such in the Bitmap associated with Table. Records are not moved physically.
Storage Size - ZERO
RecID field uses zero space and yet still does the same job!
Let we have database Table with one million records.
VALENTINA way:
RecID field uses ZERO bytes on disk and in RAM. RecID field do not need index, so ZERO bytes.
RELATIONAL way:
You use a ULONG field (4 bytes) as Primary Key. Column data size: 4 bytes * 1million = 4 Mb. PK must have index. Index size: (4 bytes of KEY + 4 bytes internal ref) * 1.5 = 12Mb
ZERO job to Create RecID
Each Valentina Table always gets this field automatically. Developer needs to put ZERO efforts for it. The best code is no code at all.
VALENTINA way:
CREATE TABLE tblPerson( Name VarChar )
RELATIONAL way:
CREATE TABLE tblPerson(ID ULONG PRIMAY KEY, Name VarChar )