且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

最有效的方式来存储在数据库中的照片参考

更新时间:2023-11-25 17:08:58

***的和最常见的答案是:选项B - 关系表用户表具有以下字段加入

The best and most common answer would be: choice B - Relational Table joined on user table with the following fields.

id
order
user_id
desc
photo_url_800
photo_url_150
photo_url_45
date_uploaded

混合,其中,您分别保存的文件名,并与您的业务逻辑层添加的照片目录。

Or a hybrid, wherein, you store the file names individually and add the photo directory with your business logic layer.

我的分析,你的第一个选项是一个不好的做法。逗号分隔的字段是不可取的数据库。这将是很难为你更新这些领域并在其上添加描述。

My analysis, your first option is a bad practice. Comma separated fields are not advisable for database. It would be difficult for you to update these fields and add description on it.

关于表的优化,你可能想看看这些文章:

Regarding the table optimization, you might want to see these articles:

  • Optimizing MyISAM Queries
  • Optimizing InnoDB Queries