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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:39:25+00:00 2026-06-04T03:39:25+00:00

I am getting errorno:150 with MySQL. While i am trying to create the third

  • 0

I am getting errorno:150 with MySQL. While i am trying to create the third table it shows Can’t create table. Following is the complete query.

CREATE DATABASE `test`;
USE `test`;

-- --------------------------------------------------------

--
-- Table structure for table `product`
--

CREATE TABLE IF NOT EXISTS `product` (
  `product_no.` int(10) NOT NULL AUTO_INCREMENT COMMENT 'This number represent a unique product',
  `name` varchar(50) NOT NULL ,
  `price` decimal(5,2) NOT NULL COMMENT 'Price should have a fomat like 25.90',
  `max_Rating` int(10) NOT NULL COMMENT 'Maximum available rating for each product (n)',
  PRIMARY KEY (`product_no.`)
);

-- --------------------------------------------------------

--
-- Table structure for table `user`
--
CREATE TABLE IF NOT EXISTS `user` (
  `user_id` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `password` varchar(20) NOT NULL,
  PRIMARY KEY (`user_id`)
);

-- --------------------------------------------------------

--
-- Table structure for table `rating`
--
CREATE TABLE IF NOT EXISTS `rating` (
  `s.n.` int(10) NOT NULL AUTO_INCREMENT,
  `product_no.` int(10) NOT NULL,
  `user_id` int(10) DEFAULT NULL,
  `given_rating` int(10) DEFAULT NULL,
  PRIMARY KEY (`s.n.`),
  foreign key (`user_id`) references `user(user_id)`,
  foreign key (`product_no.`) references `product(product_no.)`
);

Is there any field mismatch happening? I am stuck now.

  • 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-04T03:39:27+00:00Added an answer on June 4, 2026 at 3:39 am

    It looks to be related to the quoting in your foreign key definitions.

    CREATE TABLE IF NOT EXISTS `rating` (
      `s.n.` int(10) NOT NULL AUTO_INCREMENT,
      `product_no.` int(10) NOT NULL,
      `user_id` int(10) DEFAULT NULL,
      `given_rating` int(10) DEFAULT NULL,
      PRIMARY KEY (`s.n.`),
      /* Remove the backquotes surrounding user(user_id) and product(product_no.) */
      foreign key (`user_id`) references user (user_id),
      /* Inside the parens, `product_no.` should be quoted because of the period */
      foreign key (`product_no.`) references product (`product_no.`)
    );
    

    I would just note that you won’t often encounter tables named with special characters in them like s.n or product_no.. Although they are permitted and work when quoted, it is somewhat uncommon to use them owing to the quoting need they introduce. It would not otherwise be necessary to quote a column named product_no without the ..

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

Sidebar

Related Questions

Getting a 'marshal data too short' error when trying to install the mysql gem
I'm trying to execute this code nmea2kml.cpp but I keep getting the following errors.
For some reason I am getting the error No database selected I have no
Getting started with NHibernate How can I generate identity fields in nHibernate using Hilo
Getting the above error in following code. How to rectify it. Thanks. Please look
I am getting error no more tables permitted in this cluster when trying to
I'm trying to run a very simple integration test and keep getting this error:
I'm getting the following error: No route matches {:action=>show, :controller=>events} My routes.rb file has
Short question: How can I use createLink in a Filter? I'm getting error: No
I'm trying to build a fairly complex hash and I am strangely getting 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.