dongmei5168 2016-06-28 09:28
浏览 28
已采纳

MySql什么是插入预订的最佳方式

I have a database that looks like this

enter image description here

I was wondering with the separate tables and such, do i insert everything one table at a time, Like insert a row in booking, insert a row in the Customers, and last insert a row in Booking_has_Customers? Is there an easier way to do this?

Halls is unchanging just in case they have more rooms to hire.

And when retrieving data from the database, is it best to use a join on the foreign keys to get a full overview incase i need all data?

Thanks in advance!

  • 写回答

1条回答 默认 最新

  • dongpo5264 2016-06-28 09:42
    关注
    1. No there is no easier way, you need to insert the data to each table individually. However, this is the exact situation that asks for transactions. Transactions ensure that either all required insertions happen, or none of them.

    2. This question is pretty broad and cannot be generally answered. If it makes sense to retrieve data from multiple tables, then joins could be a good answer and foreign keys are good starting points for a join condition. But a join condition may have contain expressions beyond the foreign keys. It all depends the actual use case.

    I would rather ask specific questions for specific use cases for reports / queries in separate questions. This way you can get answers tailored to the exact question.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥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 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染