What type of database to use?

0

If I have a database in MySQL with a user table, and I want to store information inherent to each user, such as their profile image, conversation histories, or simply images or files that this user upload.

What database should I use so that other users can access this data?

With access I mean for example when you see that a user is connected you see your profile image or when you go to your profile you can see without downloading what files you have uploaded, I have read that MySQL is not the best for these tasks.

    
asked by latiagertrutis 29.06.2017 в 13:05
source

2 answers

0

First of all, indicate that what you should not do is store the files in the database, what you should keep are the references to them, create fields of type Varchar (XXX) and save the name of the file that has been uploaded the user.

On the other hand, MySQL is a very suitable database to do what you comment, analyze the requirements you have, define the entities and based on these define the table / s that you need for it. Because of what little you do, you already need two tables, one for the user's data (in one field it would save the avatar) and another for the documents that users upload.

Then it's just a matter of making queries to retrieve the information and upload the list of files that you have uploaded without having to download them.

I hope I have clarified the doubts.

Greetings!

    
answered by 29.06.2017 / 13:12
source
1

I explain. In my case, what I would do is save the assets in a folder, for example:

/public/images/{{user_id}}/avatar.png

(this on the server that hosts your site) Then to show the profile image of a user on your site it would be enough to put

<img src="/public/images/{{user_id}}/avatar.png" />

Clearly take care of guiding the logic so that what is between {{}} is replaced by functional information.

Now that with saving the id of your users in the BD is enough. For the other images with creating an "images" entity that has a "ref" attribute that refers to the name with which the file is saved, you could save them in:

/public/images/{{user_id}}/{{img_ref}}.{{date}}.jpeg

and create a one-to-many relationship between the "users" and the "images" would be ready;)

    
answered by 27.04.2018 в 19:42