Discussion: relational tables
Afficher un message
Vieux 20/03/2008, 21h16   #3
John Taylor-Johnston
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: relational tables

Sorry, I'm a top quoter. This is what I want to do. I'm still told there
re problems with my keys.

DROP TABLE IF EXISTS `person`;
CREATE TABLE `person` (
`person_id` int(11) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`email` varchar(255) default NULL,
PRIMARY KEY (`person_id`),
KEY `email` (`email`),
KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

INSERT INTO `person`( `person_id`, `name`, `email` ) VALUES ( 1, 'Name',
'email@address.com' ) ;
INSERT INTO `person`( `person_id`, `name`, `email` ) VALUES ( 2, 'second
Name', 'email@anotheraddress.com' ) ;

DROP TABLE IF EXISTS `shopping`;
CREATE TABLE IF NOT EXISTS `shopping` (
`shopping_id` int(11) NOT NULL,
`email` varchar(255) default NULL,
`name` varchar(255) default NULL,
PRIMARY KEY (`shopping_id`),
UNIQUE KEY `email` (`email`),
UNIQUE KEY `name` (`name`),
FOREIGN KEY (`email`) REFERENCES `person` (`email`),
FOREIGN KEY (`name`) REFERENCES `person` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


Sebastian Mendel wrote:
>>
>> This is InnoDB so I should be able to do this by SQL, right?

>
> where do you want to see this drop-downs?

  Réponse avec citation
 
Page generated in 0,04628 seconds with 9 queries