简体   繁体   中英

Database to use for storing profile information

I'm making an application for android which is used to store profile information of a user( FirstName, LastName, Email, Username, Password ). It will also store profile picture of the person. You can think of applications like WhatsApp, Viber Tango. There are many more like it.

In order to store and access this information easily and efficiently, how should these information be stored? I'm thinking about storing this information in Relational Database like MySql. I will have FN,LN,Email,Username, password and link to profile picture as columns of table. One more issue I had in mind is that if a user has say 100 friends, should I create a new table per user so that all his/her friends can be separate and accessed from single table or I should run some complex SQL query so that it returns list of friends of user?

Thanks a lot

I believe you are on the right track. MySQL is a fine choice for storing the data as long as it is on a server that can be accessed by your application.

You will need 2 tables: one to store all of the users and another to map the users friends.

Your users table will be pretty straight forward as you have already laid out. The other table (could be named something like user_friends ) would have a column containing the id of the friend that made the request, another column containing the id of the friend that accepted the request, and any other x amount of columns you may need to contain information about the friendship. Any record without an id for the accepted friend can be displayed as a pending request.

I would make sure that there can only be one record containing a mapping of friends to prevent duplicates as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM