dongtan3395 2015-02-25 17:25
浏览 26
已采纳

CakePHP数据库设计:工作板的关联

Hy everyone.

I'm actually building a job board with CakePHP and a little help for designing the database will be appreciated!

I have a table jobs with differents foreigns keys: id, recruiter_id, title, sector_id, division_id, experience_id etc.

The associated table (sectors, divisions and experiences) have the same configuration id, name and job_count and sometimes on or two other fields (like company_count for sectors).

So I would like to know if there is better way to design these tables. I thought for putting the three of them in one table named lists with the keys: id, value and list_name. With this configuration I have just one request to do to get all the list and not 3.

My question is what is the "good way" solution ? May be there's another one ?

  • 写回答

2条回答 默认 最新

  • douyi6922 2015-02-26 09:58
    关注

    I think a found a solution by using a system of taxonomy. I created a table terms which contain the list of all terms that can be associated (sector, division, type of contrat, etc.).

    Table terms id, name, type

    And I created a second table term_relationships which contain all the association including the name of the model that is associated.

    Tabe term_relationships id, ref, ref_id, term_id

    "ref" refers to the associated model (example: Job or Applicant in my case), the "ref_id" refers to the associated data (which job or which applicant) and term_id refers to which terms is associated. I think is the most evolutive and cleaner solution.

    Thanks all for your help (especially Grafikart from where I get the idea) and hope that this topic can help someone else !

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)