> Date: Mon, 6 Apr 2009 10:07:01 -0500
> From: peter.braw...@earthlink.net
> To: defati...@hotmail.com
> CC: mysql@lists.mysql.com
> Subject: Re: One to many relationship
> 
> Abdul,
> 
> Is this what you mean?
> 
> CREATE TABLE Table1 (
> table1_id INT UNSIGNED PRIMARY KEY AUTO INCREMENT,
> entrydate TIMESTAMP
> )ENGINE=INNODB;
> CREATE TABLE table2 (
> table2_id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
> table1_id INT UNSIGNED NOT NULL,
> entrydate TIMESTAMP,
> FOREIGN KEY(table1_id) REFERENCES table1(table1_id)
> )ENGINE=INNODB;
> 
> After this, the DB engine will ensure that any table1_id value you try 
> to insert in table2 actually exists in table1. See the manual page for 
> foreign keys.
> 
> PB
> 
Yeah PB. Thanks.
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx

Reply via email to