Datasheet
Part I SQL Basic Concepts and Principles
The common misconception is that the term ‘‘relational’’ comes from the relation-
ships between tables. In fact, the word ‘‘relation’’ is a mathematical term that can be
conditionally interpreted as ‘‘table.’’
Tables
A table is a basic building unit of the relational database. It is a fairly intuitive way of organiz-
ing data and has been around for centuries. A table consists of rows and columns (called records
and fields in nonrelational database jargon). Each table has a unique name in the database — this
must be a unique fully qualified name that includes schema or database name as a prefix.
The dot (.) notation in a fully qualified name is commonly used in the programming
world to describe hierarchy of the objects and their properties. This could refer not
only to the database objects but also to the structures, user-defined types, and such. For example,
a table field in a Microsoft SQL Server database could be referred to as
ACME.DBO.CUSTOMER.
CUST
ID N where ACME is a database name, DBO is the table owner (Microsoft standard), CUSTOMER
is the name of the table, and CUST ID N is the column name in the CUSTOMER table.
See Chapter 4, ‘‘Creating RDBMS Objects’’ for more information on table and other
database
object names.
Each field has a unique name within the table, and every table must have at least one field.
The number of fields per table is usually limited, the actual limitation being dependent on a
particular implementation. Unlike legacy database structure, records in a table are not stored
or retrieved in any particular order. Although records can be arranged in a particular order by
means of using a clustered index (discussed in Chapter 4, ‘‘Creating RDBMS Objects’’), the task
of sorting the record in an RDBMS is relegated to SQL.
A record is composed of a number of cells, where each cell has a unique name and might
contain some data. A table that has no records is called an empty table.
Data within the field must be of the same type — for example, the field
AMOUNT contains only
numbers, and the field
DESCRIPTION contains only words. The set of the data within one field
is said to be a column’s domain.
Early databases — relational or otherwise — were designed to contain only text data.
Modern databases store anything that could be converted into binary format: pic-
tures, movies, audio records, and so on.
Good relational design would make sure that such a record describes an entity — another rela-
tional database term to be discussed later in the book but worth mentioning here. To put it in
other words, the record should not contain irrelevant information: for example, the
CUSTOMER
table deals with the customer information only, so its records should not contain information
about, say, products that this customer ordered.
16