On 3 January 2011 01:10, Marnen Laibow-Koser <[email protected]> wrote: > David Zhu wrote in post #971909: >> Hello, >> >> I have a user table that stores their username, email address, and >> password. (along with salt, etc) >> >> However, now I want to have more complex information associated with >> each user (address, etc). I'm no DBA expert, so in terms of >> performance, which is better: >> >> - A user table that has all the fields in it (Username, Email, >> password, country, state, zipcode, etc) >> - A user table that only has username/password/email, that is >> connected via a foreign key to another table that stores all the other >> fields. >> >> Which is better? And why? > > The first will be slightly better in terms of performance, because > you're not joining tables. But if your tables are properly indexed, the > join should have a negligible effect on performance. > > However, I don't see why you'd use the second approach. It's more > complex for no particular gain.
The one time you might want to keep addresses, for example, in a separate table, would be if your app had the concept of multiple users at the same address. You might have family membership of a club for example. In this case it would be a bad idea to save the same address a number of times for each member of the family. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

