Hello,
I'm pretty new to setting up databases, but so far I'm getting along
swimmingly. But I have one question. I'm setting up a database for a
client who wants to sell tickets to their theater online. There are a
LOT of different parameters and I'd like to set it up so that when a
client selects a play and date the price is automatically generated. I
have already figured out how to get what I want, but I believe there
is a better way, I'm just ignorant to it right now. Here is the deal:
5 plays a year
5 different show times (i.e. sunday matinee, weekday evenings,
friday/sat evenings, etc.)
Each play has a different price for each show time
So I have a table (ticket_price) now that looks like this:
play ticket_type price
----------------------------------
play_1 matinee 20
play_1 week_eve 25
play_1 fri_sat_eve 28
play_2 matinee 19
play_2 week_eve 23
play_2 fri_sat_eve 25
etc....
and the order (ticket_order) table:
order_id play ticket_type meal quantity
-----------------------------------------------------------
01 play_1 matinee yes 2
02 play_2 fri_sat_eve no 5
etc...
So I match the ticket with its price for by:
mysql-> select * from ticket_order, ticket_price
where ticket_order.ticket_type='week_eve'
and ticket_price.ticket_type='week_eve'
and ticket_order.play='play_1'
and ticket_price.play='play_1';
and from there I can use PHP to create a shopping cart type of thing.
But the ticket price table seems redundant to me. But for the life of
me I cannot think of how to fix it up. Or, perhaps, the above SELECT
is more complicated than it needs to be. I've poured over my books and
did searches, but nothing seems to touch on this particular subject. I
have a horrible feeling i'm missing something elementary!
Thanks!
Shane