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
我想存储新闻Feed的数据。新闻源包含图像,视频,音频,文本。如何将所有这些存储在数据库中?我有桌子
post(postid , userid , post_content , post_time);
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.
对于视频,音频和图像,我们使用目录为每个用户。因此,当他们上传视频,音频,图像时,这将存储在他们的目录中。但是如何将所有这些放在数据库中。因此我们可以将类应用于样式图像,文本e.t.c,我无法将所有这些组合在一起并放在一起,以便它可以作为内容存储在数据库中。
I have idea like this
我有这样的想法
post(postid , userid , text_content , post_type , post_time);
post(postid,userid,text_content,post_type,post_time);
post_image(id , postid , path);
post_image(id,postid,path);
post_video(id , postid , path );
post_video(id,postid,path);
post_audio(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 .
post_type用于image = 0,video = 1和audio = 2,假设用户只能发布其中一个图像或视频或音频。
Is this a good idea to store News Feed in database . Any help will be appreciable .
将News Feed存储在数据库中是一个好主意。任何帮助都会很明显。
I am using PHP , MYSQL , Apache .
我正在使用PHP,MYSQL,Apache。
1 个解决方案
#1
0
Here is an similar question here on SO with further information and references how you could save images and audio in MySQL.
这里有一个关于SO的类似问题,有关于如何在MySQL中保存图像和音频的更多信息和参考。
BUT IT'S NOT RECOMMENDED
但是不推荐
Each file will have a few MB, so your MySQL Database will grow pretty big.
每个文件都有几MB,所以你的MySQL数据库会变得非常大。
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.
正如@ksealey在评论中提到的那样,您需要在数据库中存储保存文件的路径,这是MySQL数据库的最佳实践,也是常用的方法。
Instead of hardcode the path to the file you just refer to the database entry for the images and audios.
您只需引用图像和音频的数据库条目,而不是硬编码文件的路径。
#1
0
Here is an similar question here on SO with further information and references how you could save images and audio in MySQL.
这里有一个关于SO的类似问题,有关于如何在MySQL中保存图像和音频的更多信息和参考。
BUT IT'S NOT RECOMMENDED
但是不推荐
Each file will have a few MB, so your MySQL Database will grow pretty big.
每个文件都有几MB,所以你的MySQL数据库会变得非常大。
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.
正如@ksealey在评论中提到的那样,您需要在数据库中存储保存文件的路径,这是MySQL数据库的最佳实践,也是常用的方法。
Instead of hardcode the path to the file you just refer to the database entry for the images and audios.
您只需引用图像和音频的数据库条目,而不是硬编码文件的路径。