BBS: Inland Empire Archive Date: 01-09-93 (04:15) Number: 343 From: WES GARLAND Refer#: NONE To: RICK NEWMAN Recvd: NO Subj: DATABASE STRUCTURE Conf: (2) Quik_Bas
Hi Rick!
RN> It's a recipe database. I have up to 50 recipes which will each need
RN> 5 or six fields within each record. In addition, each recipe will have
RN> an unlimited number of ingredients, which of course will each have a
RN> coresponding quantity and unit of measure. I'm currently trying to
RN> use TYPE's, which seems to make sense & is fairly easy to understand
RN> and use. However, there seems to be several ways to go regarding
RN> the way the recipes and the ingredients relate to each other. IE,
RN> should they all be in one huge array? If so, then I can't have an
RN> unlimited number of ingredients per recipe, can I?
RN> I could certainly use some of the expertise that is obviously on this
RN> conference! Can anyone offer some suggestions and/or help??
Due to the nature of random files with respect to your application, I would
NOT use them. Also, since you only need to access one
recipe at a time, I would not use an array with all of them
in memory. Why not try a linked list approach? From the
nature of recipes, I wouldn't recommend putting each
ingredient in a separate variable, WAAAAY too tedious. Why
not have the user enter each recipe into a nice little text
file of some sort,as long as they want, with nice
descriptions, etc. You could write something to spice it
up, or just use Q.EXE (or even QBASIC /EDIT, heh) or
something to type them in, and then store them.. A record
struct like this might help:
DEFINT A-Z
'INCLUDE$:'Everylib you have, to make compiling as slow as
possible' 'Insert evil, maniacal grin. :-)
TYPE RecipeType
Title as string * 30 ' Name of the recipe
KeyWord1 as string * 10 ' Keyword, like "moose" or "cashew"
KeyWord2 as string * 10 ' or "soup" or "pie", for searching
RecipeLen as integer ' Length of the text to imbed. End Type
Dim RecipeHeader as RecipeType
Dim Temp as string
Dim Str as string
Function TypeToStr$ (RHdr as RecipeType) ' Turns the type into a String,
' for easy BINARY file access
TypeToStr = RHdr.Title + RHdr.KeyWord1 + RHDir.Keyword2
+ mki$(RecipeLen) End Function
Sub StrToType (Str as String, RHdr as RecipeType) ' Turns the str into a type.
' Same reason as above :-)
RHdr.Title = left$(Str,30)
RHdr.KeyWord1 = mid$(Str,31,40)
RHdr.KeyWord2 = mid$(Str,41,50)
RHdr.RecipeLen = cvi(right$(Str,2))
End Sub
'======CONTINUED NEXT MESSAGE=======
--- Maximus 2.01wb
* Origin: Terminal Velocity Kingston *CANADA* (613)542-4613/6594, (1:249/128)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET