Question

I want to store data of news Feed . News feed contains image , video , audio , text . How to store all these together in database ?
I have table

post(postid , userid , post_content , post_time);

For Video ,audio and image we are using directory For every user. So when ever they will upload video , audio , image then this will be stored in their directory . But how to put all these together in database . So that we can apply classes to style image , text e.t.c , I am unable to combine all these and put together so that this it can be stored in Database as content.

I have idea like this

post(postid , userid , text_content , post_type , post_time);

post_image(id , postid , path);

post_video(id , postid , path );

post_audio(id, postid , path );

post_type is used for image = 0 , video = 1 and audio =2 assuming user can post only one of them either image or video or audio .

Is this a good idea to store News Feed in database . Any help will be appreciable .

I am using PHP , MYSQL , Apache .

Was it helpful?

Solution

Here is an similar question here on SO with further information and references how you could save images and audio in MySQL.

BUT IT'S NOT RECOMMENDED

Each file will have a few MB, so your MySQL Database will grow pretty big.

As @ksealey mentioned in the comments you need to store the path to the saved file in the database, this is best practice for MySQL Databases and the common way to do it.

Instead of hardcode the path to the file you just refer to the database entry for the images and audios.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top