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

  • SEARCH
  • Home
  • 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 6822611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:41:04+00:00 2026-05-26T21:41:04+00:00

I have tried adding a foreign key like this… ALTER TABLE OrderLineItem ADD CONSTRAINT

  • 0

I have tried adding a foreign key like this…

ALTER TABLE OrderLineItem
ADD CONSTRAINT
        FK_OrderLineItem_ShippingType_name FOREIGN KEY
(shippingType)
REFERENCES ShippingType(name);

Or like this in Mysql 5.5…

alter table OrderLineItem add foreign key 
FK_OrderLineItem_ShippingType (shippingType) references ShippingType(name);

Every time I see the following error.

[2011-11-18 15:07:04] [HY000][150] Create table
‘realtorprint_dev_dev/#sql-7d0_80’ with foreign key constraint failed.
There is no index in the referenced table where the referenced columns
appear as the first columns.

[2011-11-18 15:07:04] [HY000][1005] Can’t create table
‘realtorprint_dev_dev.#sql-7d0_80’ (errno: 150)

Both OrderLineItem.shippingType and ShippingType.name have a type of varchar(50) not null. ShippingType.name is the primaryKey of ShippingType.

Here is the result of show create table on ShippingType as well as OrderLineItem…

CREATE TABLE `shippingtype` (
  `name` varchar(50) CHARACTER SET latin1 NOT NULL DEFAULT '',
  `description` varchar(255) CHARACTER SET latin1 NOT NULL,
  PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `orderlineitem` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `description` varchar(255) CHARACTER SET latin1 NOT NULL,
  `lineNumber` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `quantityMultiplier` int(11) NOT NULL,
  `unitPrice` decimal(10,2) NOT NULL,
  `order_id` bigint(20) NOT NULL,
  `productDefinition_id` bigint(20) NOT NULL,
  `mlsId` varchar(255) CHARACTER SET latin1 DEFAULT NULL,
  `printProviderUnitCost` decimal(10,2) NOT NULL,
  `shippingType` varchar(50) NOT NULL,
  `address` varchar(255) DEFAULT NULL,
  `zipPostal` varchar(255) NOT NULL,
  `city` varchar(255) NOT NULL,
  `stateProvince` varchar(255) NOT NULL,
  `country` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_OrderLineItem_productDefinition_id` (`productDefinition_id`),
  KEY `idx_OrderLineItem_order_id` (`order_id`),
  CONSTRAINT `FK_OrderLineItem_order_id` FOREIGN KEY (`order_id`) REFERENCES `userorder` (`id`),
  CONSTRAINT `FK_OrderLineItem_productDefinition_id` FOREIGN KEY (`productDefinition_id`) REFERENCES `productdefinition` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10029 DEFAULT CHARSET=utf8;
  • 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-05-26T21:41:04+00:00Added an answer on May 26, 2026 at 9:41 pm

    It is possible is that Mysql gives this bad error when the column types do not match exactly – check collation / size etc.

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

Sidebar

Related Questions

I have a root view controller with no nib file, I tried adding this
I have a mapping like this: HasMany(x => x.Orders).KeyColumn(CustomerID); Which is causing a constraint
I have a MySQL table like this: CREATE TABLE categories ( ID INT NOT
I have just tried adding a WebService (asmx based) from a WebForms project to
I have tried this... Dim myMatches As String() = System.Text.RegularExpressions.Regex.Split(postRow.Item(Post), \b\#\b) But it is
I have tried what seems like everything - I've done similiar things many times
I have tried the following two statements: SELECT col FROM db.tbl WHERE col (LIKE
I'm using django's built-in contrib.auth module and have setup a foreign key relationship to
I want to use external fonts in my app. I have tried adding new
I am trying to host ASP.NET MVC on iis 5. I have tried adding

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.