My list_items table has the following columns
- `ListID`
- `WordID`
My lists table has a primary, auto-incremented primary key `ListID`. I want to make the `ListID` in list_items a foreign key referencing the primary key in lists, but I get an error:
Error creating foreign key on `ListID` (check data types).
Both columns are int(8), and both table types are InnoDB. What could possibly be the issue?
Following these instructions has worked fine in setting up other foreign keys.
The only thing I can think of is on phpMyAdmin’s main screen, there’s a message:
“The additional features for working with linked tables have been deactivated. To find out why click here.”
But wouldn’t any issue there prevent me from setting up other foreign keys?
Relevant SQL:
--
-- Table structure for table `lists`
--
CREATE TABLE IF NOT EXISTS `lists` (
```ListID``` int(8) NOT NULL AUTO_INCREMENT,
```UserID``` int(8) NOT NULL,
```privacy``` varchar(25) NOT NULL,
```name``` varchar(50) NOT NULL,
```description``` text NOT NULL,
```date created``` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
```date modified``` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (```ListID```),
KEY ```UserID``` (```UserID```)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
--
-- Dumping data for table `lists`
--
--
-- Table structure for table `list_items`
--
CREATE TABLE IF NOT EXISTS `list_items` (
```ListID``` int(8) NOT NULL,
```WordID``` int(8) NOT NULL,
KEY ```ListID``` (```ListID```),
KEY ```WordID``` (```WordID```)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `list_items`
--
--
-- Table structure for table `users`
--
CREATE TABLE IF NOT EXISTS `users` (
```UserID``` int(8) NOT NULL AUTO_INCREMENT,
```email``` int(50) NOT NULL,
```username``` int(25) NOT NULL,
```password``` int(25) NOT NULL,
```join date``` int(11) NOT NULL,
PRIMARY KEY (```UserID```)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
you have an awful lot of backticks in your sql
normally you would only have 1 set, that could be causing a problem
example