how do I alter the child table, links, so that it has a foreign key with the parent table, feeds?
The feed_id field in links should, in fact, be constrained by the foreign key of feeds with a RESTRICT reference option.
mysql> mysql> show tables; +---------------------------+ | Tables_in_rome_aggregator | +---------------------------+ | feeds | | links | | pages | +---------------------------+ 3 rows in set (0.00 sec)
mysql> mysql> describe feeds; +----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | created | datetime | NO | | NULL | | | accessed | varchar(45) | NO | | NULL | | | url | varchar(767) | NO | UNI | NULL | | | status | int(11) | NO | | 0 | | +----------+--------------+------+-----+---------+----------------+ 5 rows in set (0.05 sec)
mysql> mysql> describe links; +---------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | created | datetime | NO | | NULL | | | feed_id | int(11) | NO | | 0 | | | link | varchar(767) | NO | UNI | NULL | | | status | int(11) | NO | | 0 | | +---------+--------------+------+-----+---------+----------------+ 5 rows in set (0.00 sec)
mysql>
While I know that I should alter the table, I don't know the syntax to establish the foreign key constraint.
thanks,
Thufir
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql
Nov 17
thufir Re: alter table for foreign key
Nov 17, 2014; 01:52
thufir
Re: alter table for foreign key
Nov 17
Martijn Tonies (Upscene Productions Re: alter table for foreign key
Nov 17, 2014; 10:53
Martijn Tonies (Upscene Productions
Re: alter table for foreign key
Nov 17
Martijn Tonies (Upscene Productions Re: alter table for foreign key
Nov 17, 2014; 10:59
Martijn Tonies (Upscene Productions
Re: alter table for foreign key
Nov 17
thufir Re: alter table for foreign key
Nov 17, 2014; 11:25
thufir
Re: alter table for foreign key
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!