test-ATIS.sh
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:24k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. #!@PERL@
  2. # Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  3. #
  4. # This library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Library General Public
  6. # License as published by the Free Software Foundation; either
  7. # version 2 of the License, or (at your option) any later version.
  8. #
  9. # This library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. # Library General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Library General Public
  15. # License along with this library; if not, write to the Free
  16. # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  17. # MA 02111-1307, USA
  18. #
  19. # Test of creating the ATIS database and doing many different selects on it
  20. #
  21. # changes made for Oracle compatibility
  22. # - added Oracle to the '' to ' ' translation
  23. # - skip blank lines from the datafiles
  24. # - skip a couple of the tests in Q4 that Oracle doesn't understand
  25. ################### Standard benchmark inits ##############################
  26. use Cwd;
  27. use DBI;
  28. use Benchmark;
  29. $opt_loop_count=100; # Run selects this many times
  30. $pwd = cwd(); $pwd = "." if ($pwd eq '');
  31. require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!n";
  32. if ($opt_small_test)
  33. {
  34.   $opt_loop_count/=10;
  35. }
  36. print "ATIS table testnn";
  37. ####
  38. ####  Connect and start timeing
  39. ####
  40. $dbh = $server->connect();
  41. $start_time=new Benchmark;
  42. ####
  43. #### Create needed tables
  44. ####
  45. init_data(); # Get table definitions
  46. if (!$opt_skip_create)
  47. {
  48.   print "Creating tablesn";
  49.   $loop_time= new Benchmark;
  50.   for ($ti = 0; $ti <= $#table_names; $ti++)
  51.   {
  52.     my $table_name = $table_names[$ti];
  53.     my $array_ref = $tables[$ti];
  54.     # This may fail if we have no table so do not check answer
  55.     $sth = $dbh->do("drop table $table_name" . $server->{'drop_attr'});
  56.     print "Creating table $table_namen" if ($opt_verbose);
  57.     do_many($dbh,@$array_ref);
  58.   }
  59.   $end_time=new Benchmark;
  60.   print "Time for create_table (" . ($#tables+1) ."): " .
  61.     timestr(timediff($end_time, $loop_time),"all") . "nn";
  62.   if ($opt_fast && defined($server->{vacuum}))
  63.   {
  64.     $server->vacuum(0,$dbh);
  65.   }
  66. ####
  67. #### Insert data
  68. ####
  69.   print "Inserting datan";
  70.   $loop_time= new Benchmark;
  71.   $row_count=0;
  72.   $double_quotes=$server->{'double_quotes'};
  73.   if ($opt_lock_tables)
  74.   {
  75.     @tmp=@table_names; push(@tmp,@extra_names);
  76.     print "LOCK TABLES @tmpn" if ($opt_debug);
  77.     $sth = $dbh->do("LOCK TABLES " . join(" WRITE,", @tmp) . " WRITE") ||
  78.       die $DBI::errstr;
  79.   }
  80.   if ($opt_fast && $server->{'limits'}->{'load_data_infile'})
  81.   {
  82.     for ($ti = 0; $ti <= $#table_names; $ti++)
  83.     {
  84.       my $table_name = $table_names[$ti];
  85.       my $file = "$pwd/Data/ATIS/${table_name}.txt";
  86.       print "$table_name - $filen" if ($opt_debug);
  87.       $row_count += $server->insert_file($table_name,$file,$dbh);
  88.     }
  89.   }
  90.   else
  91.   {
  92.     if ($opt_fast && $server->{transactions})
  93.     {
  94.       $dbh->{AutoCommit} = 0;
  95.       print "Transactions enabledn" if ($opt_debug);
  96.     }
  97.     for ($ti = 0; $ti <= $#table_names; $ti++)
  98.     {
  99.       my $table_name = $table_names[$ti];
  100.       my $array_ref = $tables[$ti];
  101.       my @table = @$array_ref;
  102.       my $insert_start = "insert into $table_name values (";
  103.       open(DATA, "$pwd/Data/ATIS/${table_name}.txt") || die "Can't open text file: $pwd/Data/ATIS/${table_name}.txtn";
  104.       while(<DATA>)
  105.       {
  106. chomp;
  107. next unless ( $_ =~ /w/ ); # skip blank lines
  108. my $command = $insert_start . $_ . ")";
  109.         $command = $server->fix_for_insert($command);
  110. print "$commandn" if ($opt_debug);
  111.         $command =~ s/\'/''/g if ($double_quotes);
  112. $sth = $dbh->do($command) or die "Got error: $DBI::errstr when executing '$command'n";
  113. $row_count++;
  114.       }
  115.     }
  116.     if ($opt_fast && $server->{transactions})
  117.     {
  118.       $dbh->commit;
  119.       $dbh->{AutoCommit} = 1;
  120.     }
  121.     close(DATA);
  122.   }
  123.   if ($opt_lock_tables)
  124.   {
  125.     $dbh->do("UNLOCK TABLES");
  126.   }
  127.   $end_time=new Benchmark;
  128.   print "Time to insert ($row_count): " .
  129.     timestr(timediff($end_time, $loop_time),"all") . "nn";
  130. }
  131. if ($opt_fast && defined($server->{vacuum}))
  132. {
  133.   $server->vacuum(0,$dbh,@table_names);
  134. }
  135. if ($opt_lock_tables)
  136. {
  137.   @tmp=@table_names; push(@tmp,@extra_names);
  138.   $sth = $dbh->do("LOCK TABLES " . join(" READ,", @tmp) . " READ") ||
  139.     die $DBI::errstr;
  140. }
  141. #
  142. # Now the fun begins.  Let's do some simple queries on the result
  143. #
  144. # The query array is defined as:
  145. # query, number of rows in result, 0|1 where 1 means that the query is possible
  146. #
  147. print "Retrieving datan";
  148. @Q1=("select_simple_join",
  149.      "select city.city_name,state.state_name,city.city_code from city,state where city.city_code='MATL' and city.state_code=state.state_code",1,1,
  150.      "select city.city_name,state.state_name,city.city_code from state,city where city.state_code=state.state_code",11,1,
  151.      "select month_name.month_name,day_name.day_name from month_name,day_name where month_name.month_number=day_name.day_code",7,1,
  152.      "select month_name.month_name,day_name.day_name from month_name,day_name where month_name.month_number=day_name.day_code and day_name.day_code >= 4",4,1,
  153.      "select flight.flight_code,aircraft.aircraft_type from flight,aircraft where flight.aircraft_code=aircraft.aircraft_code",579,1,
  154.      );
  155. @Q2=("select_join",
  156.      "select airline.airline_name,aircraft.aircraft_type from aircraft,airline,flight where flight.aircraft_code=aircraft.aircraft_code and flight.airline_code=airline.airline_code",579,1);
  157. @Q21=("select_key_prefix_join",
  158.      "select fare.fare_code from restrict_carrier,airline,fare where restrict_carrier.airline_code=airline.airline_code and fare.restrict_code=restrict_carrier.restrict_code",5692,1,
  159.     );
  160. @Q3=("select_distinct",
  161.      "select distinct category from aircraft",6,1,
  162.      "select distinct from_airport from flight",9,1,
  163.      "select distinct aircraft_code from flight",22,1,
  164.      "select distinct * from fare",534,1,
  165.      "select distinct flight_code from flight_fare",579,1,
  166.      "select distinct flight.flight_code,aircraft.aircraft_type from flight,aircraft where flight.aircraft_code=aircraft.aircraft_code",579,1,
  167.      "select distinct airline.airline_name,aircraft.aircraft_type from aircraft,airline,flight where flight.aircraft_code=aircraft.aircraft_code and flight.airline_code=airline.airline_code",44,$limits->{'join_optimizer'},
  168.      "select distinct airline.airline_name,aircraft.aircraft_type from flight,aircraft,airline where flight.aircraft_code=aircraft.aircraft_code and flight.airline_code=airline.airline_code",44,1,
  169.      );
  170. @Q4=("select_group",
  171.      "select day_name.day_name,day_name.day_code,count(*) from flight_day,day_name where day_name.day_code=flight_day.day_code group by day_name.day_name,day_name.day_code order by day_name.day_code",7,$limits->{'group_functions'},
  172.      "select day_name.day_name,count(*) from flight_day,day_name where day_name.day_code=flight_day.day_code group by day_name.day_name",7,$limits->{'group_functions'},
  173.      "select month_name,day_name from month_name,day_name where month_number=day_code and day_code>3 group by month_name,day_name",4,$limits->{'group_functions'},
  174.      "select day_name.day_name,flight_day.day_code,count(*) from flight_day,day_name where day_name.day_code=flight_day.day_code group by flight_day.day_code,day_name.day_name order by flight_day.day_code",7,$limits->{'group_functions'},
  175.      "select sum(engines) from aircraft",1,$limits->{'group_functions'},
  176.      "select avg(engines) from aircraft",1,$limits->{'group_functions'},
  177.      "select avg(engines) from aircraft where engines>0",1,$limits->{'group_functions'},
  178.      "select count(*),min(pay_load),max(pay_load) from aircraft where pay_load>0",1,$limits->{'group_functions'},
  179.      "select min(flight_code),min(flight_code) from flight",1,$limits->{'group_functions'},
  180.      "select min(from_airport),min(to_airport) from flight",1,$limits->{'group_functions'} && $limits->{'group_func_sql_min_str'},
  181.      "select count(*) from aircraft where pay_load>10000",1,$limits->{'group_functions'},
  182.      "select count(*) from aircraft where pay_load<>0",1,$limits->{'group_functions'},
  183.      "select count(*) from flight where flight_code >= 112793",1,$limits->{'group_functions'},
  184.      "select count(if(pay_load,1,NULL)) from aircraft",1,$limits->{'if'} && $limits->{'group_functions'},
  185.      "select std(engines) from aircraft",1,$limits->{'group_func_extra_std'},
  186.      "SELECT from_airport,to_airport,avg(time_elapsed) FROM flight WHERE from_airport='ATL' AND to_airport='BOS' group by from_airport,to_airport",1,$limits->{'group_functions'},
  187.      "select city_code, avg(ground_fare) from ground_service where ground_fare<>0 group by city_code",11,$limits->{'group_functions'},
  188.      "select count(*), ground_service.city_code from ground_service group by ground_service.city_code",12,$limits->{'group_functions'},
  189.      "select category,count(*) as totalnr from aircraft where engines=2 group by category having totalnr>4",3,$limits->{'group_functions'} && $limits->{'having_with_alias'},
  190.      "select category,count(*) from aircraft where engines=2 group by category having count(*)>4",3,$limits->{'group_functions'} && $limits->{'having_with_group'},
  191.      "select flight_number,range_miles,fare_class FROM aircraft,flight,flight_class WHERE flight.flight_code=flight_class.flight_code AND flight.aircraft_code=aircraft.aircraft_code AND range_miles<>0 AND (stops=1 OR stops=2) GROUP BY flight_number,range_miles,fare_class",150,$limits->{'group_functions'},
  192.      "select distinct from_airport.time_zone_code,to_airport.time_zone_code,(FLOOR(arrival_time/100)*60+MOD(arrival_time,100)-FLOOR(departure_time/100)*60-MOD(departure_time,100)-time_elapsed)/60 AS time_zone_diff FROM flight,airport AS from_airport,airport AS to_airport WHERE flight.from_airport=from_airport.airport_code AND flight.to_airport=to_airport.airport_code GROUP BY from_airport.time_zone_code,to_airport.time_zone_code,arrival_time,departure_time,time_elapsed",21,$limits->{'func_odbc_mod'} && $limits->{'func_odbc_floor'} && $limits->{'group_functions'},
  193.      "select DISTINCT from_airport.time_zone_code,to_airport.time_zone_code,MOD((FLOOR(arrival_time/100)*60+MOD(arrival_time,100)-FLOOR(departure_time/100)*60-MOD(departure_time,100)-time_elapsed)/60+36,24)-12 AS time_zone_diff FROM flight,airport AS from_airport,airport AS to_airport WHERE flight.from_airport=from_airport.airport_code AND flight.to_airport=to_airport.airport_code and MOD((FLOOR(arrival_time/100)*60+MOD(arrival_time,100)-FLOOR(departure_time/100)*60-MOD(departure_time,100)-time_elapsed)/60+36,24)-12 < 10",14,$limits->{'func_odbc_mod'} && $limits->{'func_odbc_floor'} && $limits->{'group_functions'},
  194.      "select from_airport,to_airport,range_miles,time_elapsed FROM aircraft,flight WHERE aircraft.aircraft_code=flight.aircraft_code AND to_airport NOT LIKE from_airport AND range_miles<>0 AND time_elapsed<>0 GROUP BY from_airport,to_airport,range_miles,time_elapsed",409,$limits->{'group_functions'} && $limits->{'like_with_column'},
  195.      "SELECT airport.country_name,state.state_name,city.city_name,airport_service.direction FROM airport_service,state,airport,city WHERE airport_service.city_code=city.city_code AND airport_service.airport_code=airport.airport_code AND state.state_code=airport.state_code AND state.state_code=city.state_code AND airport.state_code=city.state_code AND airport.country_name=city.country_name AND airport.country_name=state.country_name AND city.time_zone_code=airport.time_zone_code GROUP BY airport.country_name,state.state_name,city.city_name,airport_service.direction ORDER BY state_name",11,$limits->{'group_functions'},
  196.      "SELECT airport.country_name,state.state_name,city.city_name,airport_service.direction FROM airport_service,state,airport,city WHERE airport_service.city_code=city.city_code AND airport_service.airport_code=airport.airport_code AND state.state_code=airport.state_code AND state.state_code=city.state_code AND airport.state_code=city.state_code AND airport.country_name=city.country_name AND airport.country_name=state.country_name AND city.time_zone_code=airport.time_zone_code GROUP BY airport.country_name,state.state_name,city.city_name,airport_service.direction ORDER BY state_name DESC",11,$limits->{'group_functions'},
  197.      "SELECT airport.country_name,state.state_name,city.city_name,airport_service.direction FROM airport_service,state,airport,city WHERE airport_service.city_code=city.city_code AND airport_service.airport_code=airport.airport_code AND state.state_code=airport.state_code AND state.state_code=city.state_code AND airport.state_code=city.state_code AND airport.country_name=city.country_name AND airport.country_name=state.country_name AND city.time_zone_code=airport.time_zone_code GROUP BY airport.country_name,state.state_name,city.city_name,airport_service.direction ORDER BY state_name",11,$limits->{'group_functions'},
  198.      "SELECT from_airport,to_airport,fare.fare_class,night,one_way_cost,rnd_trip_cost,class_days FROM compound_class,fare WHERE compound_class.fare_class=fare.fare_class AND one_way_cost <= 825 AND one_way_cost >= 280 AND from_airport='SFO' AND to_airport='DFW' GROUP BY from_airport,to_airport,fare.fare_class,night,one_way_cost,rnd_trip_cost,class_days ORDER BY one_way_cost",10,$limits->{'group_functions'},
  199.      "select engines,category,cruising_speed,from_airport,to_airport FROM aircraft,flight WHERE category='JET' AND engines >= 1 AND aircraft.aircraft_code=flight.aircraft_code AND to_airport NOT LIKE from_airport AND stops>0 GROUP BY engines,category,cruising_speed,from_airport,to_airport ORDER BY engines DESC",29,$limits->{'group_functions'} && $limits->{'like_with_column'},
  200.      );
  201. @Q=(@Q1,@Q2,@Q21,@Q3,@Q4);
  202. foreach $Q (@Q)
  203. {
  204.   $count=$estimated=0;
  205.   $loop_time= new Benchmark;
  206.   for ($i=1 ; $i <= $opt_loop_count; $i++)
  207.   {
  208.     for ($j=1 ; $j < $#$Q ; $j+=3)
  209.     {
  210.       if ($Q->[$j+2])
  211.       { # We can do it with current limits
  212. $count++;
  213. if ($i == 100) # Do something different
  214. {
  215.   if (($row_count=fetch_all_rows($dbh,$server->query($Q->[$j]))) !=
  216.       $Q->[$j+1])
  217.   {
  218.     if ($row_count == undef())
  219.     {
  220.       die "Got error: $DBI::errstr when executing " . $Q->[$j] ."n"."got $row_count instead of $Q->[$j+1] *** n";
  221.     }
  222.     print "Warning: Query '" . $Q->[$j] . "' returned $row_count rows when it should have returned " . $Q->[$j+1] . " rowsn";
  223.   }
  224. }
  225. else
  226. {
  227.   defined(fetch_all_rows($dbh,$server->query($Q->[$j])))
  228.     or die "ERROR: $DBI::errstr executing '$Q->[$j]'n";
  229. }
  230.       }
  231.     }
  232.     $end_time=new Benchmark;
  233.     last if ($estimated=predict_query_time($loop_time,$end_time,$count,$i,
  234.    $opt_loop_count));
  235.     print "Loop $in" if ($opt_verbose);
  236.   }
  237.   if ($count)
  238.   {
  239.     if ($estimated)
  240.     { print "Estimated time"; }
  241.     else
  242.     { print "Time"; }
  243.     print  " for " . $Q->[0] . " ($count): " .
  244.       timestr(timediff($end_time, $loop_time),"all") . "n";
  245.   }
  246. }
  247. print "n";
  248. ####
  249. #### Delete the tables
  250. ####
  251. if (!$opt_skip_delete) # Only used when testing
  252. {
  253.   print "Removing tablesn";
  254.   $loop_time= new Benchmark;
  255.   if ($opt_lock_tables)
  256.   {
  257.     $sth = $dbh->do("UNLOCK TABLES") || die $DBI::errstr;
  258.   }
  259.   for ($ti = 0; $ti <= $#table_names; $ti++)
  260.   {
  261.     my $table_name = $table_names[$ti];
  262.     $sth = $dbh->do("drop table $table_name" . $server->{'drop_attr'});
  263.   }
  264.   $end_time=new Benchmark;
  265.   print "Time to drop_table (" .($#table_names+1) . "): " .
  266.     timestr(timediff($end_time, $loop_time),"all") . "n";
  267. }
  268. if ($opt_fast && defined($server->{vacuum}))
  269. {
  270.   $server->vacuum(0,$dbh);
  271. }
  272. ####
  273. #### End of benchmark
  274. ####
  275. $dbh->disconnect; # close connection
  276. end_benchmark($start_time);
  277. sub init_data
  278. {
  279.   @aircraft=
  280.     $server->create("aircraft",
  281.     ["aircraft_code char(3) NOT NULL",
  282.      "aircraft_type char(64) NOT NULL",
  283.      "engines tinyint(1) NOT NULL",
  284.      "category char(10) NOT NULL",
  285.      "wide_body char(3) NOT NULL",
  286.      "wing_span float(6,2) NOT NULL",
  287.      "length1 float(6,2) NOT NULL",
  288.      "weight integer(7) NOT NULL",
  289.      "capacity smallint(3) NOT NULL",
  290.      "pay_load integer(7) NOT NULL",
  291.      "cruising_speed mediumint(5) NOT NULL",
  292.      "range_miles mediumint(5) NOT NULL",
  293.      "pressurized char(3) NOT NULL"],
  294.     ["PRIMARY KEY (aircraft_code)"]);
  295.   @airline=
  296.     $server->create("airline",
  297.     ["airline_code char(2) NOT NULL",
  298.      "airline_name char(64) NOT NULL",
  299.      "notes char(38) NOT NULL"],
  300.     ["PRIMARY KEY (airline_code)"]);
  301.   @airport=
  302.     $server->create("airport",
  303.     ["airport_code char(3) NOT NULL",
  304.      "airport_name char(40) NOT NULL",
  305.      "location char(36) NOT NULL",
  306.      "state_code char(2) NOT NULL",
  307.      "country_name char(25) NOT NULL",
  308.      "time_zone_code char(3) NOT NULL"],
  309.     ["PRIMARY KEY (airport_code)"]);
  310.   @airport_service=
  311.     $server->create("airport_service",
  312.     ["city_code char(4) NOT NULL",
  313.      "airport_code char(3) NOT NULL",
  314.      "miles_distant float(4,1) NOT NULL",
  315.      "direction char(3) NOT NULL",
  316.      "minutes_distant smallint(3) NOT NULL"],
  317.     ["PRIMARY KEY (city_code, airport_code)"]);
  318.   @city=
  319.     $server->create("city",
  320.     ["city_code char(4) NOT NULL",
  321.      "city_name char(25) NOT NULL",
  322.      "state_code char(2) NOT NULL",
  323.      "country_name char(25) NOT NULL",
  324.      "time_zone_code char(3) NOT NULL"],
  325.     ["PRIMARY KEY (city_code)"]);
  326.   @class_of_service=
  327.     $server->create("class_of_service",
  328.     ["class_code char(2) NOT NULL",
  329.      "rank tinyint(2) NOT NULL",
  330.      "class_description char(80) NOT NULL"],
  331.     ["PRIMARY KEY (class_code)"]);
  332.   @code_description=
  333.     $server->create("code_description",
  334.     ["code char(5) NOT NULL",
  335.      "description char(110) NOT NULL"],
  336.     ["PRIMARY KEY (code)"]);
  337.   @compound_class=
  338.     $server->create("compound_class",
  339.     ["fare_class char(3) NOT NULL",
  340.      "base_class char(2) NOT NULL",
  341.      "class_type char(10) NOT NULL",
  342.      "premium char(3) NOT NULL",
  343.      "economy char(3) NOT NULL",
  344.      "discounted char(3) NOT NULL",
  345.      "night char(3) NOT NULL",
  346.      "season_fare char(4) NOT NULL",
  347.      "class_days char(7) NOT NULL"],
  348.     ["PRIMARY KEY (fare_class)"]);
  349.   @connect_leg=
  350.     $server->create("connect_leg",
  351.     ["connect_code integer(8) NOT NULL",
  352.      "leg_number tinyint(1) NOT NULL",
  353.      "flight_code integer(8) NOT NULL"],
  354.     ["PRIMARY KEY (connect_code, leg_number, flight_code)"]);
  355.   @connection=
  356.     $server->create("fconnection",
  357.     ["connect_code integer(8) NOT NULL",
  358.      "from_airport char(3) NOT NULL",
  359.      "to_airport char(3) NOT NULL",
  360.      "departure_time smallint(4) NOT NULL",
  361.      "arrival_time smallint(4) NOT NULL",
  362.      "flight_days char(7) NOT NULL",
  363.      "stops tinyint(1) NOT NULL",
  364.      "connections tinyint(1) NOT NULL",
  365.      "time_elapsed smallint(4) NOT NULL"],
  366.     ["PRIMARY KEY (connect_code)",
  367.      "INDEX from_airport1 (from_airport)",
  368.      "INDEX to_airport1 (to_airport)"]);
  369.   @day_name=
  370.     $server->create("day_name",
  371.     ["day_code tinyint(1) NOT NULL",
  372.      "day_name char(9) NOT NULL"],
  373.     ["PRIMARY KEY (day_code)"]);
  374.   @dual_carrier=
  375.     $server->create("dual_carrier",
  376.     ["main_airline char(2) NOT NULL",
  377.      "dual_airline char(2) NOT NULL",
  378.      "low_flight smallint(4) NOT NULL",
  379.      "high_flight smallint(4) NOT NULL",
  380.      "fconnection_name char(64) NOT NULL"],
  381.     ["PRIMARY KEY (main_airline, dual_airline, low_flight)",
  382.      "INDEX main_airline1 (main_airline)"]);
  383.   @fare=
  384.     $server->create("fare",
  385.     ["fare_code char(8) NOT NULL",
  386.      "from_airport char(3) NOT NULL",
  387.      "to_airport char(3) NOT NULL",
  388.      "fare_class char(3) NOT NULL",
  389.      "fare_airline char(2) NOT NULL",
  390.      "restrict_code char(5) NOT NULL",
  391.      "one_way_cost float(7,2) NOT NULL",
  392.      "rnd_trip_cost float(8,2) NOT NULL"],
  393.     ["PRIMARY KEY (fare_code)",
  394.      "INDEX from_airport2 (from_airport)",
  395.      "INDEX to_airport2 (to_airport)"]);
  396.   @flight=
  397.     $server->create("flight",
  398.     ["flight_code integer(8) NOT NULL",
  399.      "flight_days char(7) NOT NULL",
  400.      "from_airport char(3) NOT NULL",
  401.      "to_airport char(3) NOT NULL",
  402.      "departure_time smallint(4) NOT NULL",
  403.      "arrival_time smallint(4) NOT NULL",
  404.      "airline_code char(2) NOT NULL",
  405.      "flight_number smallint(4) NOT NULL",
  406.      "class_string char(8) NOT NULL",
  407.      "aircraft_code char(3) NOT NULL",
  408.      "meal_code char(7) NOT NULL",
  409.      "stops tinyint(1) NOT NULL",
  410.      "dual_carrier char(1) NOT NULL",
  411.      "time_elapsed smallint(4) NOT NULL"],
  412.     ["PRIMARY KEY (flight_code)",
  413.      "INDEX from_airport3 (from_airport)",
  414.      "INDEX to_airport3 (to_airport)"]);
  415.   @flight_class=
  416.     $server->create("flight_class",
  417.     ["flight_code integer(8) NOT NULL",
  418.      "fare_class char(3) NOT NULL"],
  419.     ["PRIMARY KEY (flight_code, fare_class)"]);
  420.   @flight_day=
  421.     $server->create("flight_day",
  422.     ["day_mask char(7) NOT NULL",
  423.      "day_code tinyint(1) NOT NULL",
  424.      "day_name char(9) NOT NULL"],
  425.     ["PRIMARY KEY (day_mask, day_code)"]);
  426.   @flight_fare=
  427.     $server->create("flight_fare",
  428.     ["flight_code integer(8) NOT NULL",
  429.      "fare_code char(8) NOT NULL"],
  430.     ["PRIMARY KEY (flight_code, fare_code)"]);
  431.   @food_service=
  432.     $server->create("food_service",
  433.     ["meal_code char(4) NOT NULL",
  434.      "meal_number tinyint(1) NOT NULL",
  435.      "meal_class char(10) NOT NULL",
  436.      "meal_description char(10) NOT NULL"],
  437.     ["PRIMARY KEY (meal_code, meal_number, meal_class)"]);
  438.   @ground_service=
  439.     $server->create("ground_service",
  440.     ["city_code char(4) NOT NULL",
  441.      "airport_code char(3) NOT NULL",
  442.      "transport_code char(1) NOT NULL",
  443.      "ground_fare float(6,2) NOT NULL"],
  444.     ["PRIMARY KEY (city_code, airport_code, transport_code)"]);
  445.   @time_interval=
  446.     $server->create("time_interval",
  447.     ["period char(20) NOT NULL",
  448.      "begin_time smallint(4) NOT NULL",
  449.      "end_time smallint(4) NOT NULL"],
  450.     ["PRIMARY KEY (period, begin_time)"]);
  451.   @month_name=
  452.     $server->create("month_name",
  453.     ["month_number tinyint(2) NOT NULL",
  454.      "month_name char(9) NOT NULL"],
  455.     ["PRIMARY KEY (month_number)"]);
  456.   @restrict_carrier=
  457.     $server->create("restrict_carrier",
  458.     ["restrict_code char(5) NOT NULL",
  459.      "airline_code char(2) NOT NULL"],
  460.     ["PRIMARY KEY (restrict_code, airline_code)"]);
  461.   @restrict_class=
  462.     $server->create("restrict_class",
  463.     ["restrict_code char(5) NOT NULL",
  464.      "ex_fare_class char(12) NOT NULL"],
  465.     ["PRIMARY KEY (restrict_code, ex_fare_class)"]);
  466.   @restriction=
  467.     $server->create("restriction",
  468.     ["restrict_code char(5) NOT NULL",
  469.      "application char(80) NOT NULL",
  470.      "no_discounts char(80) NOT NULL",
  471.      "reserve_ticket smallint(3) NOT NULL",
  472.      "stopovers char(1) NOT NULL",
  473.      "return_min smallint(3) NOT NULL",
  474.      "return_max smallint(3) NOT NULL"],
  475.     ["PRIMARY KEY (restrict_code)"]);
  476.   @state=
  477.     $server->create("state",
  478.     ["state_code char(2) NOT NULL",
  479.      "state_name char(25) NOT NULL",
  480.      "country_name char(25) NOT NULL"],
  481.     ["PRIMARY KEY (state_code)"]);
  482.   @stop=
  483.     $server->create("stop1",
  484.     ["flight_code integer(8) NOT NULL",
  485.      "stop_number tinyint(1) NOT NULL",
  486.      "stop_flight integer(8) NOT NULL"],
  487.     ["PRIMARY KEY (flight_code, stop_number)"]);
  488.   @time_zone=
  489.     $server->create("time_zone",
  490.     ["time_zone_code char(3) NOT NULL",
  491.      "time_zone_name char(32) NOT NULL"],
  492.     ["PRIMARY KEY (time_zone_code, time_zone_name)"]);
  493.   @transport=
  494.     $server->create("transport",
  495.     ["transport_code char(1) NOT NULL",
  496.      "transport_desc char(32) NOT NULL"],
  497.     ["PRIMARY KEY (transport_code)"]);
  498. # Avoid not used warnings
  499.   @tables =
  500.     (@aircraft, @airline, @airport, @airport_service,
  501.      @city, @class_of_service, @code_description,
  502.      @compound_class, @connect_leg, @connection, @day_name,
  503.      @dual_carrier, @fare, @flight, @flight_class, @flight_day,
  504.      @flight_fare, @food_service, @ground_service, @time_interval,
  505.      @month_name,
  506.      @restrict_carrier, @restrict_class, @restriction, @state, @stop,
  507.      @time_zone, @transport);
  508.   @table_names =
  509.     ("aircraft", "airline", "airport", "airport_service",
  510.      "city", "class_of_service", "code_description",
  511.      "compound_class", "connect_leg", "fconnection", "day_name",
  512.      "dual_carrier", "fare", "flight", "flight_class", "flight_day",
  513.      "flight_fare", "food_service", "ground_service", "time_interval",
  514.      "month_name",
  515.      "restrict_carrier", "restrict_class", "restriction", "state", "stop1",
  516.      "time_zone", "transport");
  517. # Alias used in joins
  518.   @extra_names=("airport as from_airport","airport as to_airport");
  519. }