r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

World: r3wp

[!RebDB] REBOL Pseudo-Relational Database

1) Couple of good bugs there ... fixing for 3.0.2.

2) Yes. Use all and any to group multiple conditions (e.g. [all [c1 
> 2 c2 < 7]] )
RebDB 3.0.2 uploaded (same access instructions as before).

Documentation updated ... http://www.dobeash.com/RebDB/rebdb3.html

This release renames several db-* functions more in line with REBOL 
naming conventions (e.g. db-insert renamed to db-append as rows are 
in actual fact appended not inserted).

Overall performance improvements (tested against a 1 million row 

	- db-append 1.2x faster
	- db-append/nocheck option 8x faster than db-insert
	- sort-idx 2x faster
	- db-select with REBOL conditions 1.2x faster

It's going to get seriously interesting once ports are working properly 
and I can start benchmarking (and optimizing) disk and URL based 
direct access.
what do you mean by ports working properly?
pekr, i guess ashley refers to http://www.rebol.org/aga-display-posts.r?post=r3wp771x652
Great news! thanks for upgrade. What about promissed file storage, 
i.e. is ti possible to operate the DB and index binary directly to/from 
ti=it :)
Anyway multiple condition is really cool I recommend to everybody 
attention, selection works as expected now thanks!
Really neat is you may create as many index columns as you need/want 
and then you can use only those ones what makes sence for you selection 
parameters. I.e. you can use multiple indexes/couners above one dataset 
and then use multiple selection for BETWEEN statement for example.
I've got only one exception. If I need different schema for each 
row (like in DevChat for example) I have to use Binary dat ecapsulation 
and sniff in binary  in second level. But multiple index columns 
helps alot in this.
Exactly. RebDB3 is optimized for "left to right" equality checks 
... which in my experience is the majority access pattern. When you 
have more than one key you are actually imposing a grouping heirarchy 
upon the data (e.g. a 3 column key of Country, State/Province/Region 
and City for example).
Ashley I think the name Index is little bit missleading the more 
appropriate would be offsets.  Anyway real indexes (ordered lists), 
are you building them on demand each new selection? Ie it is rebuilded 
on each selection or there are not used at all and each selection 
traverses thru data one of three methods?

Or maybe make the question easier is it possible to create and save 
true index on column?
The index [of offsets] is created by reading a number of columns 
(min 1) equal to key-cols and inserting both the composite row and 
the offset into a block which is then sorted by the composite row. 
For eaxmple:

Say we have 2 columns of integers in the index and also assume we 
have two rows.


	3 2 ...
	2 3 ..

might create an intermediate block like:

	#{0034} #{01030102}	; note the #{01} field length indicators}
	#{0056} #{01020103}

which is sorted to produce an index of:


Index is updated as rows are inserted or deleted. Some insert and 
update operations will set a reindex flag which is acted upon the 
next time a lookup or seek is performed.

This index is maintained automatically by RebDB ... you cannot "create" 
one in the traditional sense of the word. The weakness of this scheme 
is it assumes that key access is by column 1 OR column 1 & column 
2. It doesn't handle the situation where you need key access to column 
1 OR column 2 (which in my experience is a fairly uncommon case).
OK thanks for description
Anyway I'like to ask again about direct file storage of dat/index 
parts (file based database)  is it possible?
Yes. It's fairly easy to access the dat file on disk via a port! 
... as long as some port! bugs are corrected. Once ports are working 
correctly I'll add file support.
I'm looking forward to it
I've tested the length? function over port after inserting the port 
and it works well now, is there other bugs in fileports?
Sorry Update on port writes cannot update on port
RebDB question on REBOLforum:

Maybe it's late and my eyes are not working properly.
I am starting to use REBOLDB for REBOL2.0.

I have read the quickstart guide and now I know how to create a table 
but.. wait: How do I open the table at the next start of my script 
I cannot find a DB-OPEN function.
Also, I need to store DATE and TIME together and select rows greater 
than a DATE and TIME value. Does RebolDB support this ?
Any HELP for my problems ? I am stuck with a simple application.
I'm not a rebDB expert....So take my answers as something to be tested:

-- I don't think there is an explicit OPEN command. Simply access 
the table (with SELECT, INSERT, etc) to open it.  Similarly, no CLOSE 
-- use DB-COMMIT to ensure caches are flushed.

--rebDB supports REBOL datatypes. Have you tried creating a table 
row with a datetime in it? Did you have a problem?
Sunanda: you are right. DB il already available without opening it.
Also the function TO-DATE is able to convert from "15 nov 2010/11:30:15" 
to "15-nov-2010/11:30:15" without having to parse the string. Something 
not noticed from REBOL documentation.
(From Ashley on 5-Feb-10:)

All new RebDB v3 released for REBOL3. To take it for a spin, try 

import http://idisk.me.com/dobeash/Public/rebdb.r

when I try this I get an access error - reason: "not found or not 

Has RebDB v3 moved to a new location ?  Thanks!  Cannot wait to try 
it out.
Ashley: http://idisk.me.com/dobeash/Public/rebdb.rgives this error 
message: Account Error: Missing Data Volume
I've moved from MobileMe to DropBox since then.

import http://dl.dropbox.com/u/8269768/rebsm.r
help db-
test: db-load http://dl.dropbox.com/u/8269768/test.bin
help test
sql select test

I'm in the process of rebuilding my Dobeash site and will be adding 
this (and a few other goodies) along with documentation when done. 
No ETA, but it can live on dropbox until then.
thx, Ashley
what is the advised server / client setup? where should be the source, 
the data directory and the login.sql files for the server and the 
and the spool file... which is suggested to be called session.log 
but then it will be replayed by the commit * in login.sql if it's 
in the data directory..
if exists? login: join system/script/parent/path %login.sql [ client/run 
login ]

this would make more sense to me in SQL.r, so any directory with 
a login.sql could be either a server or client directory
it would also make more sense to call it init.sql and provide a client.sql 
and a server.sql as examples in the distribution
if im enabling the spool feature, i just get this error:
onetom ~/rebol/db $ rebdb
Replaying 9 change(s).
** Script Error: Out of range or past end
** Where: func [/local log][
the only way to restart the server is to
onetom ~/rebol/db $ rm ../rebdb/replay.bak ../rebdb/session.log
if i do a commit *, then the replay.bak won't exist, but the server 
will still try to execute the session.log, which results in fractional 
onetom ~/rebol/db $ rebdb
Replaying 4.5 change(s).
** Script Error: Out of range or past end
if i say set spool session.txt, then it works.. pretty confusing 
default. and i would expect the file created in the current directory, 
not where the db.r file is stored
and now i get
SQL> select * asd
asd has an open log file
commit asd doesn't help
Is there a protocol version of RedDB ? In order to use it under Cheyenne 
with database enhancement.
No, but it wouldn't be that hard to write a protocol wrapper replacement 
for the SQL function.
Cheyenne is able to run RSP and CGI scripts concurrently on several 
processes at the same time. AFAIK, RebDB does not do any locking 
on write access, it would be unsafe to use in the general case with 
Cheyenne. SQLite would be more resilient, but keep in mind that as 
it is locking the whole DB on each write access, it is not scalable.
The new(er) WAL (Write Ahead Logging) transaction mode reduces locking 
and increases concurrency -- http://sqlite.org/wal.html.
Seems that the SQL interpreter (SQL.r) do not support multi lines 
SQL> create table c2 [
** Syntax Error: Missing ] at end-of-script
** Near: (line 1) create table c2 [
Correct, it's just an 'ask loop (hence no semi-colon for command