# # Copyright 2017 Amazon.com # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. create table if not exists ticket_purchase_hist ( sporting_event_ticket_id BIGINT NOT NUll ,purchased_by_id MEDIUMINT NOT NULL ,transaction_date_time DATETIME NOT NULL ,transferred_from_id MEDIUMINT ,purchase_price DECIMAL(6,2) NOT NULL ,constraint ticket_purchase_hist_pk primary key(sporting_event_ticket_id, purchased_by_id, transaction_date_time) ,constraint tph_sport_event_tik_id foreign key(sporting_event_ticket_id) references sporting_event_ticket(id) ,constraint tph_ticketholder_id foreign key(purchased_by_id) references person(id) ,constraint tph_transfer_from_id foreign key(transferred_from_id) references person(id) ); create index tph_purch_by_id on ticket_purchase_hist(purchased_by_id); create index tph_trans_from_id on ticket_purchase_hist(transferred_from_id);