mds1256 Posted November 4, 2010 Share Posted November 4, 2010 Hi Just working on a bit database design and have the following scenario: users Table = Contains ID, username and password personDetails Table = contains ID, userid, first name, surname, DoB Now when linking the table e.g. to return First and Surname for a specific username is it better to have a linking table as well, so for example (pseudo speak) Select firstname, surname from personDetails, users where personDetails.userid = users.id Or have another linking table and that to contain: id userID personDetailsID and use this to link, or does it not matter which way you link? Quote Link to comment Share on other sites More sharing options...
shlumph Posted November 4, 2010 Share Posted November 4, 2010 There's no need for a third relational table. Unless a user has many personDetails... which probably doesn't make much sense. Also, if every user has a userid, firstname, surname, DoB, username, and password, then I'd put them into one table. Quote Link to comment Share on other sites More sharing options...
mds1256 Posted November 4, 2010 Author Share Posted November 4, 2010 thanks for the info, now got my head around why and when you would use a linking table for your second comment, what is gained from putting them in one table? just thought it would be better to seperate data out like that? Quote Link to comment Share on other sites More sharing options...
shlumph Posted November 4, 2010 Share Posted November 4, 2010 There's no real need to have them in a separate table since there is a one to one relation, and the fields will *always* be filled. If some users didn't have a first name, surname, & DoB then it'd be much better to create that second table. I'm not saying it's wrong and won't work the way you have it, though Quote Link to comment Share on other sites More sharing options...
mds1256 Posted November 4, 2010 Author Share Posted November 4, 2010 Thanks, understand what you mean Im just learning this stuff so advice is welcoming 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.