需要有关数据库结构的想法/建议

发布于 2024-10-11 18:09:13 字数 584 浏览 3 评论 0原文

假设我们有 100 多家酒店,每家酒店至少有 3 种以上的房型。 我想在过去一年和未来一年保持酒店的容量。我应该如何设计数据库以最容易使用

例子:

一家酒店有 30 间客房。 10ד标准 房”、10 x “复式房”、10 x “豪华房” 房间”我会保留这个例子 标准间。今天是:2011 年 1 月 13 日 想要保留 2010 年 1 月 13 日以来的记录 至 13.01.2012 我将存储什么 数据库有可用房间。某物 像这样(标准间):

<块引用>

2011年1月13日:10

2011年1月14日:9(表示当天已售出 1 间标准间)

2011年1月15日:8(意味着当天售出 2 个标准间)

2011年1月16日:10(当天全部可用)

2011年1月17日:7(意味着当天售出 3 个标准间)

2011年1月18日:10

等...

提前致谢。

Let's think we have 100+ hotels, and each hotel has at least more than 3 room types.
I want to hold hotel's capacity for one year in the past and one year in the future. How should i design the database for easiest use.

Example:

A hotel has 30 rooms. 10 x "Standard
room", 10 x "Duplex Room", 10 x "Delux
room" I will keep this example on
standard rooms. Today is: 13.01.2011 I
want to keep records from 13.01.2010
to 13.01.2012 What i will store in
database is available rooms. Something
like this(for standard room):

13.01.2011: 10

14.01.2011: 9 (means 1 standard room sold for this day)

15.01.2011: 8 (means 2 standard rooms sold for this day)

16.01.2011: 10 (all available for this day)

17.01.2011: 7 (means 3 standard rooms sold for this day)

18.01.2011: 10

etc...

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜妞爱困 2024-10-18 18:09:13

让我试着总结一下你的问题,看看我是否理解正确:

您有一组酒店。各酒店
有一套房间。每个房间都属于
到多个可能的房间之一
类型。最低级别的细节
我们感兴趣的是这里的一个房间。

这建议有一个酒店表、一个房间类型查找表和一个房间表:每个房间都会有一个对其关联的酒店和房间类型的引用。

在任何一天,房间要么是
已预订(已售出)或未预订(让我们
为简单起见,省略部分日期
在此刻)。对于其中的每一天
前年和后年
今天,您想知道有多少
每种类型的房间均可用(未预订):
每家酒店。

现在,由于酒店需要能够单独查看预订,因此您可能会维护一个预订表。但这些通常由房间、开始日期和住宿天数来定义,这对于您声明的报告目的来说并不理想:它不会按天细分。

因此,您可能希望维护一个“房间预订日志”表,该表仅包含每天预订的每个房间的记录:这可以像日期戳列加上房间 ID 一样简单。

这种模式可以让您通过聚合查询相对轻松地生成您所描述的输出(例如,显示每天预订的房间总数,按酒店和房间类型分组)。该模型似乎也适合 OLAP 多维数据集

Let me try to summarize your question to see if I understand it properly:

You have a set of Hotels. Each Hotel
has a set of Rooms. Each Room belongs
to one of a number of possible Room
Types. The lowest level of detail
we're interested in here is a Room.

This suggests a table of Hotels, a lookup table of Room Types, and a table of Rooms: each Room will have a reference to its associated Hotel and Room Type.

For any given day, a room is either
booked (sold) or not booked (let's
leave off partial days for simplicity
at this point). For each day in the
year before and the year after the
current day, you wish to know how many
rooms of each type were available (non-booked) at
each hotel.

Now, since hotels need to be able to look at bookings individually, it's likely you would maintain a table of bookings. But these would typically be defined by a Room, a Start Date, and a number of Nights, which isn't ideal for your stated reporting purposes: it isn't broken down by day.

So you may wish to maintain a "Room Booking Log" table, which simply contains a record for each room booked on each day: this could be as simple as a datestamp column plus a Room ID.

This sort of schema would let you generate the output you're describing relatively easily via aggregate queries (displaying the sum of rooms booked per day, grouped by hotel and room type, for example). The model also seems like it would lend itself to an OLAP cube.

同尘 2024-10-18 18:09:13

我曾经做过这样的家庭作业。基本上,您至少需要 3 张桌子:一张保存房间,一张保存预订,另一张桌子也链接在一起,因为它不是在给定时间预订的特定房间,而是特定类型的房间。

I did a homework question like this once. Basically you need at least 3 tables: one which holds the rooms, one which holds the reservations, and another table that links the too because its not a specific room that is reserved at a given time, its a specific type of room.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文