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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:39:36+00:00 2026-06-18T00:39:36+00:00

Here there is the small part of the script (that are the first lines

  • 0

Here there is the small part of the script (that are the first lines of that script):
When i try to execute it says me:
Error Code: 1005. Can’t create table ‘test.paese’ (errno: 150) 0.062 sec

And when i try to do “Forward Engineer” from MySQL , it replies me somehting about:
If MySQL reports an error number 1005 from a CREATE TABLE statement, and the error message refers to error 150, table creation failed because a foreign key constraint was not correctly formed.

`SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';

CREATE SCHEMA IF NOT EXISTS `test` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `test` ;

-- -----------------------------------------------------
-- Table `test`.`SETTORE`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `test`.`SETTORE` (
  `Comune` CHAR NOT NULL ,
  `superficie` INT(11) NULL ,
  PRIMARY KEY (`Comune`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `test`.`PAESE`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `test`.`PAESE` (
  `Nome-paese` CHAR NOT NULL ,
  `Comune` CHAR NOT NULL ,
  `num_abitanti` INT(11) NULL ,
  `altitudine` INT(11) NULL ,
  `IDpaese` INT(11) NOT NULL ,
  PRIMARY KEY (`Nome-paese`, `Comune`) ,
  INDEX `Comune` (`Comune` ASC) ,
  UNIQUE INDEX `idPAESE_UNIQUE` (`IDpaese` ASC) ,
  CONSTRAINT `Comune`
    FOREIGN KEY (`Comune` )
    REFERENCES `test`.`SETTORE` (`Comune` )
    ON DELETE SET NULL
    ON UPDATE CASCADE)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `test`.`PERIODO`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `test`.`PERIODO` (
  `Settimana` INT(11) NOT NULL ,
  PRIMARY KEY (`Settimana`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `test`.`TIPO-INIZIATIVA`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `test`.`TIPO-INIZIATIVA` (
  `Nome-tipo-iniziativa` CHAR NOT NULL ,
  PRIMARY KEY (`Nome-tipo-iniziativa`) )
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `test`.`INIZIATIVA`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `test`.`INIZIATIVA` (
  `Nome-tipo-iniziativa` CHAR NOT NULL ,
  `Settimana` INT(11) NOT NULL ,
  `Nome-paese` CHAR NOT NULL ,
  `Comune` CHAR NOT NULL ,
  `descrizione` VARCHAR(45) ,
  `costo_intero` FLOAT NULL ,
  `costo_ridotto` FLOAT NULL ,
  `orario_apertura` TIME NULL ,
  `orario_chiusura` TIME NULL ,
  PRIMARY KEY (`Nome-tipo-iniziativa`, `Settimana`, `Nome-paese`, `Comune`) ,
  INDEX `Nome-paese` (`Nome-paese` ASC) ,
  INDEX `Comune` (`Comune` ASC) ,
  INDEX `Settimana` (`Settimana` ASC) ,
  INDEX `Nome-tipo-iniziativa` (`Nome-tipo-iniziativa` ASC) ,
  CONSTRAINT `Nome-paese`
    FOREIGN KEY (`Nome-paese` )
    REFERENCES `test`.`PAESE` (`Nome-paese` )
    ON DELETE SET NULL
    ON UPDATE CASCADE,
  CONSTRAINT `Comune`
    FOREIGN KEY (`Comune` )
    REFERENCES `test`.`PAESE` (`Comune` )
    ON DELETE SET NULL
    ON UPDATE CASCADE,
  CONSTRAINT `Settimana`
    FOREIGN KEY (`Settimana` )
    REFERENCES `test`.`PERIODO` (`Settimana` )
    ON DELETE SET NULL
    ON UPDATE CASCADE,
  CONSTRAINT `Nome-tipo-iniziativa`
    FOREIGN KEY (`Nome-tipo-iniziativa` )
    REFERENCES `test`.`TIPO-INIZIATIVA` (`Nome-tipo-iniziativa` )
    ON DELETE SET NULL
    ON UPDATE CASCADE)
ENGINE = InnoDB;`

So the DBMS first create the table SETTORE, but then while executing CREATE TABLE PAESE it stops.
I can’t find the error among these lines, please help me, i need it so much!!

  • 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-18T00:39:37+00:00Added an answer on June 18, 2026 at 12:39 am

    That is because of conflicting constraints on the column Comune

    Column Comune is not nullable in test.PAESE. You’re making MySQL spin!

    SHOW ENGINE INNODB STATUS;

    ------------------------
    LATEST FOREIGN KEY ERROR
    ------------------------
    130129 21:55:19 Error in foreign key constraint of table test/paese:
    FOREIGN KEY (`Comune`)
            REFERENCES `test`.`SETTORE` (`Comune`)
            ON DELETE SET NULL ON UPDATE CASCADE
    ):
    You have defined a SET NULL condition though some of the
    columns are defined as NOT NULL.
    ------------
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my code, I know there's a small mistake somewhere but being a noob
There is a small part of our software that inserts a string before and
There is a similar question here on SO, but I have a fairly small
i'm trying wmd editor over ajax. here there is the bugged code wdm code
I've seen this here and there, but can't find any information regarding this thing.
People here are using visual studio for performance testing. Now there are some small
I am working on a project and there is a small part of it
Here's an interesting question ... is there a collection that is a struct somewhere
This is a small part of my program that I am working on. I'm
Here is a working code when there are not too much text in the

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.