简体   繁体   中英

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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