old-www/HOWTO/Sybase-ASA-HOWTO/intro.html

1226 lines
18 KiB
HTML

<HTML
><HEAD
><TITLE
>Introduction</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.63
"><LINK
REL="HOME"
TITLE="Sybase Adaptive Server Anywhere for Linux HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="Sybase Adaptive Server Anywhere for Linux HOWTO"
HREF="index.html"><LINK
REL="NEXT"
TITLE="Requirements"
HREF="requirements.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Sybase Adaptive Server Anywhere for Linux HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="index.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="requirements.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="INTRO"
>1. Introduction</A
></H1
><P
>This HOWTO guides you through the installation of SQL Anywhere
Studio 7.0.2 for Linux and the basic operation and administration
of Adaptive Server Anywhere databases.</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN26"
>1.1. New versions of this document</A
></H2
><P
>The latest version of this document should always be available
at the Linux Documentation project website (<A
HREF="http://www.linuxdoc.org/"
TARGET="_top"
>http://www.linuxdoc.org/</A
>).</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN30"
>1.2. Content and Audience</A
></H2
><P
>Within this document, you will find a list
of the supported Linux distributions ("<A
HREF="requirements.html"
>Section 2</A
>").
It is intended for moderately
experienced users of Linux or UNIX. Familiarity with relational
database concepts is certainly useful, but not a requirement.
"<A
HREF="intro.html#DBCONCEPTS"
>Section 1.5</A
>"
contains a summary of relational database concepts. </P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN35"
>1.3. Adaptive Server Anywhere features</A
></H2
><P
>Adaptive Server Anywhere (Adaptive Server Anywhere) is the
full SQL relational database management system at the heart of SQL
Anywhere Studio. Ideally suited for use as an embedded database,
in mobile computing, or as a workgroup server, it includes the following among
its features: </P
><P
></P
><UL
><LI
><P
>Economical hardware requirements </P
></LI
><LI
><P
>Designed to operate without administration</P
></LI
><LI
><P
>Designed for mobile computing and synchronization</P
></LI
><LI
><P
>Ease of use</P
></LI
><LI
><P
>High performance</P
></LI
><LI
><P
>Cross-platform solution</P
></LI
><LI
><P
>Standalone and network use</P
></LI
><LI
><P
>Industry standard interfaces</P
></LI
></UL
><P
>Some of the more specific features include: </P
><P
></P
><UL
><LI
><P
>Stored procedures and triggers </P
></LI
><LI
><P
>Java support for logic and datatypes </P
></LI
></UL
><P
>For further details about Adaptive Server Anywhere, please
visit the following links:</P
><P
></P
><UL
><LI
><P
><A
HREF="http://www.sybase.com/detail/1,3693,1002624,00.html"
TARGET="_top"
>http://www.sybase.com/detail/1,3693,1002624,00.html</A
> is
a datasheet on SQL Anywhere Studio. It includes some data on
Adaptive Server Anywhere, which ships as a component of SQL Anywhere
Studio. </P
></LI
><LI
><P
><A
HREF="http://www.sybase.com/detail/1,3693,1009210,00.html"
TARGET="_top"
>http://www.sybase.com/detail/1,3693,1009210,00.html</A
>
has some information on the features and system requirements of
SQL Anywhere Studio and points you to the download location for
SQL Anywhere Studio for Linux 7.0. </P
></LI
></UL
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN69"
>1.4. Quirks</A
></H2
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN71"
>1.4.1. Alt and Function keys</A
></H3
><P
>Sometimes the Alt keys or the F1-F10 keys may not function
in the terminal where you are running Interactive SQL. </P
><P
>To emulate the Alt key, press Ctrl-A. Then press whatever
key was to be pressed with the Alt key. For example, instead of
pressing Alt-F, you would press Ctrl-A, then F. </P
><P
>To emulate the function keys, press Ctrl-F, followed by the
number of the function key you wanted to press. For example, instead
of pressing F9, you would press Ctrl-F, then 9. For F10, use the
zero key. </P
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="DBCONCEPTS"
>1.5. What's a Relational Database?</A
></H2
><P
>If you are already familiar with relational databases, you
can skip this section. </P
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN79"
>1.5.1. Definition</A
></H3
><P
>A <EM
>relational database-management system</EM
> (RDBMS)
is a system for storing and retrieving data, in which the data is
organized in tables. A relational database consists of a collection
of tables that store interrelated data. </P
><P
>If that doesn't quite make sense yet, read on. </P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN84"
>1.5.2. Example</A
></H3
><P
>Suppose you have some software to keep track of sales orders,
and each order is stored in the form of a table, called sales_order.
It has information about the customer (for example, her name, address
and phone number), the date of the order, and information about
the sales representative (for example his name, department, and
office phone number). Let's put all this into a table, with the
data for a few orders: </P
><DIV
CLASS="TABLE"
><A
NAME="AEN87"
></A
><P
><B
>Table 1. The sales_order
table</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
WIDTH="89"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>cust_name</EM
></TD
><TD
WIDTH="128"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>cust_address</EM
></TD
><TD
WIDTH="168"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>cust_city_state_zip</EM
></TD
><TD
WIDTH="104"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>cust_phone</EM
></TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>order_date</EM
></TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>emp_name</EM
></TD
><TD
WIDTH="80"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>emp_dept</EM
></TD
><TD
WIDTH="97"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>emp_phone</EM
></TD
></TR
><TR
><TD
WIDTH="89"
ALIGN="LEFT"
VALIGN="TOP"
>M. Devlin</TD
><TD
WIDTH="128"
ALIGN="LEFT"
VALIGN="TOP"
>3114 Pioneer Ave.</TD
><TD
WIDTH="168"
ALIGN="LEFT"
VALIGN="TOP"
>Rutherford, NJ 07070</TD
><TD
WIDTH="104"
ALIGN="LEFT"
VALIGN="TOP"
>2015558966</TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
>19930316</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>R. Overbey</TD
><TD
WIDTH="80"
ALIGN="LEFT"
VALIGN="TOP"
>Sales</TD
><TD
WIDTH="97"
ALIGN="LEFT"
VALIGN="TOP"
>5105557255</TD
></TR
><TR
><TD
WIDTH="89"
ALIGN="LEFT"
VALIGN="TOP"
>M. Devlin</TD
><TD
WIDTH="128"
ALIGN="LEFT"
VALIGN="TOP"
>3114 Pioneer Ave.</TD
><TD
WIDTH="168"
ALIGN="LEFT"
VALIGN="TOP"
>Rutherford, NJ 07070</TD
><TD
WIDTH="104"
ALIGN="LEFT"
VALIGN="TOP"
>2015558966</TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
>19940405</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>M. Kelly</TD
><TD
WIDTH="80"
ALIGN="LEFT"
VALIGN="TOP"
>Sales</TD
><TD
WIDTH="97"
ALIGN="LEFT"
VALIGN="TOP"
>5085553769</TD
></TR
><TR
><TD
WIDTH="89"
ALIGN="LEFT"
VALIGN="TOP"
>J. Gagliardo</TD
><TD
WIDTH="128"
ALIGN="LEFT"
VALIGN="TOP"
>2800 Park Ave.</TD
><TD
WIDTH="168"
ALIGN="LEFT"
VALIGN="TOP"
>Hull, PQ K1A 0H3</TD
><TD
WIDTH="104"
ALIGN="LEFT"
VALIGN="TOP"
>8195559539</TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
>19940326</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>M.Garcia</TD
><TD
WIDTH="80"
ALIGN="LEFT"
VALIGN="TOP"
>Sales</TD
><TD
WIDTH="97"
ALIGN="LEFT"
VALIGN="TOP"
>7135553431</TD
></TR
><TR
><TD
WIDTH="89"
ALIGN="LEFT"
VALIGN="TOP"
>E. Peros</TD
><TD
WIDTH="128"
ALIGN="LEFT"
VALIGN="TOP"
>50 Market St.</TD
><TD
WIDTH="168"
ALIGN="LEFT"
VALIGN="TOP"
>Rochester, NY 14624</TD
><TD
WIDTH="104"
ALIGN="LEFT"
VALIGN="TOP"
>7165554275</TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
>19930603</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>P. Chin</TD
><TD
WIDTH="80"
ALIGN="LEFT"
VALIGN="TOP"
>Sales</TD
><TD
WIDTH="97"
ALIGN="LEFT"
VALIGN="TOP"
>4045552341</TD
></TR
><TR
><TD
WIDTH="89"
ALIGN="LEFT"
VALIGN="TOP"
>E. Peros</TD
><TD
WIDTH="128"
ALIGN="LEFT"
VALIGN="TOP"
>50 Market St.</TD
><TD
WIDTH="168"
ALIGN="LEFT"
VALIGN="TOP"
>Rochester, NY 14624</TD
><TD
WIDTH="104"
ALIGN="LEFT"
VALIGN="TOP"
>7165554275</TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
>19940127</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>M.Garcia</TD
><TD
WIDTH="80"
ALIGN="LEFT"
VALIGN="TOP"
>Sales</TD
><TD
WIDTH="97"
ALIGN="LEFT"
VALIGN="TOP"
>7135553431</TD
></TR
><TR
><TD
WIDTH="89"
ALIGN="LEFT"
VALIGN="TOP"
>E. Peros</TD
><TD
WIDTH="128"
ALIGN="LEFT"
VALIGN="TOP"
>50 Market St.</TD
><TD
WIDTH="168"
ALIGN="LEFT"
VALIGN="TOP"
>Rochester, NY 14624</TD
><TD
WIDTH="104"
ALIGN="LEFT"
VALIGN="TOP"
>7165554275</TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
>19940520</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>J. Klobucher</TD
><TD
WIDTH="80"
ALIGN="LEFT"
VALIGN="TOP"
>Sales</TD
><TD
WIDTH="97"
ALIGN="LEFT"
VALIGN="TOP"
>7135558627</TD
></TR
></TBODY
></TABLE
></DIV
><P
>Everything appears nice and ordered, but there's a fair bit
of redundancy. M. Devlin's name appears twice, along with his address
and phone number. E. Peros' details appear three times. If you look
carefully at the employee side of things, you'll notice that M.
Garcia is repeated, as well. </P
><P
>Wouldn't it be nice if you could separate that information
and only store it once, rather than several times? In the long term,
it would certainly save disk space and allow for greater flexibility.
Since redundant data entry is minimized, it would also reduce the
chances of erroneous data entering the database, increasing consistency.
Well, we can see three different entities involved here: the customer,
the order, and the employee. So let's take each of the individuals,
put them into categories, and give them identification numbers so
they can be referenced. </P
><DIV
CLASS="TABLE"
><A
NAME="AEN172"
></A
><P
><B
>Table 2. The customer
table</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
WIDTH="41"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>id</EM
></TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>name</EM
></TD
><TD
WIDTH="128"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>address</EM
></TD
><TD
WIDTH="144"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>city_state_zip</EM
></TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>phone</EM
></TD
></TR
><TR
><TD
WIDTH="41"
ALIGN="LEFT"
VALIGN="TOP"
>101</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>M. Devlin</TD
><TD
WIDTH="128"
ALIGN="LEFT"
VALIGN="TOP"
>3114 Pioneer Ave.</TD
><TD
WIDTH="144"
ALIGN="LEFT"
VALIGN="TOP"
>Rutherford, NJ 07070</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>2015558966</TD
></TR
><TR
><TD
WIDTH="41"
ALIGN="LEFT"
VALIGN="TOP"
>109</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>J. Gagliardo</TD
><TD
WIDTH="128"
ALIGN="LEFT"
VALIGN="TOP"
>2800 Park Ave.</TD
><TD
WIDTH="144"
ALIGN="LEFT"
VALIGN="TOP"
>Hull, PQ K1A 0H3</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>8195559539</TD
></TR
><TR
><TD
WIDTH="41"
ALIGN="LEFT"
VALIGN="TOP"
>180</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>E. Peros</TD
><TD
WIDTH="128"
ALIGN="LEFT"
VALIGN="TOP"
>50 Market St.</TD
><TD
WIDTH="144"
ALIGN="LEFT"
VALIGN="TOP"
>Rochester, NY 14624</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>7165554275</TD
></TR
></TBODY
></TABLE
></DIV
><DIV
CLASS="TABLE"
><A
NAME="AEN210"
></A
><P
><B
>Table 3. The employee
table</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
WIDTH="41"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>id</EM
></TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>name</EM
></TD
><TD
WIDTH="56"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>dept</EM
></TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>phone</EM
></TD
></TR
><TR
><TD
WIDTH="41"
ALIGN="LEFT"
VALIGN="TOP"
>299</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>R. Overbey</TD
><TD
WIDTH="56"
ALIGN="LEFT"
VALIGN="TOP"
>Sales</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>5105557255</TD
></TR
><TR
><TD
WIDTH="41"
ALIGN="LEFT"
VALIGN="TOP"
>902</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>M. Kelly</TD
><TD
WIDTH="56"
ALIGN="LEFT"
VALIGN="TOP"
>Sales</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>5085553769</TD
></TR
><TR
><TD
WIDTH="41"
ALIGN="LEFT"
VALIGN="TOP"
>667</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>M.Garcia</TD
><TD
WIDTH="56"
ALIGN="LEFT"
VALIGN="TOP"
>Sales</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>7135553431</TD
></TR
><TR
><TD
WIDTH="41"
ALIGN="LEFT"
VALIGN="TOP"
>129</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>P. Chin</TD
><TD
WIDTH="56"
ALIGN="LEFT"
VALIGN="TOP"
>Sales</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>4045552341</TD
></TR
><TR
><TD
WIDTH="41"
ALIGN="LEFT"
VALIGN="TOP"
>467</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>J. Klobucher</TD
><TD
WIDTH="56"
ALIGN="LEFT"
VALIGN="TOP"
>Sales</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>7135558627</TD
></TR
></TBODY
></TABLE
></DIV
><DIV
CLASS="TABLE"
><A
NAME="AEN252"
></A
><P
><B
>Table 4. The new sales_order
table</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
WIDTH="49"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>id</EM
></TD
><TD
WIDTH="64"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>cust_id</EM
></TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>order_date</EM
></TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
><EM
>sales_rep_id</EM
></TD
></TR
><TR
><TD
WIDTH="49"
ALIGN="LEFT"
VALIGN="TOP"
>2001</TD
><TD
WIDTH="64"
ALIGN="LEFT"
VALIGN="TOP"
>101</TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
>19930316</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>299</TD
></TR
><TR
><TD
WIDTH="49"
ALIGN="LEFT"
VALIGN="TOP"
>2583</TD
><TD
WIDTH="64"
ALIGN="LEFT"
VALIGN="TOP"
>101</TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
>19940405</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>902</TD
></TR
><TR
><TD
WIDTH="49"
ALIGN="LEFT"
VALIGN="TOP"
>2576</TD
><TD
WIDTH="64"
ALIGN="LEFT"
VALIGN="TOP"
>109</TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
>19940326</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>667</TD
></TR
><TR
><TD
WIDTH="49"
ALIGN="LEFT"
VALIGN="TOP"
>2081</TD
><TD
WIDTH="64"
ALIGN="LEFT"
VALIGN="TOP"
>180</TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
>19930603</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>129</TD
></TR
><TR
><TD
WIDTH="49"
ALIGN="LEFT"
VALIGN="TOP"
>2503</TD
><TD
WIDTH="64"
ALIGN="LEFT"
VALIGN="TOP"
>180</TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
>19940127</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>667</TD
></TR
><TR
><TD
WIDTH="49"
ALIGN="LEFT"
VALIGN="TOP"
>2640</TD
><TD
WIDTH="64"
ALIGN="LEFT"
VALIGN="TOP"
>180</TD
><TD
WIDTH="88"
ALIGN="LEFT"
VALIGN="TOP"
>19940520</TD
><TD
WIDTH="96"
ALIGN="LEFT"
VALIGN="TOP"
>467</TD
></TR
></TBODY
></TABLE
></DIV
><P
>As you can see, each customer's information is stored only
once, and the same goes for each employee. The sales_order table
is a lot smaller, too. Each row, representing a sales order, refers
to a cust_id and an emp_id. </P
><P
>By looking up the customer corresponding to a cust_id (which
is unique), one can find all the needed data on that customer, without
having to repeat it in sales_order. In addition, an id column has
been added. Its purpose will be explained in the next section. </P
><P
>Why do this, you ask? By eliminating redundancy, this kind
of structure reduces the opportunities for inconsistencies to seep
in, in addition to lowering storage requirements. If you had to
change E. Peros' address in the old sales_order table, you'd have
to do it three times, which would take three times as long and give
you three times as many chances to make an error. In the newer table,
all you'd have to do is change her address once, in the customer
table. Also, by carefully separating data, you make access control
simpler. </P
><P
>Finally, can you spot another redundancy? The employee table
has "Sales" all the way down the dept column. For an organization
with multiple departments, you'd want to add a department table
and reference it from a dept_id column instead. </P
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN303"
>1.5.3. Primary and Foreign Keys</A
></H3
><P
>As described in the previous section, you can separate a table
into interrelated tables. But how do you go about relating tables
to each other? In relational databases, primary keys and foreign
keys help you link tables together. Primary keys are columns that
uniquely identify each row of a table, and foreign keys define the
relationship between the rows of two separate tables. Proper use
of primary and foreign keys will help you efficiently hold information
without excessive redundancy. </P
><P
>Every table should have a primary key to ensure that each
row is uniquely identified. This often takes the form of an ID number
being assigned to each row, as in the previous section's example.
The id column forms the primary key. </P
><P
>As long as you can guarantee the uniqueness of the data in
a particular column, though, that column can be a primary key. For
example, if you only want one entry per day to be put into a particular
table, you could use the date as that table's primary key. </P
><P
>Tables are related to one another by foreign keys. In the
sales_order example, the cust_id and sales_rep columns would be
called foreign keys to the customer and employee tables, respectively.
For terminology's sake, you might want to know that in this case,
the sales_order table is called the <EM
>foreign</EM
> or <EM
>referencing</EM
> table,
while the customer and employee tables are called the <EM
>primary</EM
> or <EM
>referenced</EM
> tables. </P
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="index.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="requirements.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Sybase Adaptive Server Anywhere for Linux HOWTO</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Requirements</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>