www.virtual-world.com

PC Magazine

  PC Tech

SQL: The Universal Database Language

Introduction

What is SQL?

What is a Relational Database System?

Relational Model Basics

SQL and the Relational Model

Static and Dynamic SQL

SQL Tutorial

FIGURE 1: CREATE TABLE Syntax

SIDEBAR: What's in a Name?



X10.com - The SuperSite for Home Automation!

NextCard Internet Visa - Apply Now

 
  Category
Software

Related Stories
Handling Data with SQL
-- 11/17/98

Next: SQL and the Relational Model

SQL: The Universal Database Language
Relational Model Basics

Continued from What is a Relational Database System?

In the relational model, a relation is represented as a table of information. It has one or more attributes, which correspond to the columns of the table, and zero or more instances of data with those attributes (called n-tuples or simply tuples), which correspond to the rows (see the table "The Relational Model," below).

For any given tuple, the actual values of its attributes must be taken from the attributes' domains. A domain is essentially a data type that defines the set of all permissible values.

For example, assume there's a domain called "Days-of-the-week" that consists of "Monday" through "Sunday." If a relation had a single attribute of that domain called WEEKDAY, every tuple in the relation would have to contain one of those values in its WEEKDAY column. A WEEKDAY value of "January" or "Cat" wouldn't be allowed.

Notice that we said an attribute had to contain one of those values. It couldn't contain more than one. In addition to being constrained to a domain, attribute values have to be atomic. That is, they have to be elementary; they can't be broken down into smaller parts without losing their meaning. An attribute's value containing both "Monday" and "Tuesday" can be broken down into two parts that still represent days of the week, so that value is not atomic. But if you broke "Monday" down into smaller parts--the letters M through y--they wouldn't mean anything by themselves, so "Monday" is an atomic value.

Relations have other properties as well. Most important, they have the mathematical property of closure. That is, any operation performed on a relation yields another relation. This lets you perform mathematical operations on relations with predictable results. It also allows operations to be abstracted into variable expressions and nested.

In his original paper, Dr. Codd defined a collection of eight operators called relational algebra. Four of those operators, union, intersection, difference, and Cartesian product, were based on traditional set theory, but the rest were developed specifically for relations. Since then, Dr. Codd, Chris Date, and others have developed more operators. We'll discuss three of these relational operators--project, select (or restrict), and join--later in this article.

Next: SQL and the Relational Model

Published as PC Tech Feature in the 11/3/98 issue of PC Magazine.

Elsewhere on ZDNet
Learn SQL Online -- ZD University
Business Software: Databases -- ZD Products

 
 SPONSORED LINKS
@Backup   Your Solid Online Backup Plan. Download Now.
Services   9c/MINUTE LONG DISTANCE, 5c/MINUTE ON SUNDAYS!
STORAGE   Quantum means non-stop business, 24 hours a day
Software   X10.com -- The SuperSite for Home Automation
Books   Bargain Books up to 90% off at barnesandnoble.com
 ZDNET FEATURED LINKS
Downloads   Check out the best new downloads in Reviewer's Raves
Bargains!   Shop the Basement for best buys on computer products
Free Help   Got computing questions? ZDHelp has all the answers!
 MAGAZINE OFFERS
Free Offer   Get a FREE SUBSCRIPTION to Inter@ctive Week

TOP
Copyright (c) 1998 Ziff-Davis Inc.