Re: Databases and Keys
- Posted by irvm at ellijay.com Dec 10, 2001
- 422 views
On Monday 10 December 2001 05:42 am, you wrote: > > Hi All, > I'm currently writting my own Music DB ........Alternativly how can I build many indexes. Guess I left off the part about how to build the indexes: Input the album data: UPC, {Album name, Artist name, {tracks...}} We'll call the main table CD: Open CD table, try to insert the record using UPC as the key, and the rest of the data as ..erm.. the data. If it fails, you already have that album in the database. Cope. Then, open the ARTIST table, and try to insert a record using the Artist name as the key, and the UPC as the data. If it fails, you already have another album by that artist, so you read that record (use db_find_key), append the new UPC to that record's data, and write it back using db_replace_data. Do the same with the ALBUM table, using the Album name as key, and UPC as data. Do the same with the TRACKS table, using the song name as the key, and the UPC as the data. Very, very quick., and doesn't take much space to store a LOT of UPC's. To look up a song title, for example; open the TRACKS table, use db_find_key with the song title as the key. If it returns a number > 0, then that song title exists in the db. Read that record; the data will contain 1 or more UPC's. each of which contains a track by that name. You can then open the main CD table, read the data for each of those UPC's and use it as you want. Same if you input an artist (you get a list of UPC's which are all albums by that artist), or an album title. No seeking, sorting or searching involved (except that which EDS does for you) Regards, Irv