数据库逻辑问题,为事件设置通行证
我正在开发一个系统,人们可以在其中预订门票和某些活动通行证(汽车通行证等)。
事件发生在一天或多天。这些通行证可以链接到多个事件。他们可以有默认价格和每张票的通行证比率(因此,如果您购买 3 张票,则可以免费获得 1 张通行证)。不过,这些默认参数应该能够根据每个事件进行更改。将通行证链接到活动时,我希望能够将通行证也链接到活动的某些日期。我有点被困在这里,我原来的数据库设计似乎有缺陷。这是我目前拥有的:
tblPass
passID
name
price
ticketratio
tblEvent_pass
passID
eventID
price
ticketratio
最后,在下订单后,将在其中放置保留通行证的表格:
tblEvent_pass_reservation
reservationID
passID
day
totalPaid
totalFree
但是,通过这种设置,我似乎一直遇到麻烦。有人可以看一下这里并告诉我我做错了什么吗?我很乐意回答您有关通行证概念的任何问题。非常感谢。
I'm working on a system where people can book tickets and certain passes for events (car passes, etc.).
An event takes place on one or more days. The passes can be linked to multiple events. They can have a default price and pass per ticket ratio (so if you buy, say, 3 tickets you get 1 pass free). These default parameters should be able to be changed on a per event basis, though. When linking a pass to an event, I want to be able to link the pass to certain days of the event aswell. I'm kind of stuck here, my original database design seems to be flawed. Here's what I currently have:
tblPass
passID
name
price
ticketratio
tblEvent_pass
passID
eventID
price
ticketratio
then finally, a table where the reserved passes get put in, after the order has been made:
tblEvent_pass_reservation
reservationID
passID
day
totalPaid
totalFree
However, with this setup, I seem to keep running into trouble. Could someone have a look here and tell me what I'm doing wrong? I'll gladly answer any questions you have about the concept of the passes. Thanks a bunch.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想我解决了你的问题。
好吧,在我看来,您的问题在于您将通行证与活动而不是活动日表关联起来。
看下面的结构:
-tblPass (passID, ...)
-tblEvent(事件 ID、描述、...)
-tblEventDay(eventDayID,eventID, day (date), ...)
现在您需要将事件日与 pass 表链接起来,以便我们创建另一个 eventday-pass (N 到 N)连接:
< strong>tblEventDay_Pass(eventDayID, passID, PricePaid, ... )
如果您将“门票”视为基本单位,则必须将门票与活动日期相关联,例如“封闭的活动只能负担得起” 15,000 人,所以你只有 15,000 张门票”。如果是这样,tblEventDay_Pass 将获得一个 TicketID,该 ID 与活动的可用门票相同。您需要创建另一个工单表并将其链接到事件表。
像这样的东西:
https://i.sstatic.net/EUrAM.jpg
希望有帮助!:)
I think I got your problem right.
Well, in my way of view, your problem is that your are associating a pass to an event instead of an event-day table.
Look at the following structure:
-tblPass (passID, ...)
-tblEvent (eventID, description, ...)
-tblEventDay(eventDayID,eventID, day (date), ...)
Now you need to link your event days with the pass table so we create another eventday-pass (N to N) connection:
tblEventDay_Pass(eventDayID, passID, pricePaid, ... )
If you consider the "ticket" as your base unit you'll have to link tickets to event days, like "a closed event can only afford 15.000 people so you will only have 15.000 tickets". If so, the tblEventDay_Pass will get a ticketID which will be the same ID as the available tickets for the event. You'll need to create another Ticket table and link it to the events table.
Something like this:
https://i.sstatic.net/EUrAM.jpg
Hope it helps!:)
有几种方法可以对此进行建模:
您可以创建一个 event_day 表来存储每个事件发生的各个日期
(event_day_id,event_id,datetime)
然后是一个表,用于将通行证映射到事件日 pass_event_day
(pass_id,event_day_id)
there are a few ways to model this:
you could create a event_day table to store the individual days each event is on
(event_day_id,event_id,datetime)
then a table to map the pass to the event days pass_event_day
(pass_id,event_day_id)