Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8661187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:26:20+00:00 2026-06-12T16:26:20+00:00

i am trying to create an order management system but after creating base tables

  • 0

i am trying to create an order management system
but after creating base tables ie (Suppliers,Customers,Categories,Employees,Shippers)
i go to next level with creating product and orders, i am able to add foregin keys in those table.
now i added last level table oderDetail and trying to add foregin key to OrderID and ProdcuID but it just gives me error 150
mysqldump

-- MySQL Administrator dump 1.4
--
-- ------------------------------------------------------
-- Server version   5.5.8


/*!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 */;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;


--
-- Create schema testdrive
--

CREATE DATABASE IF NOT EXISTS testdrive;
USE testdrive;

--
-- Definition of table `categories`
--

DROP TABLE IF EXISTS `categories`;
CREATE TABLE `categories` (
  `CategoryID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Description` varchar(45) NOT NULL,
  `Picture` blob,
  PRIMARY KEY (`CategoryID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `categories`
--

/*!40000 ALTER TABLE `categories` DISABLE KEYS */;
/*!40000 ALTER TABLE `categories` ENABLE KEYS */;


--
-- Definition of table `customers`
--

DROP TABLE IF EXISTS `customers`;
CREATE TABLE `customers` (
  `CustomerID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `CompanyName` varchar(255) NOT NULL,
  `ContactName` varchar(255) NOT NULL,
  `ContactTitle` varchar(255) NOT NULL,
  `Address` text NOT NULL,
  `City` varchar(255) NOT NULL,
  `Region` varchar(255) NOT NULL,
  `PostalCode` varchar(45) NOT NULL,
  `Country` varchar(255) NOT NULL,
  `Phone` varchar(255) NOT NULL,
  `Fax` varchar(255) NOT NULL,
  PRIMARY KEY (`CustomerID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `customers`
--

/*!40000 ALTER TABLE `customers` DISABLE KEYS */;
/*!40000 ALTER TABLE `customers` ENABLE KEYS */;


--
-- Definition of table `employees`
--

DROP TABLE IF EXISTS `employees`;
CREATE TABLE `employees` (
  `EmployeeID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `LastName` varchar(255) NOT NULL,
  `FirstName` varchar(255) NOT NULL,
  `Title` varchar(255) NOT NULL,
  `BirthDate` date NOT NULL,
  `HireDate` date NOT NULL,
  `Address` text NOT NULL,
  `City` varchar(255) NOT NULL,
  `Region` varchar(255) NOT NULL,
  `PostalCode` varchar(45) NOT NULL,
  `Country` varchar(255) NOT NULL,
  `HomePhone` varchar(255) NOT NULL,
  `Extension` varchar(255) DEFAULT NULL,
  `Photo` blob NOT NULL,
  `Notes` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`EmployeeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `employees`
--

/*!40000 ALTER TABLE `employees` DISABLE KEYS */;
/*!40000 ALTER TABLE `employees` ENABLE KEYS */;


--
-- Definition of table `orderdetail`
--

DROP TABLE IF EXISTS `orderdetail`;
CREATE TABLE `orderdetail` (
  `OrderDetailID` int(10) NOT NULL,
  `ProductID` int(10) NOT NULL,
  `OrderID` int(10) NOT NULL,
  `Quantity` varchar(255) NOT NULL,
  `Discount` varchar(255) NOT NULL,
  PRIMARY KEY (`OrderDetailID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `orderdetail`
--

/*!40000 ALTER TABLE `orderdetail` DISABLE KEYS */;
/*!40000 ALTER TABLE `orderdetail` ENABLE KEYS */;


--
-- Definition of table `ordres`
--

DROP TABLE IF EXISTS `ordres`;
CREATE TABLE `ordres` (
  `OrderID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `CustomerID` int(10) unsigned NOT NULL,
  `EmployeeID` int(10) unsigned NOT NULL,
  `OderDate` date NOT NULL,
  `RequiredDate` date NOT NULL,
  `ShippedDate` date NOT NULL,
  `ShipperID` int(10) unsigned NOT NULL,
  PRIMARY KEY (`OrderID`),
  KEY `Order_Customer` (`CustomerID`),
  KEY `Order_Employee` (`EmployeeID`),
  KEY `Order_Shipper` (`ShipperID`),
  CONSTRAINT `Order_Customer` FOREIGN KEY (`CustomerID`) REFERENCES `customers` (`CustomerID`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `Order_Employee` FOREIGN KEY (`EmployeeID`) REFERENCES `employees` (`EmployeeID`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `Order_Shipper` FOREIGN KEY (`ShipperID`) REFERENCES `shippers` (`ShipperID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `ordres`
--

/*!40000 ALTER TABLE `ordres` DISABLE KEYS */;
/*!40000 ALTER TABLE `ordres` ENABLE KEYS */;


--
-- Definition of table `products`
--

DROP TABLE IF EXISTS `products`;
CREATE TABLE `products` (
  `ProductID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `ProductName` varchar(255) NOT NULL,
  `SupplierID` int(10) unsigned NOT NULL,
  `CategoryID` int(10) unsigned NOT NULL,
  `QuantityPerUnit` varchar(255) NOT NULL,
  `UnitPrice` varchar(255) NOT NULL,
  PRIMARY KEY (`ProductID`),
  KEY `Product_Supplier` (`SupplierID`),
  KEY `Product_Category` (`CategoryID`),
  CONSTRAINT `Product_Supplier` FOREIGN KEY (`SupplierID`) REFERENCES `suppliers` (`SupplierID`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `Product_Category` FOREIGN KEY (`CategoryID`) REFERENCES `categories` (`CategoryID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `products`
--

/*!40000 ALTER TABLE `products` DISABLE KEYS */;
/*!40000 ALTER TABLE `products` ENABLE KEYS */;


--
-- Definition of table `shippers`
--

DROP TABLE IF EXISTS `shippers`;
CREATE TABLE `shippers` (
  `ShipperID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `CompanyName` varchar(255) NOT NULL,
  `Phone` varchar(255) NOT NULL,
  PRIMARY KEY (`ShipperID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `shippers`
--

/*!40000 ALTER TABLE `shippers` DISABLE KEYS */;
/*!40000 ALTER TABLE `shippers` ENABLE KEYS */;


--
-- Definition of table `suppliers`
--

DROP TABLE IF EXISTS `suppliers`;
CREATE TABLE `suppliers` (
  `SupplierID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `CompanyName` varchar(255) NOT NULL,
  `ContractTittle` varchar(255) NOT NULL,
  `Address` text NOT NULL,
  `City` varchar(255) NOT NULL,
  `Region` varchar(255) NOT NULL,
  `PostalCode` varchar(255) NOT NULL,
  `Country` varchar(255) NOT NULL,
  `Phone` varchar(255) NOT NULL,
  `Fax` varchar(255) NOT NULL,
  `HomePage` text NOT NULL,
  PRIMARY KEY (`SupplierID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `suppliers`
--

/*!40000 ALTER TABLE `suppliers` DISABLE KEYS */;
/*!40000 ALTER TABLE `suppliers` ENABLE KEYS */;

and here is what i am trying to do

  ALTER TABLE testdrive.orderdetail
 ADD CONSTRAINT orderDetail_Product FOREIGN KEY (ProductID) REFERENCES testdrive.products (ProductID) ON UPDATE CASCADE ON DELETE CASCADE,
 ADD CONSTRAINT OrderDetail_Order FOREIGN KEY (OrderID) REFERENCES testdrive.ordres (OrderID) ON UPDATE CASCADE ON DELETE CASCADE;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:26:21+00:00Added an answer on June 12, 2026 at 4:26 pm

    forein key between two fields that are not exactly the same. The fields type, dimension and flags should be identical.

    add unsigned int in the column ( productId, orderId ) of table testdrive.orderdetail

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am trying to create a Memory Management System. In order to do
I was trying to create a linear order from git log output, but all
I'm trying to create an html table for order logs for customers. A customer
I'm trying to create an unique array regardless of its original order and using
I'm trying to create a hash that preserves the order that the keys are
I'm currently trying to create a subclass of UIImageView in order to make it
I am trying to create a table within PHP code in order to open
I'm trying to convert datetime2 to datetime in order to create a standard between
I've been trying to create an order confirmation page for my rails app, and
I am trying to create a Makefile in order to generate object files in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.