Hi, I’m working on creating a social network site. On the profile page there are multiple widgets that display user information from different tables(some of which have foreign relationships with other tables). Anyone would like to share their experience on how to design this page and Active Record classes while minimizing the amount of processing and database connections?
I would recommend putting a lot of columns in one table that cover the basics (name, email, website, etc). By doing this, you will put less load on the database since there are few joins (if any). When I built my first website, I got too caught up with db normalization that I often needed to join 16 tables to return a single doc ID. I don’t think a profile page will require more than 2/3 tables.
That depends on the nature of those records. A good starting metric is the number of entries in the DB (that’s mostly fast to fetch. If not, your RDBMS sucks). Anotehr approach is to take the highest value of a last_updated field (should be covered by an index).
It might be more complex than that. Impossible to tell without knowledge of your database layout
The tables that I have is like a user having multiple addresses, multiple schools. Then I have “Addresses” widget and “Schools” widget, which will display all rows in the table they’re associated with.