dongnaopa6200 2014-04-03 13:20
浏览 22
已采纳

插入时如何将这些数据库表链接在一起

I'm trying to build a checklist/signoff system. Basically, I've got a form that the user fills out, see below. The user is automatically put there based on who is logged in.

http://i.imgur.com/sTysmyV.jpg

Each Checklist is attached to a specific Job number. So say a manager wants to look at Job 1000, he'll click it, navigate to "Checklists" and he'll see the checklist below.

http://i.imgur.com/kGqcyZt.jpg

Now, I have an option to select different revisions of a checklist for a job so that managers can look at different revisions.

I'm just not sure on how to string everything together.

I have 2 tables so far.

checklist_component_stock

Imgur

and checklist_revision

Imgur

I'm not sure how to link everything correctly in the tables so when Rev1 gets pulled up say for Job 1000, it shows the correct rows that have been created for that specific job and revision.

  • 写回答

1条回答 默认 最新

  • douqun1977 2014-04-03 14:30
    关注

    Assuming I'm understanding your question correctly, Each time a checklist is updated, I'm guessing that you're currently updating the existing checklist_component_stock record, and inserting the new revision information into the checklist_revision table..?

    If so, then you need to add a revision field into your checklist_component_stock table, and make this part of the foreign key to the checklist_revision table.

    Then, when a checklist is changed, insert a new record into checklist_component_stock with the new revision number, as well as inserting your new revision information into the checklist_revision table.

    Then, when you pull back a specific revision, you'll do something like:

    SELECT *
    FROM checklist_component_stock a
    INNER JOIN checklist_revision b ON a.job_num = b.job_num
                                    AND a.revision = b.revision
    WHERE a.job_num = xxx
    AND a.revision = yyy
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用