Understanding the Program Table Structure

The tables are based on the person and phone number tables used in the first chapter. Here’s the structure of the person table and the SQL to create it:

+------------+-------------+------+-----+---------+----------------+ | Field      | Type        | Null | Key | Default | Extra          | +------------+-------------+------+-----+---------+----------------+ | id         | int(11)     |      | PRI | NULL    | auto_increment | | first_name | varchar(30) |      |     |         |                | | last_name  | varchar(30) | YES  |     | NULL    |                | | greeting   | varchar(30) | YES  |     | NULL    |                | +------------+-------------+------+-----+---------+----------------+ CREATE TABLE person (   id int(11) NOT NULL auto_increment,   first_name varchar(30) NOT NULL default ‘’,   last_name varchar(30) default NULL,   greeting varchar(30) default NULL,   PRIMARY KEY  (id) ) TYPE=MyISAM;

The phone table uses the person.id and the phone_type as the primary key:

+--------------+-------------+------+-----+---------+-------+ | Field        | Type        | Null | Key | Default | Extra | +--------------+-------------+------+-----+---------+-------+ | id           | int(11)     |      | PRI | 0       |       | | phone_type   | varchar(10) |      | PRI |         |       | | phone_number | varchar(30) |      |     |         |       | | note         | varchar(30) | YES  |     | NULL    |       | +--------------+-------------+------+-----+---------+-------+ CREATE TABLE phone (   id int(11) NOT NULL default ‘0’,   phone_type varchar(10) NOT NULL default ‘’,   phone_number varchar(30) NOT NULL default ‘’,   note varchar(30) default NULL,   PRIMARY KEY  (id, phone_type) ) TYPE=MyISAM;



Perl Database Programming
Perl Database Programming
ISBN: 0764549561
EAN: 2147483647
Year: 2001
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net