Java Reference
In-Depth Information
2. Enter lines 87 through 105 as shown in Figure 11-17 on page 710.
The Users table is created with five fields (Figure 11-25). The first three fields
are of type TEXT, with the field, userID, used as the primary key. The other
field types used, LONGBINARY and BIT, have implicit field lengths.
userID field is
primary key
field size
implied
FIGURE 11-25
The data type, LONGBINARY , is used to store large binary objects and will
be used to store Password objects in this database. The number of bytes is not
specified, but with Access, it has a maximum size of 2.14 gigabytes. Microsoft
Access synonyms for this data type are IMAGE, GENERAL, and OLEOBJECT. In
ANSI SQL, this also is referred to as a binary large object, or BLOB. The data
type, BIT , is a Boolean, or logical, type that results in a true or false value. A true
value is equal to -1 and a false value is equal to 0. In Microsoft Access, this data
type uses one byte for storage and has synonyms of YESNO, LOGICAL, and
LOGICAL1.
As indicated earlier, the UserStocks table represents a many-to-many
relationship between the Users table and the Stocks table. It consists of two
fields: userID, which is a foreign key to the Users table, and symbol, which is a
foreign key to the Stocks table. As such, the creation of this table had to be
placed after the creation of the previous two tables. This table will be created
without designating a primary key, as the primary key index will be created later.
Creating a foreign key requires creating a reference in the current table to the
table and primary key field name(s) in the related table. This is done with the
REFERENCES keyword.
The step on the next page enters code to create the UserStocks table with
foreign keys to the Users and Stocks tables.
 
Search WWH ::




Custom Search