Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 4th, 2013, 10:39 AM
arson714 arson714 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 2 arson714 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 46 sec
Reputation Power: 0
Angry Database help

I'm extremely new to this (n00b!) but I am having some troubles creating a table and I suspect the foreign key is the culprit.

Here's what I have done so far:

Create database test;
Use test;
Create Table students (sid char(20), name char(20), login char(20), age integer, gpa real);
Insert into students (sid,name,login,age,gpa) values (1, ‘Wayne’, ‘bwayne@123.com’,25, 3.95);
Insert into students (sid,name,login,age,gpa) values (1, ‘Kent’, ‘ckent@123.com’,27, 3.91);
Select * from students;
Update students s set s.age = s.age +1, s.gpa = s.gpa -1 where s.sid = 1;
Select * from students;
Alter table students add constraint unique (name,age);
Alter table students add constraint studentskey primary key (sid);

When I attempt to add the following I get 'Error 1005 (HY000): Can't create table 'testing.enrolled' (errno: 150)

create table enrolled (studid char(20),cid char(20),grade char(10),primary key (studid, cid),foreign key (studid) references students);


Any help would be greatly appreciated! As I said, I'm very new to this and am probably doing something easy, incorrectly.

Reply With Quote
  #2  
Old March 4th, 2013, 10:41 AM
arson714 arson714 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2013
Posts: 2 arson714 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 46 sec
Reputation Power: 0
OMG. I'm an idiot.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > Database help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap