Hi,

When I add a reference to a non-existing row in the referenced table, I have
no error:
My table "member_orders_items" references "members_orders",
member_orders_item has a FK to a non existing PK in member_orders (since
this one is empty), no error is generated.

I can see in MySQL Administrator that both tables are InnoDB.
Here is my table structure:


DROP TABLE IF EXISTS `members_orders`;
CREATE TABLE `members_orders` (
`id_order` int(10) unsigned NOT NULL auto_increment,
`paid_date` datetime default NULL,
`record_date` datetime NOT NULL,
`total` decimal(7,2) unsigned NOT NULL,
`total_partner` decimal(7,2) unsigned NOT NULL,
`member_id` int(10) unsigned NOT NULL,
`total_no_discount` decimal(7,2) unsigned default NULL,
PRIMARY KEY (`id_order`),
KEY `FK_MEMBER_ID_MEMBERS_ORDERS` (`member_id`),
CONSTRAINT `FK_MEMBER_ID_MEMBERS_ORDERS` FOREIGN KEY (`member_id`)
REFERENCES `members` (`id_member`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8;


LOCK TABLES `members_orders` WRITE;
UNLOCK TABLES;

DROP TABLE IF EXISTS `members_orders_items`;
CREATE TABLE `members_orders_items` (
`id_order_item` int(10) unsigned NOT NULL auto_increment,
`qty` int(10) unsigned NOT NULL,
`total` decimal(7,2) unsigned NOT NULL,
`order_id` int(10) unsigned NOT NULL,
`item_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id_order_item`),
KEY `FK_ORDER_ID_MEMBERS_ORDERS_ITEMS` (`order_id`),
KEY `FK_ITEM_ID_MEMBERS_ORDERS_ITEMS` (`item_id`),
CONSTRAINT `FK_ITEM_ID_MEMBERS_ORDERS_ITEMS` FOREIGN KEY (`item_id`)
REFERENCES `services_items` (`id_item`),
CONSTRAINT `FK_ORDER_ID_MEMBERS_ORDERS_ITEMS` FOREIGN KEY (`order_id`)
REFERENCES `members_orders` (`id_order`)
) ENGINE=InnoDB AUTO_INCREMENT=137 DEFAULT CHARSET=utf8;

LOCK TABLES `members_orders_items` WRITE;
INSERT INTO `members_orders_items` VALUES (137,750,'54.00',25,45); //<--
Here should be an error ?
UNLOCK TABLES;



Thank you for any kind help !!
Matt.
-- 
View this message in context: 
http://www.nabble.com/InnoDB-tables-but-no-FK-constraints-tp17364156p17364156.html
Sent from the MySQL - General mailing list archive at Nabble.com.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to