home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 6 / 06.iso / a / a610 / 6.ddi / DEMO / FGL / CREATE.4GL < prev    next >
Encoding:
Text File  |  1989-12-08  |  3.1 KB  |  98 lines

  1. MAIN
  2. {
  3. The create program creates the database tables that the leads
  4. program uses.  It also documents their structure.
  5. }
  6. CREATE DATABASE leads
  7.  
  8. CREATE TABLE contact
  9. {
  10. Each row in this table summarizes a contact with a prospect.
  11. }
  12.    (
  13.    cdate             DATE,
  14.    empnum            SMALLINT,   {Can join with sperson.empnum}
  15.    ndate             DATE,
  16.    nemp              SMALLINT,   {Can join with sperson.empnum}
  17.    notes             CHAR (50),
  18.    ctype             CHAR (1),   {C = complaint
  19.                                   I = request for information
  20.                                   Q = inquiry
  21.                                   S = sale}
  22.    ref               INTEGER,    {Can join with prospect.ref}
  23.    cnum              SERIAL      {Can join with sale.cnum}
  24.    )
  25. CREATE INDEX i_cref ON contact(ref)
  26. CREATE UNIQUE INDEX i_ccnum ON contact(cnum)
  27.  
  28. CREATE TABLE prospect
  29. {
  30. This table contains information on the prospect
  31. (both the person and the company).
  32. }
  33.    (
  34.    fname               CHAR (15),
  35.    lname               CHAR (15),
  36.    title               CHAR (6),   {letter title: Mr., Ms., Dr., etc.}
  37.    company             CHAR (40),
  38.    add1                CHAR (40),
  39.    add2                CHAR (40),
  40.    add3                CHAR (40),
  41.    city                CHAR (40),
  42.    state               CHAR (2),
  43.    zip                 CHAR (5),
  44.    phone               CHAR (12),
  45.    source              CHAR (1),   {B = binder weekly
  46.                                     N = newspaper
  47.                                     O = other
  48.                                     P = binder production news
  49.                                     R = radio}
  50.    ref                 SERIAL      {This column is for the use of the program;
  51.                                     the user never sees it.
  52.                                     Can join with contact.ref}
  53.    )
  54. CREATE UNIQUE INDEX i_pref ON prospect(ref)
  55.  
  56. CREATE TABLE sale
  57. {
  58. Each contact that generates a sale references a row in this table
  59. }
  60.    (
  61.    cnum              INTEGER,    {Can join with contact.cnum}
  62.    pcode             CHAR (10),  {Can join with product.pcode}
  63.    quantity          SMALLINT,
  64.    discount          SMALLINT    {stored as an integer 1-99}
  65.    )
  66.  
  67. CREATE TABLE sperson
  68. {
  69. Information on each salesperson is kept in this table.  The address and
  70. phone are that of the salesperson's business location.
  71. }
  72.    (
  73.    empnum            SMALLINT,   {Can join with contact.empnum or
  74.                                   Can join with contact.nemp}
  75.    position          CHAR (25),
  76.    lname             CHAR (15),
  77.    fname             CHAR (15),
  78.    add1              CHAR (40),
  79.    add2              CHAR (40),
  80.    add3              CHAR (40),
  81.    city              CHAR (40),
  82.    state             CHAR (2),
  83.    zip               CHAR (5),
  84.    phone             CHAR (12)
  85.    )
  86. CREATE UNIQUE INDEX i_sempnum ON sperson(empnum)
  87.  
  88. CREATE TABLE product
  89.    (
  90.    pcode             CHAR (10),  {Can join with sale.pcode}
  91.    price             MONEY(6),
  92.    descrip           CHAR (30)
  93.    )
  94. CREATE UNIQUE INDEX i_ppcode ON product(pcode)
  95.  
  96. GRANT CONNECT TO PUBLIC
  97. END MAIN
  98.