1.3.
4 Instances and Schemas
Databases change over time as information is inserted and
deleted. The collection of information stored in the database
at a particular moment is called an instance of the
database. The overall design of the database is called the
database schema. The concept of database schemas and
instances can be understood by analogy to a program
written in a programming language. A database schema
corresponds to the variable declarations (along with
associated type definitions) in a program. Each variable has
a particular value at a given instant. The values of the
variables in a program at a point in time correspond to an
instance of a database schema.
Database systems have several schemas, partitioned
according to the levels of abstraction. The physical
schema describes the database design at the physical
level, while the logical schema describes the database
design at the logical level. A database may also have
several schemas at the view level, sometimes called
subschemas, that describe different views of the database.
Of these, the logical schema is by far the most important
in terms of its effect on application programs, since
programmers construct applications by using the logical
schema. The physical schema is hidden beneath the
logical schema and can usually be changed easily
without affecting application programs. Application
programs are said to exhibit physical data independence if
they do not depend on the physical schema and thus need
not be rewritten if the physical schema changes.
Page 13
We also note that it is possible to create schemas that
have problems, such as unnecessarily duplicated
information. For example, suppose we store the department
budget as an attribute of the instructor record. Then,
whenever the value of the budget for a department (say the
Physics department) changes, that change must be
reflected in the records of all instructors associated with the
department. In
Chapter 7, we shall study how to distinguish
good schema designs from bad schema designs.
Traditionally, logical schemas were changed infrequently, if
at all. Many newer database applications, however, require
more flexible logical schemas where, for example, different
records in a single relation may have different attributes.
1.4 Database Languages
A database system provides a data-definition language
(DDL) to specify the database schema and a data
manipulation language (DML) to express database
queries and updates. In practice, the data-definition and
data-manipulation languages are not two separate
languages; instead they simply form parts of a single
database language, such as the SQL language. Almost all
relational database systems employ the SQL language,
which we cover in great detail in
Chapter 3,
Chapter 5.
1.4.1 Data-Definition Language
Chapter 4, and
We specify a database schema by a set of definitions
expressed by a special language called a data-definition
language (DDL). The DDL is also used to specify additional
properties of the data.
We specify the storage structure and access methods used
by the database system by a set of statements in a special
type of DDL called a data storage and definition
language. These statements define the implementation
details of the database schemas, which are usually hidden
from the users