home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / database / p4w_all.zip / TI1492.ASC < prev    next >
Text File  |  1993-05-12  |  6KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Paradox for Windows                   NUMBER  :  1492
  9.   VERSION  :  1.0
  10.        OS  :  WIN
  11.      DATE  :  May 12, 1993                             PAGE  :  1/3
  12.  
  13.     TITLE  :  Normalizing a Non-normalized Paradox Table
  14.  
  15.  
  16.  
  17.  
  18.   This Technical Information Sheet demonstrates the best
  19.   interactive method for converting a non-normalized table into a
  20.   table in the first normal form.  In brief, a non-normalized table
  21.   is one in which repeating groups of information are spread out
  22.   over many fields, rather than placing them into a few fields with
  23.   many records.  For example, suppose you have a table which tracks
  24.   orders placed by a number of customers over a single year.  You
  25.   want this table to display the customer number and the number of
  26.   products purchased for each month.  For simplicity's sake, assume
  27.   the year only has three months (January, February, and March).
  28.  
  29.   Below is the non-normalized version of this table (OrdersA):
  30.  
  31.   OrdersA═╦═Customer #═╦═January═╦═February═╦═March═╗
  32.           ║   0001     ║   3     ║   7      ║   0   ║
  33.           ║   0002     ║   0     ║   1      ║   0   ║
  34.           ║   0003     ║   0     ║   0      ║  14   ║
  35.  
  36.   Below is the normalized version (the table is called OrdersB):
  37.  
  38.   OrdersB═╦═Customer #═╦═══Month═══╦═Quantity═╗
  39.           ║   0001     ║ January   ║      3   ║
  40.           ║   0001     ║ February  ║      7   ║
  41.           ║   0001     ║ March     ║      0   ║
  42.           ║   0002     ║ January   ║      0   ║
  43.           ║   0002     ║ February  ║      1   ║
  44.           ║   0002     ║ March     ║      0   ║
  45.           ║   0003     ║ January   ║      0   ║
  46.           ║   0003     ║ February  ║      0   ║
  47.           ║   0003     ║ March     ║     14   ║
  48.  
  49.   The first table is keyed on Customer # only.  All information
  50.   related to a single customer is stored in a single record with
  51.   many fields.  The second table is keyed on both Customer # and
  52.   Month.  Each customer has three records (twelve if you were
  53.   dealing with a full year), one for each month, and that month's
  54.   corresponding quantity.  It is necessary to perform a query or
  55.   possibly a series of queries to convert the data from the first
  56.   table to the normalized format of the second table.  To begin the
  57.   process, create a new table with the proper structure (one
  58.   structured like the OrdersB table).  Once this is done, set up
  59.   the query as shown on the next page:
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Paradox for Windows                   NUMBER  :  1492
  75.   VERSION  :  1.0
  76.        OS  :  WIN
  77.      DATE  :  May 12, 1993                             PAGE  :  2/3
  78.  
  79.     TITLE  :  Normalizing a Non-normalized Paradox Table
  80.  
  81.  
  82.  
  83.  
  84.   Bring up the tables, OrdersA and OrdersB, by choosing File | New
  85.   | Query, multi-selecting the tables OrdersA and OrderB
  86.   (Ctrl+click), and choosing OK.
  87.  
  88.   OrdersA═╦═Customer #═╦═January═╦═February═╦═March═══╗
  89.           ║ _Cust      ║ _Quant1 ║          ║         ║
  90.           ║ _Cust      ║         ║ _Quant2  ║         ║
  91.           ║ _Cust      ║         ║          ║ _Quant3 ║
  92.  
  93.  
  94.   OrdersB═╦═Customer #═╦═══Month═══╦═Quantity═╗
  95.   Insert  ║ _Cust      ║ January   ║ _Quant1  ║
  96.   Insert  ║ _Cust      ║ February  ║ _Quant2  ║
  97.   Insert  ║ _Cust      ║ March     ║ _Quant3  ║
  98.  
  99.   In the query forms above, example elements are represented by an
  100.   underscore "_" preceding the label of the example element (i.e.
  101.   _Cust and _Quant1).  Example elements are created by pressing
  102.   [F5] and then typing a label for the example element.  On row 1,
  103.   the insert query links the OrdersA Customer # field to the
  104.   OrdersB Customer # field (by the example element Cust) and the
  105.   OrdersA January Quantity field to the OrdersB Quantity field (by
  106.   the example element Quant1).  On row 2, the OrdersA Customer #
  107.   field is linked to the OrdersB Customer # field (by the example
  108.   element Cust) and the OrdersA February Quantity field is linked
  109.   to the OrdersB Quantity field (by the example element Quant2).
  110.   Use a new row for each field from the source that is being
  111.   inserted into the single target field.  For example, if the table
  112.   has a full year (twelve months), then the query would have twelve
  113.   rows of links.  The example element representing the quantity
  114.   must be different for each line in the query.  In this example,
  115.   the example elements are numbered (i.e. Quant1, Quant2, Quant3).
  116.   The key word "Insert" tells Paradox to insert new records in the
  117.   OrdersB table by copying the data from the OrdersA fields which
  118.   contain example elements (i.e., Cust and Quant1) to their
  119.   corresponding fields in OrdersB.
  120.  
  121.  
  122.   Notes:
  123.  
  124.      1.  This is a generic example, however, the concept is
  125.          applicable to any database in which the repeating fields
  126.          contain the same type of data.
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Paradox for Windows                   NUMBER  :  1492
  141.   VERSION  :  1.0
  142.        OS  :  WIN
  143.      DATE  :  May 12, 1993                             PAGE  :  3/3
  144.  
  145.     TITLE  :  Normalizing a Non-normalized Paradox Table
  146.  
  147.  
  148.  
  149.  
  150.      2.  After setting up the query, save it by choosing File |
  151.          Save.  To run the query, press [F8].  The technique
  152.          outlined in this Technical Information Sheet enables you
  153.          to use a non-normalized table for data-entry purposes and
  154.          to create a query to quickly convert the data to a
  155.          normalized version for reporting purposes.
  156.  
  157.      3.  For further discussion of the theory behind normalization,
  158.          refer to Technical Information Sheet 124.  For additional
  159.          information about queries, refer to Chapter 6 and 7 of the
  160.          User's Guide.
  161.  
  162.  
  163.   DISCLAIMER: You have the right to use this technical information
  164.   subject to the terms of the No-Nonsense License Statement that
  165.   you received with the Borland product to which this information
  166.   pertains.
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.