1.1. What Is a Database?

A database (DB) is a collection of data items of a certain type that are stored either in the main memory of a computer or on a storage medium such as a hard disk or a solid state drive. In addition to the stored data items (the DB's content), a DB may also have a data dictionary, which contains the database schema defining the structure of the DB and its data items on the basis of an underlying set of elementary datatypes.

The stored data items are meaningful to the users of the DB. For instance, if the data items are binary large objects representing digital images, they can be presented to a DB user as an image on a computer screen such that the user is able to view and interpret the image. When the data items are records, they can be collectively presented to a DB user in a table or individually in a form consisting of data fields such that the user can interpret the field contents as information about an entity like a person or a bank account.

There are many different types of databases, distinguished by contents or by technologies. Examples of different DB types by contents are: phone number directories, image databases, and financial databases. Examples of different DB types by technologies are: Key-Value Stores, Relational Databases, Multi-Media Databases, XML Databases, Document Stores and Object Databases. There is a standard database programming language for relational databases: the Structured Query Language (SQL).

A phone number directory represents a key-value store. The names of people are the keys for looking up their phone numbers, which are the values associated with these keys. A key-value store can be presented in the form of a single table with just two columns: the first one for the keys and the second one for their values, such that each row represents a key-value pair, as shown in Table 1-1 below.

Table 1-1. A phone number directory as an example of a key-value store.
NamePhone number
Bob Jennings(732) 516-8970
Jane Anselm(732) 516-4301
Tara Helms(504) 972-3381
Tom Miller(282) 664-9357

A financial database, containing data about bank accounts and their owners, is typically implemented as a Relational Database (RDB), which manages the different types of data (here: accounts and account owners) using different database tables.

An RDB can be presented in the form of a set of tables, as shown in Figure 1-1, such that certain columns (normally the first column of a table) contain the primary keys that identify an entity represented by a table row. Often the primary key is provided by a special column called "ID", which contains numbers that are internal identifiers, as in the tables shown in Figure 1-1 below.

Figure 1-1. A relational database with two tables: People and Movies.