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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:18:32+00:00 2026-06-08T20:18:32+00:00

This create table is throwing an error 150: CREATE TABLE IF NOT EXISTS published(

  • 0

This create table is throwing an error 150:

CREATE TABLE IF NOT EXISTS published(
isbn VARCHAR(13) NOT NULL,
publisherid INTEGER NOT NULL,
year INTEGER NOT NULL,
lastupdate TIMESTAMP NOT NULL,
lastupdateby INTEGER NOT NULL,
FOREIGN KEY (lastupdateby) REFERENCES librarians (librarianid),
FOREIGN KEY (isbn) REFERENCES books,
FOREIGN KEY (publisherid) REFERENCES publishers,
PRIMARY KEY (isbn, publisherid)
) ENGINE = INNODB;

I’ve checked that the tables it references (librarians, books, and publishers) are already created when SQL gets to this bit. Here are their DDLs:

CREATE TABLE IF NOT EXISTS librarians(
librarianid INTEGER AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL,
canread BOOLEAN NOT NULL,
canwrite BOOLEAN NOT NULL,
canexec BOOLEAN NOT NULL,
lastupdate TIMESTAMP NOT NULL,
lastupdateby INTEGER NOT NULL,
FOREIGN KEY (lastupdateby) REFERENCES librarians (librarianid)
) ENGINE = INNODB;

CREATE TABLE IF NOT EXISTS books(
isbn VARCHAR(13) PRIMARY KEY,
title VARCHAR(255) NOT NULL,
lastupdate TIMESTAMP NOT NULL,
lastupdateby INTEGER NOT NULL,
FOREIGN KEY (lastupdateby) REFERENCES librarians (librarianid)
) ENGINE = INNODB;

CREATE TABLE IF NOT EXISTS publishers(
publisherid INTEGER PRIMARY KEY AUTO_INCREMENT,
publishername VARCHAR(255) UNIQUE NOT NULL,
lastupdate TIMESTAMP NOT NULL,
lastupdateby INTEGER NOT NULL,
FOREIGN KEY (lastupdateby) REFERENCES librarians (librarianid)
) ENGINE = INNODB;

Further, I’ve checked the following guidelines I found here:

The referenced tables should be InnoDB as well. Well, I even had that explicitly specified.

Referenced tables must have an index and primary key. The foreign key fields are the (sole) primary keys of their respective reference tables. Unless I misunderstand this requirement, that should fulfill it.

SQL data types of FK column and referenced PK column must be identical. Unless I checked it wrong, this, too should be okay.

  • lastupdateby INTEGER NOT NULL –> librarianid INTEGER AUTO_INCREMENT PRIMARY KEY
  • isbn VARCHAR(13) NOT NULL –> isbn VARCHAR(13) PRIMARY KEY
  • publisherid INTEGER NOT NULL –> publisherid INTEGER PRIMARY KEY AUTO_INCREMENT

So, what did I miss? What can be the cause of this error 150?

  • 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-08T20:18:34+00:00Added an answer on June 8, 2026 at 8:18 pm

    You are missing column references in the foreign key specifications for tables books and publishers. You need to change those lines as below:

    FOREIGN KEY (isbn) REFERENCES books (isbn),
    FOREIGN KEY (publisherid) REFERENCES publishers(publisherid),
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Query was this: CREATE TABLE `query` ( `id` int(11) NOT NULL auto_increment, `searchquery` varchar(255)
I have a table like this: CREATE TABLE book_info ( book_id VARCHAR(32) not null,
This works: CREATE TABLE shoutbox_shout ( shout_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
I have a table like this: create table `test` ( `id` bigint(20) NOT NULL
Given this: create table Location( LocationId int identity(1,1) not null primary key, Address nvarchar(max)
If my table looks like this: CREATE TABLE `daily_individual_tracking` ( `daily_individual_tracking_id` int(10) unsigned NOT
I've created a table like this : create table tbl( address varchar(5000)); If i
I have a table that's created like this: CREATE TABLE bin_test (id INTEGER PRIMARY
Given a table structure like this: CREATE TABLE `user` ( `id` int(10) unsigned NOT
I have something like this: create table account ( id int identity(1,1) primary key,

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.