I want to store data about passengers/guests, who book together, with a common reference number consisting of 6 alphanumeric characters. The primary key in the table would have to be (ref_number, number_of_guest) together (e.g. (ASDFJK; 1) refers to guest #1 within the reservation, (ASDFJK; 2) refers to guest #2 within the reservation).
What I want is to create this reference number with a BEFORE INSERT ON trigger like SET NEW.ref = randomlyGeneratedString, but was sad to see that MySQL has only row level statements, therefore I can only add n different reference numbers to all people within the same reservation, but that just makes no sense.
guesttable, but how do I insert the reference number into the records of each of them? Again, the reference is create with a triggergenerate_reference BEFORE INSERT ON reservations. I can solve the problem by simply generating the reference number in the reservation system and the website, but would prefer to do it within the database. It's such a shame that MySQL lacks statement level triggers...