stublackett Posted February 25, 2008 Share Posted February 25, 2008 Hi, I've made 3 tables Tables are setup like User Table UserID username fullname email password level address1 address2 city postcode userlevel Ideas Table IdeasID title description category image User_Ideas UserID IdeasID I'm using PHPMyAdmin and what I'd like to do is create a relationship between the User_Ideas table and the Users and Ideas table using the Primary Keys as indexes (Note there are underlined) How do I link the tables together, So that when say an Idea is added to the ideas' table, It then links to the User_Ideas table and inserts the values of the relationship Any ideas on : a) How to do this in PHPMyAdmin !? OR b) How to do this in Pure MySQL Code? Thanks Quote Link to comment Share on other sites More sharing options...
fenway Posted February 25, 2008 Share Posted February 25, 2008 I don't know what you mean by "inserts the values of the relationship". Quote Link to comment Share on other sites More sharing options...
stublackett Posted February 25, 2008 Author Share Posted February 25, 2008 I don't know what you mean by "inserts the values of the relationship". Ok, A user signs up to the sight for instance He is then given a UNIQUE UserID of 1 - For Example Purposes He submits an Idea which has the IdeasID of 1 also So the user_ideas table contains the UserID = 1 IdeasID = 1 and this will then make sure that the Idea submitted by the user is Unique to them and paired to them Quote Link to comment Share on other sites More sharing options...
fenway Posted February 25, 2008 Share Posted February 25, 2008 You can use LAST_INSERT_ID() to get back the user_uid... and use this in subsequent inserts. You can also have the relational table have unique index contraints. But "making sure" is still ambigious. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.