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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:51:29+00:00 2026-05-26T13:51:29+00:00

CREATE TABLE titlexplan( id INTEGER NOT NULL, title_id INTEGER NOT NULL , plan_id INTEGER

  • 0
CREATE TABLE titlexplan(
  id INTEGER NOT NULL,
  title_id INTEGER NOT NULL ,
  plan_id INTEGER NOT NULL ,
  start_date DATETIME NOT NULL,
  end_date DATETIME
  CHECK (start_date < end_date),
  PRIMARY KEY(id),
  INDEX (title_id),
    FOREIGN KEY (title_id)
    REFERENCES title(id)
  INDEX (plan_id),
    FOREIGN KEY (plan_id)
    REFERENCES plan(id)    
);

This is the code I am using, and I am getting a syntax error: #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INDEX (plan_id), FOREIGN KEY (plan_id) REFERENCES plan(id) )' at line 10.

I am trying to get the title_id and plan_id to update when the respective id’s from other tables update, and I’m trying to track changes.

I haven’t been able to find a clear guide for how to do this, and these queries work in part but not in whole. I don’t think that I need a primary key in this table, but I get a warning: “Warning, table contains no primary key,” when I don’t use primary keys. So, I just added the ‘id’ column. I’m not thinking it’s actually needed, though.

Please advise.

Thank you.

  • 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-05-26T13:51:30+00:00Added an answer on May 26, 2026 at 1:51 pm
    CREATE TABLE titlexplan(
      id INTEGER NOT NULL,
      title_id INTEGER NOT NULL ,
      plan_id INTEGER NOT NULL ,
      start_date DATETIME NOT NULL,
      end_date DATETIME
      CHECK (start_date < end_date),
      PRIMARY KEY(id),
    
      FOREIGN KEY (title_id)
      REFERENCES title(id)
      ON UPDATE CASCADE,
    
      FOREIGN KEY (plan_id)
      REFERENCES plan(id)
      ON UPDATE CASCADE
    );
    

    I beleive this should work. “ON UPDATE CASCADE” will cause these foreign keys to update any time the key they are referencing updates.

    Also make sure your using innoDB engine for the foreign keys to work properly.

    If you didn’t want the id column and the combination of title_id and plan_id was always unique you could do

    CREATE TABLE titlexplan(
      title_id INTEGER NOT NULL ,
      plan_id INTEGER NOT NULL ,
      start_date DATETIME NOT NULL,
      end_date DATETIME
      CHECK (start_date < end_date),
      PRIMARY KEY(title_id, plan_id),
    
      FOREIGN KEY (title_id)
      REFERENCES title(id)
      ON UPDATE CASCADE,
    
      FOREIGN KEY (plan_id)
      REFERENCES plan(id)
      ON UPDATE CASCADE   
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

create table categories(a integer unsigned NOT NULL,b integer unsigned NOT NULL,primary key(a,b)); And create
CREATE TABLE Department( DNumber integer NOT NULL PRIMARY KEY); CREATE TABLE Patient( PID integer
create table ImagenesUsuario { idImagen int primary key not null IDENTITY } This doesn't
create table snippet( id int not null auto_increment, primary key(id), idlanguage int not null,
Create table FavoriteDish ( FavID int identity (1,1) primary key not null, DishID int
CREATE TABLE jokecategory ( jokeid INT NOT NULL, categoryid INT NOT NULL, PRIMARY KEY
CREATE TABLE DEPARTMENTS (Department_Id varchar(5) Primary Key NOT NULL, Department_Name char(20) NOT NULL, Manager_Id
CREATE TABLE Customer( customer_id INT NOT NULL, first_name VARCHAR(20), last_name VARCHAR(20), PRIMARY KEY (customer_id)
create table A ( id int(10) not null, val1 varchar(255), primary key (id) );
CREATE TABLE item ( link MEDIUMINT UNSIGNED PRIMARY KEY NOT NULL, title TEXT NOT

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.