Jump to content

Foreign Key


Err
 Share

Recommended Posts

Hello, I'm trying to set up a foreign key on two InnoBD tables through PHPMyAdmin. I don't see any options to allow this, and the online help documents are very confusing. I was hoping to get help with this.Here's the deal, I have two tables, one named book and the other user. In book I have an id (for the book, and also is a primary key) and a UserId (for the user). I want to link the UserId in book to the UserId in the user table. This is done with a foreign key, but I don't see the option to allow this.Here are some images to get a better idea with what I'm working with:table: booktable: userboth tablesI know this can be done, but I'm not understanding it. Can someone explain how to do this?

Edited by RahXephon
Link to comment
Share on other sites

CREATE TABLE users (...UserId INT(10) REFERENCES user(UserId),...);

By the way, by convention field names are in lowercase, with underscores (e.g. `user_id').

Link to comment
Share on other sites

  • 2 weeks later...

Yeah, even the latest version of PHPMyAdmin can't do it (if it can, I can't find it). But thank for your help justsomeguy. I found a way to manage the database without having do this.

Edited by RahXephon
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...