Databases Reference
In-Depth Information
Adding a third table to our model
To get a more complete schema, we will now add another table,
country
, to our
database. The following block of code displays the contents of its export file:
CREATE TABLE IF NOT EXISTS `country` (
`code` char(2) NOT NULL,
`description` varchar(50) NOT NULL,
PRIMARY KEY (`code`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `country` (`code`, `description`) VALUES
('ca', 'Canada'),
('uk', 'United Kingdom');
We will now link this table to the
author
table. First, in the
Relation view
for the
country
table, we specify the column that we want to display, and then click on
Save
.
We then add a
country_code
column (same type and size as that of the
code
column
in the
country
table) to the
author
table, and in the
Relation view
, we link it to the
newly-created
country
table.
We must remember to click on
Save
for the relation
to be recorded.
Search WWH ::
Custom Search