satu lg sy perasan, kl awk tgk struktur db awk, care penggunaan foreign key tu salah. ni sql dump yg awk bg:
so, drop blk table issues dan bina blk table tu pkai sql ni:
- Code:
--
-- Constraints for table `issues`
--
ALTER TABLE `issues`
ADD CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`id`) REFERENCES `category` (`catid`) ON DELETE CASCADE;
so, drop blk table issues dan bina blk table tu pkai sql ni:
- Code:
-- phpMyAdmin SQL Dump
-- version 3.1.3.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Dec 04, 2009 at 11:27 PM
-- Server version: 5.1.33
-- PHP Version: 5.2.9
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `test`
--
-- --------------------------------------------------------
--
-- Table structure for table `issues`
--
CREATE TABLE IF NOT EXISTS `issues` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`catid` int(11) NOT NULL,
`idesc` varchar(255) NOT NULL,
`pid` int(11) NOT NULL,
`idate` date NOT NULL,
`userid` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `catid` (`catid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
--
-- Dumping data for table `issues`
--
INSERT INTO `issues` (`id`, `title`, `catid`, `idesc`, `pid`, `idate`, `userid`) VALUES
(2, 'Foreign Key', 1, 'How to create foreign key in MySQL database?', 3, '2009-11-17', 1),
(3, 'Online Shopping System', 1, 'Is it possible to drag the items into cart? it means that, users don''t have to click', 2, '2009-11-24', 1);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `issues`
--
ALTER TABLE `issues`
ADD CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`catid`) REFERENCES `category` (`catid`);