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

The Archive Base Latest Questions

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

i am trying to create DB with this script. But i am in the

  • 0

i am trying to create DB with this script. But i am in the black hole. I don’t know what to do now. Here is my MySQL code. Please somebody for kick me up.

If i use one foreign key it is ok, but i do not know how to use more of them.

EROOR IS:

#1005 - Can't create table 'ruda_dev_souteze2.results' (errno: 150)

QUERY IS:

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,ALLOW_INVALID_DATES';

CREATE SCHEMA IF NOT EXISTS `ruda_dev_souteze2` DEFAULT CHARACTER SET utf8 COLLATE utf8_czech_ci ;

USE `ruda_dev_souteze2` ;

-- -----------------------------------------------------
-- Table `ruda_dev_souteze2`.`contests`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `ruda_dev_souteze2`.`contests` (
  `id` BIGINT(20) NOT NULL AUTO_INCREMENT ,
  `name` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL ,
  `date` DATE NOT NULL ,
  `public` TINYINT(1) NOT NULL ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB
AUTO_INCREMENT = 11
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_czech_ci;


-- -----------------------------------------------------
-- Table `ruda_dev_souteze2`.`people`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `ruda_dev_souteze2`.`people` (
  `contest_id` BIGINT(20) NOT NULL ,
  `number` INT(11) NOT NULL ,
  `category` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL ,
  `fname` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL ,
  `lname` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL ,
  PRIMARY KEY (`contest_id`, `number`) ,
  INDEX `id_idx` (`contest_id` ASC) ,
  CONSTRAINT `cidfp`
    FOREIGN KEY (`contest_id` )
    REFERENCES `ruda_dev_souteze2`.`contests` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_czech_ci;


-- -----------------------------------------------------
-- Table `ruda_dev_souteze2`.`subjects`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `ruda_dev_souteze2`.`subjects` (
  `contest_id` BIGINT(20) NOT NULL ,
  `number` INT(11) NOT NULL ,
  `name` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL ,
  `direct` TINYINT(1) NOT NULL ,
  `type` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL ,
  `subjectscol` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NULL DEFAULT NULL ,
  PRIMARY KEY (`contest_id`, `number`) ,
  INDEX `id_idx` (`contest_id` ASC) ,
  CONSTRAINT `cidfs`
    FOREIGN KEY (`contest_id` )
    REFERENCES `ruda_dev_souteze2`.`contests` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_czech_ci;


-- -----------------------------------------------------
-- Table `ruda_dev_souteze2`.`results`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `ruda_dev_souteze2`.`results` (
  `contest_id` BIGINT(20) NOT NULL ,
  `subject_number` INT(11) NOT NULL ,
  `people_number` INT(11) NOT NULL ,
  `number_8c2` FLOAT(10,2) NULL DEFAULT NULL ,
  `time_time` TIME NULL DEFAULT NULL ,
  `time_frag` FLOAT(2,2) NULL DEFAULT NULL ,
  PRIMARY KEY (`contest_id`, `subject_number`, `people_number`) ,
  INDEX `cidfr_idx` (`contest_id` ASC) ,
  INDEX `snfr_idx` (`subject_number` ASC) ,
  INDEX `pnfr_idx` (`people_number` ASC) ,
  CONSTRAINT `cidfr`
    FOREIGN KEY (`contest_id` )
    REFERENCES `ruda_dev_souteze2`.`contests` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `snfr`
    FOREIGN KEY (`subject_number` )
    REFERENCES `ruda_dev_souteze2`.`subjects` (`number` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `pnfr`
    FOREIGN KEY (`people_number` )
    REFERENCES `ruda_dev_souteze2`.`people` (`number` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_czech_ci;


-- -----------------------------------------------------
-- Table `ruda_dev_souteze2`.`users`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `ruda_dev_souteze2`.`users` (
  `username` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL ,
  `fullname` VARCHAR(255) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL ,
  `password` BINARY(40) NOT NULL ,
  `access` CHAR(1) CHARACTER SET 'utf8' COLLATE 'utf8_czech_ci' NOT NULL ,
  PRIMARY KEY (`username`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_czech_ci;



SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
  • 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-12T15:39:26+00:00Added an answer on June 12, 2026 at 3:39 pm

    I think I understand what you’re asking (if not, please clarify).

    In your CREATE TABLE query for the results table, you’re trying to create three individual FOREIGN KEY columns and each goes to a different table. The problem in the query are these three lines:

    INDEX `cidfr_idx` (`contest_id` ASC) ,
    INDEX `snfr_idx` (`subject_number` ASC) ,
    INDEX `pnfr_idx` (`people_number` ASC) ,
    

    If you change INDEX to KEY it should work fine. Also, ASC is the default – so technically you could leave it out (but leaving it in wouldn’t hurt a thing.

    So, after this minor update your CREATE TABLE for the results table should look like:

    CREATE  TABLE IF NOT EXISTS `ruda_dev_souteze2`.`results` (
      `contest_id` BIGINT(20) NOT NULL ,
      `subject_number` INT(11) NOT NULL ,
      `people_number` INT(11) NOT NULL ,
      `number_8c2` FLOAT(10,2) NULL DEFAULT NULL ,
      `time_time` TIME NULL DEFAULT NULL ,
      `time_frag` FLOAT(2,2) NULL DEFAULT NULL ,
      PRIMARY KEY (`contest_id`, `subject_number`, `people_number`) ,
      KEY `cidfr_idx` (`contest_id`) ,
      KEY `snfr_idx` (`subject_number`) ,
      KEY `pnfr_idx` (`people_number`) ,
      CONSTRAINT `cidfr`
        FOREIGN KEY (`contest_id` )
        REFERENCES `ruda_dev_souteze2`.`contests` (`id` )
        ON DELETE NO ACTION
        ON UPDATE NO ACTION,
      CONSTRAINT `snfr`
        FOREIGN KEY (`subject_number` )
        REFERENCES `ruda_dev_souteze2`.`subjects` (`number` )
        ON DELETE NO ACTION
        ON UPDATE NO ACTION,
      CONSTRAINT `pnfr`
        FOREIGN KEY (`people_number` )
        REFERENCES `ruda_dev_souteze2`.`people` (`number` )
        ON DELETE NO ACTION
        ON UPDATE NO ACTION)
    ENGINE = InnoDB
    DEFAULT CHARACTER SET = utf8
    COLLATE = utf8_czech_ci;
    

    I tested the full script locally with the changes and it ran fine – please let me know if you’re having any issues and I can look into it further.

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

Sidebar

Related Questions

I'm trying to run the following PowerShell script to create a local user. This
I am trying to create this table in a MySQL database CREATE TABLE IF
I am trying to create this QT gui using a thread but no luck.
I have trying to create this jquery dropdown, but it doesn't work, Does anybody
Im Trying to create this: |---------------------------------------------| | Panel 1a | Panel 2a | Panel
I am trying to create this tooltip sample for my wordpress it works just
I am trying to create this simple application in c#: when the user double
I'm trying to create this effect: http://www.thecssninja.com/demo/css_tree/ the problem I'm having is that the
I am trying to create something like this as i have done it in
I'm trying to find out how they were able to create this site. http://www.cpeople.ru

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.