duanfang7757 2017-03-13 22:13
浏览 89
已采纳

多个客户端的数据库设计提供状态更新

I am working on a project where Businesses can make accounts, then these businesses can have a number of representatives. The representatives will be sending offers to other businesses within the system. Offers can be sent to multiple businesses at once, and each business should have the ability to choose from a drop down list if they want to accept\deny\put on hold the offers they receive. I am working with PHP and so far I created everything and it's working but. When a representative who's working for business C sends an offer to businesses A and B, A and B should be able to view the offer and change their status on the offer if they wanna accept\deny\put on hold. How should I structure the database to make this possible and efficient? I currently have a table for "Businesses" A table for "Business details" A table for "Employees" a table for "offers". When an employee sends an offer to any business\es, these business\es IDs are stored in the "Offer's" table as a string and I'm retrieving the offer's details to whoever business that has their ID within that string in the "offers" table. But this way, multiple businesses can VIEW the offer but when they want to change their own stand alone status about the offer I get the issue which I am asking for help with.

Maybe on business creation I should make an extra query like 'Create table' . $business_name . '_offers' ; so every time a business is created there's a table for their offers is created but how can I define the fields for the newly created table?

Please note that I also need to be sending notifications about the offers' status changes later on. I have never done this and any help with the queries\structure would be appreciated. Sorry for the long post. Thank you!

  • 写回答

1条回答 默认 最新

  • drcb19700 2017-03-13 22:20
    关注

    Sounds like you need an intermediary table between businesses and offers. It would be something like:

    BusinessOffersTable
        OfferID
        BusinessID
        Status
    

    It's a many-many table, so for each new offer that is created, you add a record for every business it gets sent to. Then each business can modify the status for each individual offer themselves.

    OfferID    BusinessID    Status
    1          1             a
    1          2             b
    1          3             a
    2          1             a
    2          2             b
    2          3             a
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 怎么在stm32门禁成品上增加记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 解riccati方程组