Chapter 2 Database Terms and Concepts

Relational database concepts

A relational database management system (RDBMS) stores and retrieves data that is represented in tables. A relational database consists of a collection of tables that store interrelated data.

This section introduces some of the terms and concepts that are important in talking about relational databases.

Database tables

In a relational database, all data is held in tables, which are made up of rows and columns.

Each table has one or more columns, and each column is assigned a specific datatype, such as an integer number, a sequence of characters (for text), or a date. Each row in the table has a value for each column.

A typical fragment of a table containing employee information may look as follows:













The tables of a relational database have some important characteristics:

The following table lists some of the formal and informal relational database terms describing tables and their contents, together with their equivalent in other nonrelational databases. This manual uses the informal terms.

Formal relational term

Informal relational term

Equivalent nonrelational term










When you are designing your database, make sure that each table in the database holds information about a specific thing, such as employees, products, or customers.

By designing a database this way, you can set up a structure that eliminates redundancy and inconsistencies. For example, both the sales and accounts payable departments may look up information about customers. In a relational database, the information about customers is entered only once, in a table that both departments can access.

A relational database is a set of related tables. You use primary and foreign keys to describe relationships between the information in different tables.

Primary and foreign keys

Primary and foreign keys define the relational structure of a database. These keys enable each row in the database tables to be identified, and define the relationships between the tables.

Tables have a primary key

All tables in a relational database should have a primary key. The primary key is a column, or set of columns, that allows each row in the table to be uniquely identified. No two rows in a table with a primary key can have the same primary key value.

If no primary key is assigned, all the columns together become the primary key. It is good practice to keep your primary key for each table as compact as possible.


In a table holding information about employees, the primary key may be an ID number assigned to each employee.

In the sample database, the table of sales order items has the following columns:

To identify a particular item, both the order number and the line number are required. The primary key is made up of both these columns.

Tables are related by foreign keys

The information in one table is related to that in other tables by foreign keys.


The sample database has one table holding employee information and one table holding department information. The department table has the following columns:

To find the name of a particular employee's department, there is no need to put the name of the employee's department into the employee table. Instead, the employee table contains a column holding the department ID of the employee's department. This is called a foreign key to the department table. A foreign key references a particular row in the table containing the corresponding primary key.

In this example, the employee table (which contains the foreign key in the relationship) is called the foreign table or referencing table. The department table (which contains the referenced primary key) is called the primary table or the referenced table.

Other database objects

A relational database holds more than a set of related tables. Among the other objects that make up a relational database are:


Retrieve data from a database using the SELECT statement. The basic query operations in a relational system are projection, restriction, and join. The SELECT statement implements all of these operations.

A projection is a subset of the columns in a table. A restriction (also called selection) is a subset of the rows in a table, based on some conditions.

For example, the following SELECT statement retrieves the names and prices of all products that cost more than $15:

SELECT name, unit_price
FROM product
WHERE unit_price > 15

This query uses both a restriction (WHERE unit_price > 15) and a projection (SELECT name, unit_price)

A JOIN links the rows in two or more tables by comparing the values in key columns and returning rows that have matching values. For example, you may want to select the item identification numbers and product names for all items for which more than a dozen has been shipped:

FROM product KEY JOIN sales_order_items
WHERE sales_order_items.quantity > 12

The product table and the sales_order_items table are joined together based on the foreign key relationships between them.

Other SQL statements

You can do more with SQL than just query. SQL includes statements that create tables, views, and other database objects. It also includes statements that modify tables and commands that perform many other database tasks discussed in this manual.

The system tables

Every database contains a set of system tables, which are special tables that the system uses to manage data and the system. These tables are sometimes called the data dictionary or the system catalog.

System tables contain information about the database. You never alter the system tables directly in the way that you can alter other tables. The system tables hold information about the tables in a database, the users of a database, the columns in each table, and so on. This information is data about data, or metadata.


Copyright © 2000 Sybase, Inc. All rights reserved.