MadTechie Posted April 8, 2007 Share Posted April 8, 2007 OK i have been setting up a database which is getting more and more complex, howeven while i was designing it and started to wonder if i am setting the tables up the best way.. heres a basic example of what i have neen doing UserTable ID UserName Group [/td] 1 User1 Group1 2 User2 Group2 Items ID ItemName Weight 1 Item1 100g 2 Item2 200g 3 Item3 300g 4 Item4 400g Now the question in the example above i'll have another table called UserItems ID UserID ItemID 1 2 1 2 2 2 3 2 4 this would be if the user2 picked items 1,2 & 4, now is this the best way of doing this and do i need the ID on the 'UserItems' table ? Quote Link to comment https://forums.phpfreaks.com/topic/46117-solved-advice-wanted/ Share on other sites More sharing options...
fenway Posted April 8, 2007 Share Posted April 8, 2007 You should have a UID in every table with rare exceptions... this is the best way as far as DB normalizati on is concerned. Quote Link to comment https://forums.phpfreaks.com/topic/46117-solved-advice-wanted/#findComment-224435 Share on other sites More sharing options...
veridicus Posted April 8, 2007 Share Posted April 8, 2007 If the only purpose of UserItems is to join the other two tables together, then there's no need for it to have its own unique ID. Whether it has an ID or not, you should place a unique index on UserID, ItemID. Quote Link to comment https://forums.phpfreaks.com/topic/46117-solved-advice-wanted/#findComment-224477 Share on other sites More sharing options...
MadTechie Posted April 9, 2007 Author Share Posted April 9, 2007 Cool, i know the UID isn't needed but database explainsion is unforseen thus i try to always have one thanks for the responce, i was sure i was doing this the correct way, i just wanted to check i wasn't living in the past.. lol Quote Link to comment https://forums.phpfreaks.com/topic/46117-solved-advice-wanted/#findComment-224603 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.