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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:33:49+00:00 2026-06-11T01:33:49+00:00

CREATE TABLE IF NOT EXISTS `questions` ( `question_id` int(11) NOT NULL AUTO_INCREMENT, `createddate` timestamp

  • 0
CREATE TABLE IF NOT EXISTS `questions` (
  `question_id` int(11) NOT NULL AUTO_INCREMENT,
  `createddate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updateddate` timestamp NULL DEFAULT NULL,
  `active_flag` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`question_id`),
  UNIQUE KEY `id_UNIQUE` (`question_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE `alarts` (
  `alart_id` BIGINT(20) unsigned NOT NULL AUTO_INCREMENT,
  `alart_name` varchar(45) NOT NULL,
  `interval` int(10) unsigned NOT NULL,
  `alart_sent_counter` int(10) unsigned NOT NULL,
  `alart_types_id` BIGINT(20) unsigned NOT NULL,
  `contact_group_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`alart_id`),
  FOREIGN KEY (`alart_types_id`) REFERENCES alart_types(`alart_types_id`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;

I want to create new table with two FOREIGN KEY like this:

CREATE TABLE `alart_question_mapping` (
`alart_question_mapping_id` BIGINT(20) unsigned NOT NULL AUTO_INCREMENT,  
`question_id` int(11) NOT NULL,
`alart_id` BIGINT(20) unsigned NOT NULL,
PRIMARY KEY (`alart_question_mapping_id`),
FOREIGN KEY (`question_id`) REFERENCES questions(`question_id`),
FOREIGN KEY (`alart_id`) REFERENCES alart_types(`alart_id`)
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;

but I am getting error:
Error Code: 1005. Can’t create table ‘alart_question_mapping’ (errno: 150)

How can I create this table ?

Thank’s.

  • 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-11T01:33:50+00:00Added an answer on June 11, 2026 at 1:33 am

    It can’t find table alart_types.

    From MySQL Foreign Key Constraints

    If you re-create a table that was dropped, it must have a definition
    that conforms to the foreign key constraints referencing it. It must
    have the right column names and types, and it must have indexes on the
    referenced keys
    , as stated earlier. If these are not satisfied, MySQL
    returns error number 1005 and refers to error 150 in the error
    message.

    I think you mean

    FOREIGN KEY (`alart_id`) REFERENCES alart(`alart_id`)
    

    instead of

    FOREIGN KEY (`alart_id`) REFERENCES alart_types(`alart_id`)
    

    Hope this makes sense.

    enter image description here

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

Sidebar

Related Questions

SQL STRUCTURE CREATE TABLE IF NOT EXISTS `map` ( `id` int(11) NOT NULL AUTO_INCREMENT,
Simplified Table structure: CREATE TABLE IF NOT EXISTS `hpa` ( `id` bigint(15) NOT NULL
Given the table: CREATE TABLE IF NOT EXISTS `users` ( `id` bigint(20) NOT NULL
Using the command: CREATE TABLE IF NOT EXISTS `test`.`t1` ( `col` VARCHAR(16) NOT NULL
I have this table: CREATE TABLE IF NOT EXISTS `produtos` ( `id` int(11) NOT
I have the following table: CREATE TABLE IF NOT EXISTS `customer_list` ( `id` INT
I've got a table like so: CREATE TABLE IF NOT EXISTS grades(_id, timestamp, extra);
Here's what I'm working with: CREATE TABLE IF NOT EXISTS `rate` ( `id` int(11)
i have 2 tables CREATE TABLE if not exists tag_name( + tagid INTEGER PRIMARY
I have a code: CREATE TABLE IF NOT EXISTS Person ( name varchar(24) ...

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.