MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 16th, 2007, 03:03 AM
EToS EToS is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 2 EToS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 49 sec
Reputation Power: 0
InnoDB foreign key problem

hey guys.. wonder if anyone might be able to help with my current situation.. ive got 2 tables :

DROP TABLE IF EXISTS users;

CREATE TABLE users (
usr_id int unsigned NOT NULL auto_increment,
usr_name varchar(30) NOT NULL unique key,
usr_pass varchar(32) NOT NULL,
etc..

usr_level int unsigned NOT NULL unique key default '1',

PRIMARY KEY (usr_id),
FOREIGN KEY (usr_level) REFERENCES user_levels (l_level)
) TYPE=InnoDB;

and

DROP TABLE IF EXISTS user_levels;

CREATE TABLE user_levels (
l_level int unsigned NOT NULL unique key default '1',
l_level_desc varchar(100) NOT NULL default '',
PRIMARY KEY (l_level)
) TYPE=InnoDB;


recently i was getting errno150 (cant write table) until i realised i had to add "unique key" to "usr_level" in users table so that it matched the "unique key" attribute that "l_level" has in user levels table.. (InnoDB requires this)

now it adds fine.. but the problem after adding the unique is that i cant have many users with same access level (which i wanted)..

can anyone recommend a way under innodb to keep the l_level in user_levels unique.. but not its foreign key in users so that it can be a 1 to many relationship?

thanks for your help!!

Reply With Quote
  #2  
Old May 16th, 2007, 08:44 AM
EToS EToS is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 2 EToS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 49 sec
Reputation Power: 0
seem to of sorted it.. but adding KEY(usr_level) or INDEX(usr_level) to users table..

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > InnoDB foreign key problem


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT