Re: Finding data in Euphoria databases

new topic     » goto parent     » topic index » view thread      » older message » newer message

ZNorQ wrote:
> 
> I have plans to make use of Euphoria's database.e (EuDB) archive, and I've 
> done some minor testing, but I haven't gotten around to really stress test
> it.
> 
> But I've come as far as to see how it is build up - using 'keys' and 'data'
> sections for each record.
> 
> Generally I create a key by using the db_table_size()+1 function, usually by
> adding some kind of prefix - like "COMP" for "COMPANIES", etc., but I found
> out that the database only have a built in search function on the key, and
> not the data itself.
> 
> This makes me think that in order to find information effectively in typical
> fields where people would search for information should really be part of
> the key..? AFAIK, keys can't be changed after it's creation (which I see as
> a good thing), which again would make it difficult to use since this
> information can't be corrected if any punching mistakes where made.
> 
> The only way I see to search for information in records data section now, 
> is to loop through each record and 'find'ing or 'match'ing each data section
> with what-ever one would need to search for.
> 
> }}}
<eucode>
> atom SearchIdx
> for cntrec = 1 to db_table_size() do
>   if   match("rds", db_record_data()) 
>   then SearchIdx = cnt
>        exit
>   end  if
> end for
> </eucode>
{{{

> 
> This is quite slow. Of course, one could limit the search by looking at
> the specific sequence element (field) taken from db_record_data() so that
> it dosen't search through the whole record, but it would still require the
> code to read the whole record before searching for the information.
> 
> Question 1;
>   Anyone got any experience using large amounts of data? How effective is
>   EuDB in finding, inserting and deleting records?
> 
> Question 2;
>   Finding; What solution do you use?
> 
> Kenneth

I've never used EUdb. But I have my own database system for keeping track of
movies for my store. Actually I have six dbs "open regular", "open adult", "open
dvds", "sold regular", "sold adult", and "sold dvds". I know I should have "open
reg dvds" and "open adult dvds" etc.
But at the time I set this up DVD's were a novilty not the norm as they are
today.
When I sell a movie I move it from "open" to "sold". If I buy back a movie I
  move it from "sold" to "open". Each db has a lot of fields starting with "movie
  number". Field number 11 has a variable length field with the history of each
  movie. Date bought, date sold, date rented etc. So it's a pretty extensive db.
  When I start my program I load all the dbs then I create an index by movie
  number. This takes a little while.

for x=1 to 6 do
 for y=1 to length(db[x]) do
  index[x]=append(index[x],db[x][y][1])
 end for
end for

Now I have an index of all my dbs by movie number. From then on when look up a
  movie I look up the movie number in the index which streers to the right db very
  quickly. However in the rare event that I have look up a movie by a string
  (example "Matrix") then I have to search all the fields. This, of course, takes
  longer. I could make an index of each field at start up. But then again this
  would take longer.

I think I see what you mean by pointers. This would entail using
  allocate_string() and keeping track of the pointers that way.

I doubt if this will be of any help to you but as to your question #2, that's
  how I do it.


Don Cole

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu