简体   繁体   English

酒店预订系统数据库架构

[英]Hotel Reservation system Database schema

I am about to develop a online hotel reservation system...using php and mysql... I have some doubts about my current database schema and the business logic to get the hotels in which rooms are free between two particular dates... 我将要开发一个在线酒店预订系统...使用php和mysql ...我对我当前的数据库架构和业务逻辑存疑,以获取在两个特定日期之间免费的酒店...

Does anyone know of some kind of tutorial where i can get some idea about the hotel reservation schema and the business logics that should be used in the system...? 有谁知道某种教程,可以让我对系统中应该使用的酒店预订模式和业务逻辑有一些了解...?

Thanks for your suggestions.... 感谢您的建议。

Edit : I've figured out most of the logic... The points i am not clear about are the following... 编辑:我已经弄清楚了大多数逻辑...以下是我不清楚的要点...

  1. If a user selects more than one room in a particular hotel between two particular dates how can i represent in the following reservation table...? 如果用户在两个特定日期之间选择特定酒店的一个以上房间,我如何在下面的预订表中表示...?

    Table : Reservation 表:预订

      Field 1 : reservation_id Field 2 : room_id Field 3 : no. of Rooms Field 4 : check-in date Field 5 : check-out date Field 6 : Customer id 
  2. How can i check what rooms are available between two dates based on the reservation table and the following rooms table...? 我如何根据预订表和以下房间表检查两个日期之间的可用房间...?

    Table : Room 桌子:房间

      Field 1 : hotel_id Field 2 : room_id Field 3 : total_num_rooms 

Note : The db contains more than one hotel... So it's like a user can select a city and look for rooms available in hotels in that area between two particular dates... 注意:该数据库包含多个酒店...因此,就像用户可以选择一个城市并在两个特定日期之间查找该地区的酒店可用客房...

Also say if there are 10 numbers of room of a particular type in a hotel, i need to show only the number of rooms that are free in that particular time period..... 还要说,如果旅馆中有10种特定类型的房间,我只需要显示在该特定时间段内免费的房间数即可。

As a general thought, apply divide and conquer. 作为一般思想,应用分而治之。 Always. 总是。

For example, why do you think a specific customer should be able to have 'number of rooms' for a certain time span associated? 例如,为什么您认为特定客户应该能够在特定时间段内拥有“房间数”? What if, for example, I'm on a business trip and have my family follow me a few days later. 例如,如果我正在出差并且几天后让家人跟随我怎么办? Now, for the given time span the number of rooms is no longer a constant. 现在,在给定的时间范围内,房间数不再是一个常数。

That doesn't really matter? 没关系吗? True, you could just add another entry for the same customer. 是的,您可以为同一客户添加另一个条目。 But then again, you could have done that in the first place and simplify your logic saying that a customer can only have one room at a time in a single row, but there can be rows that create overlaps in time spans for a given customer. 但是话又说回来,您可以首先做到这一点,并简化您的逻辑,即一个客户一次只能在一个行中只有一个房间,但是对于给定客户而言,可能会有行在时间跨度上产生重叠。

Also, make sure you separate Reservation and a ReservationRequest . 另外,请确保您将ReservationReservationRequest分开。 The latter is comprised of a set of Reservations I think - because I want that room for me and my family and both criteria must be matched. 我认为后者由一系列保留构成-因为我希望为我和我的家人留出空间,并且两个条件必须匹配。

Just a few ideas. 只是一些想法。 Note that this is the ivory tower approach and it can lead to massively overblown solutions. 请注意,这是象牙塔方法,可能导致解决方案过于夸张。 In the RealWorld (TM), stick to Marcs suggestions: Analyze the actual customers need. 在RealWorld(TM)中,请遵循Marcs的建议:分析实际的客户需求。 If handling 1% of the requests increases development time by 200%, he's not gonna like (or need) it, and vice versa. 如果处理1%的请求会使开发时间增加200%,那么他就不会喜欢(或不需要)它,反之亦然。

There isn't a perfect way of representing something like an hotel reservation system. 没有一种完美的方式来表示类似酒店预订系统的内容。

Try talking to your client or people working in hotels to understand what they are doing now and base your system on this. 尝试与您的客户或酒店工作人员交谈,以了解他们现在在做什么,并以此为基础建立您的系统。

I'd guess: 我猜:

A Room has a RoomType
A Customer can Book 1..n Room(s)
A RoomType has a name and a price

... and so on. ... 等等。

If you just use a tutorial, you might end up creating a system that doesn't fit the requirements of possible users. 如果仅使用教程,那么最终可能会创建一个不适合可能的用户要求的系统。 So talk to these future end users, figure out the business logic and start coding :) 因此,与这些未来的最终用户交谈,找出业务逻辑并开始编码:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM