How would I structure database the best?

What is the best MySQL database structure for a social networking website?

  • How would you structure a MySQL database for a social networking website? Would you use one database for every user and tables within the databases to store user data such as friends and activities or, would you create one database for the social network and have multiple tables that has all users' friends and activities?

  • Answer:

    Firstly, I would choose one database for the website. The reason for it is that it takes more time to walk through different databases than to walk through tables within a database and that time difference is quite considerable. If you will be creating a database for each user, there will be serious performance issues. Plus maintaining relationship among entities will be very difficult. How will you structure a MySQL database? That depends on what I am creating. In general identify the entities in your project then attributes associated with them then how the entities are related. So these entities will become your table and attributes will be columns in them respectively. The relationship sometimes also needs a table. For a social network, User will be entity and her details will be attributes. The relation between two users, friends, will also need a table to store(who is friends with whom).

Neeraj Khandelwal at Quora Visit the source

Was this solution helpful to you?

Other answers

Normally, for one application with its group of related entities, you would use one database ("schema"). Within that schema you should apply the usual modelling and normalisation disciplines based on your application's specific requirements and business rules. See any good relational text, such as Fabian Pascal's Practical Issues in Database Management or many others.

Toby Thain

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.