HP 3000 Manuals

What Is a Relational Database? [ Up and Running with ALLBASE/SQL ] MPE/iX 5.0 Documentation


Up and Running with ALLBASE/SQL

What Is a Relational Database? 

A relational database is a collection of data arranged in tables, also
known as relations.  Tables are subject to the following relational 
operations, each of which lets you retrieve data in a specific way:

   *   Selection, which lets you extract a subset of rows.
   *   Projection, which lets you extract a subset of columns.
   *   Joining, which lets you extract from more than one table at a
       time.

In practice, these operations frequently appear together.  SQL statements
that use these operations are known as queries.  Three queries that use
the SQL SELECT command to illustrate selection, projection, and joining
are shown in Figure 1-1.

[]
Figure 1-1. Relational Operations Rows and Columns When you look at data in relational terms, you can assume several things: * Tables are arranged in rows and columns, which are like records and fields in an ordinary file. * Each column has a specific data type and size. * Each row contains one element for every column. * A column can contain NULL values if you allow it to. Sample Database Table The following is a portion of a database table consisting of names and account balances for an employee credit union: Employee Accounts ----------------------------------------------------------------------------------------------------- | | | | | | | Last Name | First Name | Telephone | Employee Number | Balance | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | Harrison | Gerald | 7233 | 2432099 | 142.59 | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | Abelson | Annette | 4312 | 3510044 | 2345.09 | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | Stanley | Peter | NULL | 3540011 | 321.98 | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | Walters | Georgia | 2554 | 9124772 | 1230.10 | | | | | | | ----------------------------------------------------------------------------------------------------- Notice that the third row contains a NULL value in the third column instead of a value for Telephone. Data Types and Sizes Each column can accept data of a specific type and size. Here is the breakdown for the sample table above: Column Name Data Type Last Name VARCHAR(15) First Name VARCHAR(15) Telephone SMALLINT Employee Number INTEGER Balance DECIMAL(10,2) Data types are described further in chapter 2. Using Several Tables You can put the same data into several different tables such as the following: Table 1. Employees Table ---------------------------------------------------------------------------------------------- | | | | | Last Name | First Name | Employee Number | | | | | ---------------------------------------------------------------------------------------------- | | | | | Harrison | Gerald | 2432099 | | | | | ---------------------------------------------------------------------------------------------- | | | | | Abelson | Annette | 3510044 | | | | | ---------------------------------------------------------------------------------------------- | | | | | Stanley | Peter | 3540011 | | | | | ---------------------------------------------------------------------------------------------- | | | | | Walters | Georgia | 9124772 | | | | | ---------------------------------------------------------------------------------------------- Table 2. Telephone Table ---------------------------------------------------------------------------------------------- | | | | | Last Name | First Name | Telephone | | | | | ---------------------------------------------------------------------------------------------- | | | | | Harrison | Gerald | 7233 | | | | | ---------------------------------------------------------------------------------------------- | | | | | Abelson | Annette | 4312 | | | | | ---------------------------------------------------------------------------------------------- | | | | | Stanley | Peter | NULL | | | | | ---------------------------------------------------------------------------------------------- | | | | | Walters | Georgia | 2554 | | | | | ---------------------------------------------------------------------------------------------- Table 3. Accounts Table --------------------------------------------------------------------------------------------- | | | | Employee Number | Account Balance | | | | --------------------------------------------------------------------------------------------- | | | | 2432099 | 142.59 | | | | --------------------------------------------------------------------------------------------- | | | | 3510044 | 2345.09 | | | | --------------------------------------------------------------------------------------------- | | | | 3540011 | 321.98 | | | | --------------------------------------------------------------------------------------------- | | | | 9124772 | 1230.10 | | | | --------------------------------------------------------------------------------------------- You decide which arrangements of data work best for you by using the processes of data analysis and database design. In data analysis, you investigate the various ways your data can be used. In database design, you create specific table structures based on your analysis. The design phase results in a set of table descriptions, sometimes known as a schema, for your database. Chapter 2 presents an introduction to data analysis and database design.


MPE/iX 5.0 Documentation