Tutorial:Programming
the SQL commands. The examples will
be based around Microsoft Access,
though the examples should also work
 The key concept of the relational model
with other implementations of SQL.
is that data sits in tables, and that data
Relational Databases
elements within different tables can be
Before we begin looking at SQL it 
self we ought to look more closely at
related in some way. 
what we mean by a database. Al 
though some people talk about  SQL
databases  there is in fact no such
thing. SQL itself makes no references
of structuring data which is mathe 
in the database has a number of fields
to the underlying databases which it
matically consistent and abstracted
which define the content and a number
can access, which means that it is pos 
away from the physical implementa 
of instances of that field   think of the
sible to have a SQL engine which can
tion of the database. The relational
fields as columns in a table and the
address relational databases, non rela 
model was quickly taken up and it
instances as rows. For example, if we
tional (flat) databases, even spread 
remains one of the most revolutionary
had a table of LAN users, then we
sheets programs. However, SQL is
of computer science concepts which
could have fields of first name, sur 
normally used to address a relational
spurred on an entire industry.
name and userID. The rows in such a
database, which is what many people
The key concept of the relational
table would contain the values which
class as a SQL database.
model is that data sits in tables, and
define each instance of user, for exam 
The relational model of a database
that data elements within different ta 
ple, the entry to define user John Smith
was first defined by Dr Ted Codd in
bles can be related in some way to
would be: John, Smith, JSmith.
1970, working at the IBM Research
provide
meaningful
information
A single table of LAN users does not
Labs at San Jose, and it describes a way
rather than just lists of data. Each table
provide us with very much, even
though it is more useful than no table
at all. However the user table becomes
immediately more useful when we
have other tables to which it can be
linked dynamically. Imagine that we
have a table of software products, with
fields of Product, Version, User Li 
cence and Product Code. Again this is
useful information, especially for in 
ventory purposes, but its value would
be magnified if we could create a rela 
tionship between the user table and the
software table. For example such a link
between these tables could be used to
record which users are licensed for
which software products. From this it
would be possible to find out how
many users are licensed to use product
X, or which products user Y is using.
Add a  department  field to the user
table, for example, and you could then
derive the relationship between de 
partmental software requirements and
the software that is licensed and so on.
Obviously there is much more to the
Figure 4   Creating a table in Access.
relational model than this, but as far as
SQL is concerned it is the concept of
tables, fields and relationships which
CREATE TABLE UserTable (FirstName TEXT, LastName TEXT,
is important. SQL is not a relational
UserID  TEXT, Dept TEXT, EmpNo INTEGER, PCType TEXT );
database, it is simply a data manipula 
tion language which uses some of the
concepts of relational databases to per 
Figure 5   Creating the UserTable table.
form its tasks.
File: T1125.2
Issue 108 (June 1999) page 18
PC Network Advisor
<  Next page  >
New! The best sites for quality inkjet printer cartridges and the best sites for cheap inkjet cartridges
Windows Help Desk Home