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 8383231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:06:54+00:00 2026-06-09T17:06:54+00:00

I’m attempting to create two tables with a one-to-many relationship. Here are the schemas

  • 0

I’m attempting to create two tables with a one-to-many relationship. Here are the schemas for both of them:

CREATE TABLE property_key (
    id INTEGER AUTO_INCREMENT PRIMARY KEY,
    property VARCHAR(4000)
);

CREATE TABLE property_value (
    id INTEGER AUTO_INCREMENT PRIMARY KEY,
    prop_key VARCHAR(4000),
    prop_value VARCHAR(4000),
    lang VARCHAR(2),
    INDEX ix_land(lang)
);

When I attempt to add a foreign key relationship between property_value and property_key on prop_key, I get a weird error:

[ALTER - 0 row(s), 0.000 secs]  [Error Code: 1005, SQL State: HY000] 
Can't create table 'test.#sql-a8_6' (errno: 150)

The ALTER syntax I’m using is:

ALTER TABLE property_value ADD CONSTRAINT fk_prop_key FOREIGN KEY (prop_key) REFERENCES property_key(property);

I’ve consulted the MySQL Reference Manual on the matter, but I’ve satisfied all of the requirements there. How do I mitigate this issue?

  • 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-09T17:06:55+00:00Added an answer on June 9, 2026 at 5:06 pm

    One issue is that the fields are too large. InnoDB has a field limit of 768 bytes per key, and the foreign key that is being created is around 8KB. Further, it wouldn’t be possible to ensure that the foreign key is unique.

    Two options to mitigate this – you can either reduce the size of the VARCHAR fields to less than 768 bytes, or index about the two id fields instead.

    ALTER TABLE property_value
        ADD CONSTRAINT fk_property_key_id FOREIGN KEY (property_key_id)
        REFERENCES property_key(id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am writing an app with both english and french support. The app requests
I'm trying to create an if statement in PHP that prevents a single post
I'm making a simple page using Google Maps API 3. My first. One marker

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.