Java Reference
In-Depth Information
A table is a set of data records, arranged as rows, each of which contains individual
data elements or fields, arranged as columns. All the data in one column must be of
the same type, such as integer, decimal, character string, or date.
In many ways, a table is like a spreadsheet. Each row contains a single record. Unlike
the rows in a spreadsheet, however, the rows in a database have no implicit order.
Table 3 -3 illustrates the way tables are designed to contain rows of related,
unordered data elements.
Table 3-3: Part of a Database Table
Contact_ID
First_Name MI
Last_Name
Street
City
State
Zip
1
Alex
M
Baldwin
123 Pine
S t
Washington
DC
12345
2
Michael
Q
Cordell
1701 York
Rd
Columbia
MD
21144
It is immediately obvious that all fields within a given column have a number of
features in common:
 
They are similar in type .
 
They form part of a column that has a name .
 
All fields in a column may be subject to one or more constraints.
When a table is created, data types and field lengths are set for each column. These
assignments are set using a statement of the following form:
CREATE TABLE tableName
( columnName dataType[(size)] [constraints] [default value],...);
The table and column names must start with a letter and can be followed
by letters, numbers, or underscores.
Note
Integrity constraints
In addition to selecting data type and length, there are various constraints that may
have to be applied to the data stored in a column. These constraints are called
integrity constraints because they are used to ensure the consistency and accuracy
of the data. They are as follows:
 
NULL or NOT NULL
 
UNIQUE
 
PRIMARY KEY
 
FOREIGN KEY
NULL or NOT NULL
Search WWH ::




Custom Search