简体   繁体   English

特定查询的关系数据库设计结构

[英]relational database design structure for a specific query

I have a database problem where I am suppose to design a tour database. 我在设计游览数据库时遇到数据库问题。 they keep track visitors, tickets, and the attractions (such as palace or local shows) that they visit. 他们会跟踪访客,门票和他们参观的景点(例如宫殿或当地表演)。 We assume that each visitor has to buy a ticket to enter the tour. 我们假设每个游客都必须购买门票才能进入旅游。

Each ticket is valid for only one day, and there are no special tickets for children or families etc. But there are several classes of tickets, in particular Gold, Silver, and Bronze tickets. 每张票仅有效一天,并且没有针对儿童或家庭等的特殊票。但是有几种票,特别是金,银和铜票。 A Gold ticket is more expensive, but then most of the attractions in the tour are free or 金票比较贵,但是游览中的大多数景点都是免费的或
at least fairly cheap. 至少相当便宜。 For Silver and Bronze tickets, there may be significant extra charges for most of the attractions. 对于银牌和铜牌门票,大多数景点可能会收取大量额外费用。 Thus, a person planning to spend the whole day and do as many rides as possible may want to buy a Gold ticket, while others are better off with a Silver or Bronze ticket. 因此,计划花一整天时间并尽可能多骑车的人可能想购买金票,而其他人最好购买银票或铜牌。

Ticket prices, as well as the extra charges per attraction for each ticket class, may depend on the season, and may change over time. 门票价格,以及每个门票类别的每个景点的额外费用,可能取决于季节,并可能随时间而变化。 Thus, during Spring Break 2013 Season there may be one set of prices, while during the Peak Summer Season 2013 there may be another set of prices. 因此,在2013年春假期间,可能会有一套价格,而在2013年夏季高峰季节时,可能会有另一套价格。 Each attraction has a unique name (eg, Glass museum or gold mine), and whenever a visitor visits an attraction, the database should store information about the ticket held by the visitor and about when exactly the visitor entered the attraction. 每个景点都有一个唯一的名称(例如,玻璃博物馆或金矿),每当游客访问景点时,数据库应存储有关游客所持门票的信息以及游客确切进入景点的时间。

Visitors
(v_id,visitor_name)

Ticket_purchase
(v_id,t_id,date)

Tickets
(t_id,class,price,season)

Attractions
(t_id,attraction_name,goldextracost,silverextracost,bronzeextracost)

Attraction_visited
(v_id,t_id,attraction_name,datetime)

Now if I want to output the number of people who bought a Bronze ticket but who would have saved money if they had bought a Gold ticket (because they visited a lot of attractions where they had to pay extra during that day) 现在,如果我要输出购买青铜票但如果购买金票本来可以省钱的人数(因为他们参观了很多景点,因此当天不得不多付钱)

Is it possible with the above tables or I need some structural changes?? 上面的表格是否可能,或者我需要进行一些结构上的更改?

from what i can see you overwrite the ticket price when you change it... because of this you cannot look back at different ticket prices... as i undrstand ticket prices can change you would have to add to the tickets a field for the date when you created the new price. 从我可以看到的角度来看,当您更改机票价格时,您会覆盖它的价格...因此,您不能回头查看不同的机票价格...因为我无法理解机票价格的变化,因此您必须在机票中添加一个字段创建新价格的日期。 then you would not delete the old ticket price. 那么您将不会删除旧机票价格。 just pull the newest. 只是拉最新的。 and the same for anything else with a price... you cant overwrite it.. just add a start date... 和其他价格相同的东西...您不能覆盖它..只需添加开始日期...

and when you are ready to see how much the person spend you can see how much they spent on their tickets and attractions... 当您准备查看此人的花费时,您可以看到他们在门票和景点上花费了多少...

once you do this what you want will be possible. 一旦执行此操作,便可以实现所需的功能。

I think you have the information you need. 我认为您拥有所需的信息。 You're recording the ticket used when a patron visits an attraction and with that data you can get the ticket class and calculate what the cost would have been had they visited the attraction with a different class ticket. 您正在记录顾客访问景点时使用的门票,并使用该数据可以获取门票类别,并计算出如果他们使用其他类别的门票访问景点所花费的费用。

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

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