Re: database theory

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

>>>>>
Easy one: write all records to the same, fixed length.
Let's say a name and address record is always 256 bytes long.
You want the 3rd name in the file, so you seek byte
(256 * 3), and read 256 bytes. This also makes updates
to the file easy, since you're just writing 256 new bytes
over 256 old.
<<<<<

Yes, but how would you know to seek the third one?  Let me think.  Well,
here.  How fast is this?

sequence last_name
last_name =3D ""
while last_name !=3D "Jordan" -- the name I'm trying to retrieve
    counter =3D 1
    seek(database,counter) -- database is an open file
    line =3D gets(database) -- line is a sequence
    index =3D find(',',line)
    last_name =3D line[1..index-1]
    counter =3D counter+80 -- line length, suppose
end while

Is this solution viable?  Is there a better way if I can use the "easy" w=
ay
you describe?  Thanks.

Alan

 =

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

Search



Quick Links

User menu

Not signed in.

Misc Menu