473,387 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

MySQL Query Browser

Below is a script i think should be running correctly.
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE Sponsor(SponsorID INT, 
  2.     Companyname VARCHAR (20),
  3.     ActivitiesID INT NOT NULL,
  4.     UNIQUE(ActivitiesID),
  5.     Foreign Key (ActivitiesID)REFERENCES Activities(ActivitiesID),
  6.     Primary Key (SponsorID)) ENGINE=InnoDB;
  7.  
  8. INSERT INTO Sponsor VALUES (1,'Red Bull'),(2,'Nike')
  9. ,(3,'YMCA'),(4,'Mercedes'),(5,'Lucozade'),(6,'BHF');
  10.  
  11. CREATE TABLE Activities(ActivitiesID INT, 
  12.     Name VARCHAR (20), Maxcapacity INT, 
  13.     StartTime TIME, EndTime TIME,
  14.     Primary Key (ActivitiesID)) ENGINE=InnoDB;
  15.  
  16. INSERT INTO Activities VALUES (1,'Aerobics', 3,
  17.  '10:00:00', '12:00:00'),(2,'Bicycling', 6, 
  18. '08:30:00', '13:00:00'), (3,'Circuit', 10, 
  19. '14:00:00', '16:30:00'), (4,'Rowing', 5, 
  20. '06:00:00', '15:00:00'), (5,'Swimming', 4,
  21. '13:30:00', '17:00:00'), (6,'Badminton', 8, 
  22. '15:30:00', '17:30:00');
But whenever i run the above queries, I get 'can't create sponsor'; errono 150.

How do i correct this?
Feb 11 '12 #1
1 1964
Dormilich
8,658 Expert Mod 8TB
from the manual:
1005 (ER_CANT_CREATE_TABLE)

Cannot create table. If the error message refers to error 150, table creation failed because a foreign key constraint was not correctly formed. If the error message refers to error –1, table creation probably failed because the table includes a column name that matched the name of an internal InnoDB table.
so it seems that something is wrong with your FK definition. (e.g. the Activities table does not exist yet)
Feb 12 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: joemyre | last post by:
Hi everyone, What I'm trying to do is take php variables i got from user input, and pass them as the MySQL query terms. $query = "select * from ident where ".$searchtype1."=".$searchterm1."";...
1
by: PW Herman | last post by:
Does mySQL not like dashes or something? I seem to be getting the following error: "Unknown column 'etrans' in 'where clause'" when I do the following query: SELECT * from expense where...
0
by: Murphy | last post by:
I am currently migrating a db from SQL Server & MySQL and ? (front end yet to be decided upon) As I familiarise myself with MySQL populating tables etc can be quite clumbersome. After reading the...
2
by: Don | last post by:
I'm new to MySQL and am having a frustrating time figuring out some of the tools. I'm getting ERROR 1044 when I try to execute the following sp. ------------------------------ DELIMITER $$ ...
0
by: taras.di | last post by:
Hi everyone, I've come across an extremely strange problem. The exact same query in both mysql command line client, and mysql query browser gives entirely different results. I was hoping someone...
2
by: Flic | last post by:
Hi, I have a basic db that I access with MySQL query browser. Everything seems fine to me but I am using this db as part of a php shopping basket and when I try to add an item I get: Notice:...
1
by: stmfc | last post by:
i am trying to set up mysql query browser gui. the gui is asking for input for the following connection parameters: connection: username: password: host: port: schema: here i cannot figure...
2
by: stmfc | last post by:
i have a problem with user creation for mysql db i think the problem stems from string style. GRANT ALL ON newDB.* TO 'test'@'localhost' IDENTIFIED BY 'test'; i am...
3
by: muruga | last post by:
Hi to everybody can any one give me suggestions about how to download mysql query browser for redhat linux 9.0 for mysql version 3.23.54. I had tried it by downloading...
3
by: emsik1001 | last post by:
Hi http://dev.mysql.com/doc/query-browser/en/mysql-query-browser-connection.html I'm trying to connect from my Windows based PC to a dedicated server which is running on Linux system. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.