TENAGLIA@mis.mcw.edu (Chris Tenaglia - 257-8765) (05/31/91)
Regarding: Records > Thanks to all those who answered my query about records. > Next question - I am using records as the basis for a simple database > program. Given that the program will be written in a tight enough way to > ensure that it won't be possible to write a list with more elements than > there are in a database entry, what is the advantage of using a record > to store a database entry as opposed to a list? > I've got my own ideas on this, but I'd like to canvass a few other > opinions. > Thanks. > Roger Hare. Perhaps I don't understand the true use of records, or the true meaning of database. I wrote a useful little database. I call it 'AtterCop'. It's nomenclature and early evolution is too bizaare for this message. In it's first ICON manifestation it used lists. Lists worked well. If you wanted the data sorted, I had a menu entry that would ask for which fields. It was slow especially on inquiry serially scanning through the list elements. Deletion was slower. I moved all the elements back one to cover up the unwanted record and popped off the last element (duplicate). It permitted multiple occurences of the key, and printed pretty fast. Records? I always thought of records as ICONs method for creating user defined datatypes. I once thought it was a database component, but after a few experiments, it's true purpose became clear. Tables? After a database contains 1000 or so items, lists become very slow. So I rewrote 'AtterCop' using icon tables instead. The database key is a concatenated string from the key fields, is the index to the table. The entire record (string with fields delimited including the key ones) is a list element to that table entry. Thus the database is actually a table of lists. This still allows multiple occurences to a key, and lookup, and maintenance functions are handled quite speedily. Also, no explicit sort is needed. Sorting is done optionally at print or view time. Speed of loading, saving, printing seems to take a little longer though. See example. Writing out the database as a list Writing it as a table of lists out := open(database,"w") out := open(database,"w") every write(out,!db) every lookup := key(db) do every write(out,!db[lookup]) close(out) Chris Tenaglia (System Manager) | Medical College of Wisconsin 8701 W. Watertown Plank Rd. | Milwaukee, WI 53226 (414)257-8765 | tenaglia@mis.mcw.edu, mcwmis!tenaglia