0

I have two tables.Each has an identical field titled vin. In both tables I've removed all primary keys. I've gone to the relationship view and made sure nothing was selected under the dropdown for foreign key. I've gone to the database designer view, and there are no relationships being shown between any tables. Despite all this, I still get #1553 - Cannot drop index 'vin': needed in a foreign key constraint when I try to drop the index from either table. Thanks for any help!

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Stefano Mtangoo
0

TABLE 1:

-- phpMyAdmin SQL Dump
-- version 3.3.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 29, 2011 at 02:23 PM
-- Server version: 5.5.8
-- PHP Version: 5.3.5

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `atf`
--

-- --------------------------------------------------------

--
-- Table structure for table `vehicle_info_table`
--

CREATE TABLE IF NOT EXISTS `vehicle_info_table` (
`vin` varchar(6) NOT NULL,
`Year` int(4) NOT NULL,
`Make` varchar(25) NOT NULL,
`Model` varchar(25) NOT NULL,
`Color` varchar(25) NOT NULL,
`Tag` varchar(7) NOT NULL,
`Special Info` text,
`debtor_ID` int(11) NOT NULL,
KEY `vin` (`vin`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `vehicle_info_table`
--

TABLE 2:

-- phpMyAdmin SQL Dump
-- version 3.3.9
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 29, 2011 at 02:28 PM
-- Server version: 5.5.8
-- PHP Version: 5.3.5

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `atf`
--

-- --------------------------------------------------------

--
-- Table structure for table `order_to_locate`
--

CREATE TABLE IF NOT EXISTS `order_to_locate` (
`order_ID` int(6) NOT NULL,
`date` datetime NOT NULL,
`leanholder` varchar(55) NOT NULL,
`vin` varchar(8) NOT NULL,
`debtor_ID` int(11) NOT NULL,
PRIMARY KEY (`vin`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `order_to_locate`
--


--
-- Constraints for dumped tables
--

--
-- Constraints for table `order_to_locate`
--
ALTER TABLE `order_to_locate`
ADD CONSTRAINT `order_to_locate_ibfk_1` FOREIGN KEY (`Vin`) REFERENCES `vehicle_info_table` (`Vin`);

First, I didn't know I could export the sql code, so thanks for pointing me in that direction. I am brand new to PHP and Mysql. I deleted the key = vin from table #1, and the constraint from the second table there, saved, and imported the files, and it still wont let me delete the indexes. Please advise. Thanks again for any help.

0

did you notice the statment you finally run,

ALTER TABLE `order_to_locate`
ADD CONSTRAINT `order_to_locate_ibfk_1` FOREIGN KEY (`Vin`) REFERENCES `vehicle_info_table` (`Vin`);

0

`Special Info` text,
`debtor_ID` int(11) NOT NULL,
KEY `vin` (`vin`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Check at that red, what kind of key it is?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.