title: Foreign key to composite key
body: <p>I have a problem i need to reference a single foreign key to a composite key in another table.</p>
  
  <p>My database structure is as following:</p>
  
  <pre><code>CREATE TABLE available_trip (
  trip_code integer not null,
  date datetime not null,
  primary key(trip_code, date),
  FOREIGN KEY (trip_code) REFERENCES trip (trip_code)
  );
  
  CREATE TABLE booking (
      available_trip_code integer not null,
      customer_code integer not null,
      date datetime not null,
      deposit float not null,
      total_price float not null,
      has_paid float not null,
      description_en nvarchar(12) null,
      finance_type_code nvarchar(12) not null,
      primary key(available_trip_code, customer_code, date),
      FOREIGN KEY (available_trip_code) REFERENCES available_trip (trip_code, date),
  
  
  FOREIGN KEY (customer_code) REFERENCES customer (customer_code),
              FOREIGN KEY (finance_type_code) REFERENCES finance_type (finance_type_code)
          );
  </code></pre>
  
  <p>my question is: how do I let <code>booking.available_trip_code</code> reference to <code>available_trip.trip_code</code> and <code>available_trip.date</code> ?</p>