home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / DATABASE / BLTC17.ZIP / !Q&A.TXT < prev    next >
Encoding:
Text File  |  1993-08-31  |  7.7 KB  |  158 lines

  1. Questions & Answers
  2.  
  3. Q: What is BULLET?
  4.  
  5. A: BULLET is a library of program modules that together let the programmer
  6.    develop and create software that can manage huge amounts of data on
  7.    disk using the industry-standard DBF data file format. It also uses high-
  8.    speed b-tree index files to manage keyed data file access.
  9.  
  10.  
  11. Q: What compiler is BULLET for?
  12.  
  13. A: BULLET can be used by nearly all DOS compilers. It's written entirely in
  14.    assembly language. Because of this, it does not require any particular
  15.    programming language or compiler vendor. The 4 requirements are listed
  16.    in the !WHATIS.TXT file.
  17.  
  18.  
  19. Q: Why do I need BULLET when all I need to handle are small amounts of data?
  20.  
  21. A: BULLET can deal with a database as small as 1 record or as large as several
  22.    million. While your current needs may be small, your future needs are bound
  23.    to expand. BULLET can work with you now, and later, even if you switch
  24.    development platforms by moving to another compiler. And BULLET is fast,
  25.    it can deal with a database with millions of records as easily as it can
  26.    with just a few.
  27.  
  28.  
  29. Q: But b-tree stuff, isn't that hard?
  30.  
  31. A: Everything associated with maintaining the database, its data files and its
  32.    index files, is done behind-the-scenes by BULLET. You just specify how the
  33.    data record is to look by specifying the number of fields, their lengths and
  34.    types, and then specify how you want your index files to be based.
  35.  
  36.  
  37. Q: So how do I design my data record?
  38.  
  39. A: You probably have a pretty good idea, already. A good way to determine what
  40.    should go into a database is what you want to come out of it. For example,
  41.    if you're doing a mailing list program, you'll want to have at least the
  42.    name, perhaps broken into first name and last. Also you'll need the mailing
  43.    address--4 lines is usually enough, so you'll want 4 separate address line
  44.    fields. Then there's the State and ZIP, possibly even country. That's the
  45.    minimum. It would look something like this:
  46.  
  47.    FIRSTNAME field of 15 characters; LASTNAME field of 19 characters; ADDR1
  48.    field of 34 characters, ADDR2, ADDR3, ADDR4 as ADDR1; State field of 2
  49.    characters, and ZIP a field of 5 (or 9 if ZIP+4) characters. You could
  50.    specify the ZIP as a numeric field if you wanted.
  51.  
  52.    You'll notice that the longest field is 34 characters. Why? Because most
  53.    mailing labels are 3.5 inches, about 34 characters across. Since the first
  54.    name and last are usually put on the same line, their total should be 34.
  55.  
  56.    You'll probably want to add more fields like telephone number, last time
  57.    written to, oh, just about anything that you'd think would be important to
  58.    know. There you go, you've just designed your data record.
  59.  
  60.  
  61. Q: Then what?
  62.  
  63. A: Then decide how you need to access this data. You'll want to access it at
  64.    least by name, so one index you'll want is on the name. While you could
  65.    specify the entire name be used as a key, say LASTNAME+FIRSTNAME, this is
  66.    a bit of overkill. Instead, you may want to use just a portion of the name.
  67.    A good candidate would be SUBSTR(LASTNAME,1,5)+SUBSTR(FIRSTNAME,1,1). This
  68.    sets up a key that's only 6 bytes long. The first method, using all the
  69.    name, would be 34 bytes long. By keeping your keys short you'll keep your
  70.    index files small and your index performance high. And yes, you can also
  71.    mix numeric field types with character field types in your key expressions.
  72.  
  73.  
  74. Q: But what if I have two or more names that are identical, or very similar
  75.    but have these parts of the names the same?
  76.  
  77. A: BULLET lets you specify if your index files allow only unique key entries or
  78.    whether duplicate keys are permitted. When keying on a name you should have
  79.    your index file allow duplicate keys. What BULLET does is number these
  80.    identical keys by adding a suffix to each key (called an enumerator). This
  81.    enumerator allows the index algorithm to treat each key as a different key.
  82.    If you search the index for all matches in the first 6 characters of the
  83.    key (the enumerators will always be different) these similar names will
  84.    be found in consecutive order. To find out if the key you've just accessed
  85.    is the actual person you had in mind, you'd scan the data record associated
  86.    with that key for other information, such as middle initial, address,
  87.    anything that would make that person recognizable from another with a
  88.    similar key. If it isn't what you're looking for, get the next key and data
  89.    record, and so on until the first 6 characters of the key no longer are the
  90.    6 you're looking for.
  91.  
  92.  
  93. Q: So I've got my data record designed and also my primary index file. What
  94.    else should I do?
  95.  
  96. A: Now that the database is designed most of the "unknown" is taken care of.
  97.    What comes next depends on how you, yourself, program. What I often do
  98.    next is detail exactly what I want the output to be. That way, I've got
  99.    the front and the back and just need to do the middle. The middle is where
  100.    the fun's at. You'll be amazed at just how few of your in-the-middle coding
  101.    is spent on managing the database. BULLET takes care of all the little
  102.    details. You just need to give it the data and tell it what to do with
  103.    it. Or you tell it what to get and it comes back with what you requested.
  104.    You then do whatever you want with that data.
  105.  
  106.  
  107. Q: I've looked at the header file and it sure has a lot of commands. You're
  108.    telling me that this is simple?
  109.  
  110. A: Yes. Once you've created your data and index files, those mid-level
  111.    routines are not often used. Almost everything you do in your in-the-middle
  112.    coding will use the high-level routines. The InsertXB and UpdateXB routines
  113.    handle adding new or changing existing data, and the GetFirstXB, GetNextXB,
  114.    etc., routines handle getting the data. 90% of the time these are the
  115.    routines your program will be using.
  116.  
  117.  
  118. Q: What about all those packs? How can I keep them straight?
  119.  
  120. A: The good thing about modern programming langauges is that they let you
  121.    build reusable code. The ideal way to use BULLET is to build reusable
  122.    code objects in your programming langauge of choice and hide the down-and-
  123.    dirty aspects of dealing with the various packs in those objects. For
  124.    example, a create key routine could be written once and that object used
  125.    for all your other programming projects.
  126.  
  127.  
  128. Q: I think I'm getting the hang of it. What's next?
  129.  
  130. A: Jump in and start coding. You may want to look over, maybe even print out,
  131.    one of the example programs. The BC_LAI10.BAS is straight forward, try
  132.    that. If you have any questions, just pop-up CZ. It's all in there.
  133.  
  134.  
  135. Q: Sounds good. But, tell me, what is the first thing I'm likely to muff?
  136.  
  137. A: Nothing serious. Just make sure that your record structure in memory
  138.    reserves the first byte for the delete tag. Also, make sure that the field
  139.    descriptors you assigned when you created the data file match your in-memory
  140.    structure, i.e., if you've created a data file (using CreateDXB) with say, 3
  141.    fields, each 25 characters long, make sure that your in-memory structure is
  142.    also 3 fields, each 25 characters.
  143.  
  144.    Note: it is allowable to alias your physical fields but the total length
  145.    must match the total length of the DBF data record. (Alias meaning that
  146.    instead of using Field1[25], you use Field1a[13] and Field1b[12]. Be sure
  147.    you know what you're doing!
  148.  
  149.    Also, the transaction routines (InsertXB, UpdateXB, ReindexXB, and the
  150.    LockXBs) return a transaction index rather than a completion code. Be sure
  151.    to check the documentation for the routines.
  152.  
  153. Q: I'm off.
  154.  
  155. A: So am I, but be sure to...
  156.  
  157.    ...Read the manual! Until you do you can't take full advantage of BULLET.
  158.