List:General Discussion« Previous MessageNext Message »
From:abdulazeez alugo Date:April 7 2009 10:41am
Subject:RE: One to many relationship
View as plain text  

 
> Date: Mon, 6 Apr 2009 10:07:01 -0500
> From: peter.brawley@stripped
> To: defatigue@stripped
> CC: mysql@stripped
> 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
Thread
One to many relationshipabdulazeez alugo5 Apr
  • Re: One to many relationshipMartijn Tonies6 Apr
  • Re: One to many relationshipPeter Brawley6 Apr
    • RE: One to many relationshipabdulazeez alugo7 Apr