代码之家  ›  专栏  ›  技术社区  ›  BDuelz

如何将照片标记为用户的“个人资料图片”?

  •  -1
  • BDuelz  · 技术社区  · 15 年前

    文件夹结构类似于

    public_html/
    upload/
        user-123/
            profile-199/
            profile-321/
                images/
                    123423.png
    

    我提议的表结构是这样的

    id
    profile_id
    filename  (or maybe extension only, since filename will most likely just be the primary id for that photo)
    profile (boolean field of whether this a profile pic or not)
    date_added
    

    我应该如何处理特殊的图像,如个人资料图片?

    编辑:

    3 回复  |  直到 15 年前
        1
  •  0
  •   Mark Byers    15 年前

    这将工作,但它会有一个问题,多张照片可以被标记为个人资料照片,除非你特别注意防止这一点。

    另一种设计是有一个带有列的表 user_id special_photo_id 其中photo\u id是photos表中的外键。这有一个稍微不同的问题:现在有可能有一张不属于用户的特殊照片。

        2
  •  0
  •   Iznogood    15 年前

    您可以在users表(其中存储用户名和其他信息)中有一个字段,其中profile\ id字段init指向profiles表。这样你就得到了一个可能的个人资料,并离开去确定它。

        3
  •  0
  •   gsharma    15 年前

    图像表如下所示:

    id
    profile_id
    filename    
    date_added
    

    我想你会有更多的非特殊图像比特殊。因此,大多数情况下,您建议的字段“profile(boolean)”将为0。

    编辑:我相信@Iznogood也是这么说的。