Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: REBOL Relational Object-oriented Database

From: gjones05:mail:orion at: 21-Jun-2001 17:22

Hi, Louis, All questions are welcomed, in my opinion, but your was asking for a lot in one chunk. ;-) Furthermore, it is possible that you might have offended some of us lowly list members by asking for responses only from the "The Creator" (of REBOL, that is ;-). The following may be of some help, but the answers are a bit terse. Feel free to ask for further clarification if it makes no sense. From: "Dr. Louis A. Turk"
> 1. How can a field in a record be edited (not just replaced)? Carl, a > function please.
***old version*** change-data: func [email-old email-new /local record] [ record: find database email-old if none? record [alert reform ["Missing record:" email-old] exit] insert clear first record email-new ; See note in feature #6 above. ] ***new version change-data: func [email-old email-new /local record] [ record: find database email-old if none? record [alert reform ["Missing record:" email-old] exit] record/1: email-new ; See note in feature #6 above. ]
> 2. What is the purpose of the 2 in the remove-data function?
The 'find returns an index to the record. The refinement /part on 'remove says to remove from the index position to the length of 2, which removes the email address and the record.
> 3. Every time the insert-data function is called a box opens asking me for > permission to write to disk. How do I prevent this in such a way as to not > open my computer up for possible invasion? (Later: well, its not asking me > now, but I don't know why.)
REBOL security defaults to allowing local file read operations, but it requests permission to write a file locally. When the program needs to write to a local file, it will request permission. If you click "yes", then only the single write operation will occur. If you click "Allow All" then it will no longer ask each time. If your program and datafile are in a *non-shared* directory on your computer, then there is no risk of someone tapping into your computer. What constitutes a non-shared directory depends on the platform. There are different ways to change the default levels, depending on how the script will be used.
> 4. How do I print out a list of all or some of the fields in all of the > records (say for a report)? I am using probe right now so I can at least > see what is in the database, but I need formatted reports.
forskip database 2 [ print ["Email: " database/2/email] print ["Name: " database/2/name] print ["Phone: " database/2/phone] print ["Web URL: " database/2/web] ]
> 5. How can this database be related to a second database by say the phone > number field? How can the data from both databases be accessed at once?
Say the second database has a structure like phone and type (meaning "Home", Work , etc), then assume the phone number is stored as a string (do to local differences). Complete phone numbers are unique by definition, so a second database could be structured as a simple block with alternating values of numbers and types, like: ["01-713-555-1212" "Work" "01-713-555-2121" "Home"] A simple 'select using the phone number field will return the phone location type on this table (just like you used email address to look up a full record on the first). Using related tables does sort of violate the idea behind an object oriented database, though. :-) REBOL is flexible enough to allow this type of information to be further embedded within a record, but might add a bit of complexity though, depending on how it is implemented.
> 6. How can data be exported from a database as a comma separated file.
write %/path/to/my-csv-file "" ;to get fresh file emit: func [blk] [repend blk] forskip database 2 [ csv-line: make string! 1000 emit [{"} database/2/email {","} database/2/name {","} database/2/phone {","} database/2/web {"^/}] write/append %/path/to/my-csv-file csv-line ]
> 7. How can data be imported into a database from a comma separated file.
foreach line read/lines %/path/to/my-csv-file [ foreach [email name phone web] parse line none [ email: to-email trim email trim name trim phone web: to-url trim web ;;;;;then insert fields into a database ] ]
> 8. What is the maximum number of records practical to search with REBOL on > a computer with 512 MB of RAM? With 20,000 records or so what would > performance be like?
Assuming a somewhat fast processor (500 MHZ) and the database block is made into a hash, performance should be quite tolerable for a single user up into this range of size.
> 9. How can I get instant action upon pressing a key (say for a menu > choice), without having to also hit the enter key? I hate to have to hit 2 > keys when hitting one would work just as well.
I don't know this one!! Hope this helps. --Scott Jones