1 Introduction to Query
The information stored in the database depends upon the use of the database. Throughout this manual, a sales analysis example is used. This is only an example to show you how to work with the database. After you have read this first section, ask your manager or the person in charge of the computer system what information your database stores.
Figure 1 Example Data Items
Thus the first data item uses the first line and the second data item uses the next two lines. Note that cards are not really used for storage. This is only an example to help you visualize data items.
When it becomes necessary to find the card which contains the customer Jon Doe, you need a way to specify which line on each card is to be searched. Consequently, each data item is assigned a name and length. For example, the first data item might be named "customer" and have a length of one line. (When stored in the database, the length is actually specified as a number of characters or digits.)
Figure 2 Data Entry Example
The figure shows a data entry that consists of 13 data items.
A collection of data sets is called a database. The data sets in a database are usually linked together. For example, a second data set in the Sales Analysis database contains the data items ORDER_NO, OPTION_DESC, OPTION_PRICE and OPTION_TYPE; this data set is referred to as the OPTION data set. Because the information in this data set may be wanted with the information in the customer data set, the two are linked together through a third data set, ORDER, which has one data item ORDER_NO. This link from one data set to another is called a data path.
The data item which is linked is called a key item.
Now assume the customer specifies two options on the same order. This would cause the option data set to have two entries with the same order number. These entries are also linked through the key item. This link, within a data set, is called a data chain.
Figure 5 Example Data Chain
In a master data set, there is only one data entry for each key item value. There may be up to 16 data paths from this key item.
In a detail data set, there may be more than one data entry for each key item value. There may be up to sixteen key items in a data entry. For every value of a key item in a detail data set, there is a corresponding value in its associated master data set.
For example, the order data set has one data entry for each ORDER_NO value. The option data set has two data entries for ORDER_NO 0001. Since there is a value of 0001 in the option data set ORDER_NO data item, there must be a value of 0001 in the order data set ORDER_NO data item. However, there does not have to be the same value in the customer data set.
There are two types of master data sets. The automatic master data set contains one data item which is a key item. When a new value is added to the same key item in a detail data set, the value is automatically added to the automatic master data set. Deletions from the automatic master data set are made when the last data entry with a particular key item value is deleted from the detail data set.
The manual master data set contains one or more data items, one of which is a key item. Before a new key item value can be added to a detail data set that is linked to a manual master data set, the value must be first added to the manual master data set.
The following is a diagram of the Sales Analysis database showing the data paths between master and detail data sets.
Figure 6 Sales Analysis Database