javascript - 分類資訊查詢的功能實現

來源:互聯網
上載者:User

類似這類的分類資訊查詢的有沒有一個思路推薦 或者 一個案例借鑒下 ,很急,線上等大神

回複內容:

類似這類的分類資訊查詢的有沒有一個思路推薦 或者 一個案例借鑒下 ,很急,線上等大神

我推薦使用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 關聯就可以了。

標籤系統

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

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.