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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:12:43+00:00 2026-06-13T15:12:43+00:00

Well, i have two tables publica_evento_grupo Field | Type | Null | Key |

  • 0

Well, i have two tables

publica_evento_grupo

Field | Type | Null | Key | Default | Extra
id_evento_grupo int(10) unsigned    NO  PRI     auto_increment
id_evento       int(8)  unsigned    NO  MUL     
id_grupo        int(8)  unsigned    NO  MUL     
identificacao   varchar(55)         NO  

publica_identificacao_publicacao

Field | Type | Null | Key | Default | Extra
id_evento       int(8) unsigned NO  PRI     
identificacao   varchar(55)     NO  PRI     

publica_evento_grupo.id_evento in is a foreign key to a third table called publica_evento but is also a foreign key together with the column to the table publica_identificacao_publicacao.identificacao. The problem is, I got to create the foreign key that relates publica_evento_grupo to publica_identificacao_publicacao by the key id_evento, but when I try to create the another FK with the column identificacao, it gives the errno below

 [Err] 1005 - Can't create table '#sql-1049_1980992' (errno: 150).

As you can see the table publica_identificacao_publicacao has two PK and that iss the reason that it has to be 2 FK to relate them, i didn’t create the indexes yet, because as far as i know, i just have to create the indexes after adding the FK contraints, and I was able to create the FK contraint to the column id_evento between evento_grupo and identificacao_publicacao, i don’t know why just the column identificacao is giving this error

EDIT 1: @RolandBouman i don’t have the permission to use that command SHOW ENGINE INNODB STATUS

EDIT 2: @Geoff_Montee acctually the command you passed worked, to undestand why i use that structure take a look at this question MySQL UNIQUE Constraint multiple columns condition

  • 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-13T15:12:44+00:00Added an answer on June 13, 2026 at 3:12 pm

    That error usually happens because there is a type mismatch between the referring table and the referred table. In this case, the types seem to match.

    Have you considered having a constraint for both fields in the primary composite key? You might have to remove the existing foreign key constraint on id_evento first.

    ALTER TABLE publica_evento_grupo ADD FOREIGN KEY 
        (id_evento, identificacao) REFERENCES 
        publica_identificacao_publicacao (id_evento, identificacao);
    

    It seems as though the error in this case might be because you try to add a foreign key constraint to only part of a composite primary key.

    Does identificacao exist in any other tables? Why do you want to add a foreign key constraint to only part of a composite primary key?

    Think about it this way…

    Let’s say you do have a foreign key constraint in the publica_evento_grupo table to the identificacao field by itself. Let’s also say in the publica_identificacao_publicacao table you have (1, "some string") and (2, "some string"). So if you delete (2, "some string"), but leave (1, "some string") in its place. The rows that refer to (1, "some string") in the publica_evento_grupo table will complain, even though they shouldn’t!

    So it sounds to me like you should add a foreign key constraint to all of a primary key or none of it.

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

Sidebar

Related Questions

I have two tables (well, two relevant for this question) : Bets (holds the
I have two servlets below and work well with Tomcat7/Indigo, it will print '
I have two classes, ClassA and ClassB , as well as a many to
I have found two different things in two well known books in c, first
Well as I have posted earlier too...I have created a site in two languages.One
I have two tables: Accounts , which contains the information of accounts that a
I have two tables. Report and ReportData . ReportData has a constraint ReportID. How
I have two tables which share common fields. Rather than re-map all of these
I have two @Entity s, both with a BigDecimal field as follows: in one
I have two tables called 'USER' and 'CART' the two tables contain the same

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.