I am fairly new to triggers and PL/SQL, so my question is mainly one of design.
I am creating a set of tables to represent ticket purchases. There are three types of tickets:
- Ticket #1: Price, Quantity, Time
- Ticket #2: Price, Quantity, Time, Seating, Refundable
- Ticket #3: Price, Quantity, Time, Food , Drink
So I have created three tables: (I believe this is called, normalizing):
Table1 has columns Price, Quantity and Time
Table2 has Seating and Refundable
Table3 has Food and Drink
I have inserted a primary key column into Table1 and am using foreign keys in Table2 and Table3 which point to Table1's PK.
The Plan: When a user purchases a ticket, I insert a record into the appropriate table(s). For instance, if the user purchases:
Ticket #1, I insert a record into Table1
Ticket #2, I insert a record into Table1 and Table2
Ticket #3, I insert a record into Table1 and Table3
The Problem: How can I receive all the data for a ticket not of type 1, and then split the parameters to insert into the separate tables. For instance, when I try to create a trigger for Table2, that trigger can only receive the parameters that match what Table2 columns has. How can I receive the data for Table1?
An example of a complete purchase of ticket type 2.
User purchases ticket online -> web form stuff happends... -> dao sends ONE insert command to the database -> trigger for Table2 kicks off and validates info for Table1 and Table2.
Thanks!