The basic unit of a relational database is a table: a two-dimensional structure whose rows represent individual "things" of some type and whose columns represent attributes of those things. Like members of a Java or C++ object, attributes can be references to other "things".

In a relational database, "things" can be things in an ordinary sense, such as cars or people. Tables containing attributes for such things are called entity tables. But part of the power of relational databases lies in relational tables that capture relationships between entities. For example, an ownership table can capture the ownership relation between people and cars. Each row in an ownership table has an owner (person) attribute and an owned entity (car) attribute.

The simplest use of a table is an entity table. It just captures attributes of a simple "thing". The attributes can be various types of data such as strings, integers, floating-point numbers, dates, and times.

A table can also represent relations between entities. Doing this requires that the entities have an id table column that uniquely identifies each row. Other tables can have entries called foreign references that refer to an appropriate row.

People are not easily classified in an object-oriented programming language. If you attempt to define classes or tables for different types of people (e.g. teachers, students, customers, employees, etc.) you quickly find problems:

These problems lead to significant problems in keeping database data up to date.

These problems are best handled by identifying roles for people rather than types. In the table structure below a customer is a person; an employee is also a person. The structure is similar to the implementation of inheritance in object-oriented languages. However, you can have the same person in both the customer and employee tables. You can also dynamically insert a person into or delete a person from either table in response to changing roles.

There are five tables in the Cars database:

They are diagrammed below.

Data is retrieved from a relational database with a SELECT query. A SELECT query returns a table constructed from the database tables, using a WHERE clause to impose conditions on the data. The ability to search multiple tables for data satisfying multiple conditions with a single query is a very powerful tool. Optimization techniques have been developed over SQL's 40 year history so that queries can be executed efficiently.

A WHERE clause typically begins with foreign reference conditions which ensure consistency of column data from multiple tables. This is illustrated in the following query. Each of the conditions in the WHERE clause just equates the two ends of a foreign reference (red arrows in the above diagram).

The table resulting from the above query has a row for each owner/car pair. Additional conditions in the WHERE clause can select a smaller number of rows. If the tables were enhanced with more columns such as "color" and "year" columns for the "car" table, additional WHERE clauses could limit the rows to information about cars with a specific description.

Forthcoming.