>  Q&A  >  본문

javascript - 分类信息查询的功能实现

类似这类的分类信息查询的有没有一个思路推荐 或者 一个案例借鉴下 ,很急,在线等大神

伊谢尔伦伊谢尔伦2749일 전438

모든 응답(2)나는 대답할 것이다

  • PHP中文网

    PHP中文网2017-04-10 14:56:10

    我推荐使用4个关联表来达到最灵活有效的实现。

    type 表
    id, name

    type_attribute 表
    id, type_id(关联type表的id),name,...(可以定义一些属性,比如多选,必选之类)

    type_attribute_option 表
    id, attribute_id(关联type_attribute表的id),name

    relation 表
    id, goods_id(商品的id),attribute_id(关联type_attribute的id),attribute_option(关联type_attribute_option的id)

    那么剩下的就很简单了。就按照你第二个例子里面的电影网站为例,
    type 顾名思义就是种类了,电影就是一种大的种类
    type_attribute 就是类型里面的一些属性,比如电影有类型,年代,地区,语言,属性什么的。
    type_attribute_option 就是这些属性的一些选项,比如年代有 2015,2014

    然后每个电影使用 relation 表来和 attribute 和 option 关联就可以了。

    회신하다
    0
  • ringa_lee

    ringa_lee2017-04-10 14:56:10

    标签系统

    tag_id | tags | tag_type
    1 | 2013 | year
    2 | 2014 | year
    3 | Dr.M | actor

    tag_relation
    object_id | tag_id
    1 | 1
    1 | 2

    회신하다
    0
  • 취소회신하다