[REBOL] [DEV] dbms3.r 01
From: g::santilli::tiscalinet::it at: 13-Jan-2002 15:36
PROJECT NAME: dbms3.r (temporary)
writing a small and simple relational database management system
in REBOL, for use with applications that don't need a full blown
separate DBMS such as MySQL. With respect to dbms.r, it will be
more efficient in the data storage to be usable with much more
rows per table, and possibly will have a more powerful/abstracted
DEVELOPMENT, part 1
let's start with the low level functions to handle tables on disk.
table on memory could be useful too, but should be easier to
implement. we can then adapt dbms.r to use the new format, to have
an usable system in less time. we'll need a better way to store
rows, maybe in blocks or all in one file. the problem with using
one single file for the data is that currently rebol does not
allow for easy seeking on direct ports. subdividing the table in
blocks of 100 or 1000 rows and having a file per block might be
more efficient - maybe someone wants to run some benchmarks. if we
use one file, we need a file to index the rows in the file since i
expect to have dynamic sized rows as in dbms.r. the index can be
kept in memory too, since it will be a block of integers, so about
16 bytes per row. we're not targetting 1'000'000 rows per table so
that does not seem a problem.
i think we can proceed this way: let's create all three kinds of
tables, then we can let the user choose. let's start with tables
on memory, that can be simply represented with blocks. our
interface should include ways to: append a new row, pick a row,
change a row, remove a row.
; brett, i like your idea. :)
memory-table-funcs: context memory-table-funcs-code
; i like joel's style, but i'll stick with the standard here
memory-table-funcs: context [
row-append: func row-append-spec row-append-code
row-pick: func row-pick-spec row-pick-code
row-change: func row-change-spec row-change-code
row-remove: func row-remove-spec row-remove-code
memory-table-funcs: context [
row-append: func [
"Append a row to an on-memory table"
; returns the row-id of the new row
row-pick: func [
"Pick a row from an on-memory table"
; returns the row or none! for an invalid row-id
row-change: func [
"Change a row in an on-memory table"
changes [block! object!]
; returns the row-id of the changed row, or none! for
; an invalid row-id
row-remove: func [
"Remove a row from an on-memory table"
; returns true, or false if the row-id is invalid
some comments: the row-id will be the index of the row in the
block, so it's an integer. this might be different for other kind
of tables. also, the row-id of a row is not guaranteed to remain
constant for a row, like in dbms.r. the changes argument of the
row-change function can be a block or an object; a block is useful
for things such as [column: column + 1] where you want to change
the value of a column based on its previous value.
[TO BE CONTINUED]
(I'll stop here for today, as I want too see the reaction of the
list before going too much further.)