douba3378 2011-11-08 09:59
浏览 57
已采纳

如何添加多个人员进行项目并将这些项目显示给员工(PHP + MySQL)

I don't know if i should ask this question here, but it's related to database development/programming.

I am developing a project management application, everything seems to work fine, There's a projects table for projects and staffs table for staffs and so on.

Right now i am using PHP + MySQL, this is for the beta version, later i will be using NoSQL databases.

The problem i am facing is how will i add multiple staffs to the project, Should i do like this i..e add a field in projects database which will have list of all staffs like staffs = 1,2,34,2 or staffs = 'user1, user2, emailaddress

If i do like this, how would i display the list of projects staffs are assigned to.., when staffs login, I mean i could do this, but it wont be very straightforward.., and the idea i have in mind on to do this is just horrible, i..e like as soon as the staffs log in check every project's staffs field and if they are in that list display that project to them.

Do you guys have any idea in mind on how to go about this, if so please let me know.

  • 写回答

1条回答 默认 最新

  • douzhanshen0657 2011-11-08 10:08
    关注

    Building your application with a relational database, and when it's done - you switch to a NoSQL Database? Don't! NoSQL is a different approach, and it will cost you a lot of time!

    Besides that, I think you want a table to link your projects to your staffs. This table will contain a project id and a staff id (this will also be the primary key).

    Selecting projects for the staff can be as easy as:

    SELECT p.projectName 
    FROM staffProjects AS sp 
    INNER JOIN projects AS p USING (projectID) 
    WHERE staffID = 1";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集