home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / CONTRIB / MBASE / MBASE50.TAR / mbase / sample / sample.s < prev   
Encoding:
Text File  |  1992-11-21  |  1.5 KB  |  35 lines

  1. relation sample
  2.  
  3. #
  4. #  Each customer at a store, for example, has one record in this relation--the
  5. #  record contains their name and a customer code (assigned by the system, with
  6. #  the first customer being 100), their balance and number of purchases made,
  7. #  the date and time the record was established, and a 3-character string that
  8. #  describes whether or not they're allowed credit at the store.
  9. #
  10.  
  11. field custname type string length 30; # A fairly short name field, but hey...
  12. field custnum  type serial start 100; # Assigned automatically (from 100)
  13. field balance  type money;            # Standard double, to .XX resolution
  14. field date_en  date;                  # Date customer entered into database
  15. field time_en  type time;             # Time customer entered into database
  16. field credit   char * 3;              # "y"/"n"/"?" etc.
  17. field num      ushort;                # Number of purchases customer has made
  18. field phone    type phone;            # Phone number of client
  19.  
  20. index ix_name    on custname with duplicates;
  21. index ix_number  on custnum;
  22. index ix_balance on balance            with duplicates;
  23. index ix_entered on date_en, time_en   with duplicates;  # DATE_EN FIRST!!!
  24.  
  25. #
  26. # Why date_en first?  Because a composite index, like ix_entered, will
  27. # sort merrily along the first field you give it... as soon as it finds two
  28. # records which have the same first field, it'll sort 'em by the second.  So
  29. # ix_entered will sort things by date, and when the date's the same, by time..
  30. # if you did it the other way around, it'd be a pretty stupid index.
  31. #
  32.  
  33. end
  34.  
  35.