title: Referencing a composite primary key
body: <p>I have two tables, with each table having a composite primary key.</p>
  
  <p>One attribute is in both composite primary keys.</p>
  
  <p>How am i supposed to reference the common attribute?? Do i just reference it as a FK in both tables  as below? The cust_id and flight_id below are each part of the composite key as well and reference primary keys in other tables. (Ignore the third attribute in the erd for the br_flight table as I choose to use a composite key in the end). </p>
  
  <pre><code>CREATE TABLE BOOKING_REFERENCE (
  REFERENCE_ID NVARCHAR(10) NOT NULL,
  CUST_ID NUMBER(10)NOT NULL,
  STATUS NVARCHAR (1), NOT NULL,
  PRIMARY KEY(REFERENCE_ID, CUST_ID),
  FOREIGN KEY(REFERENCE_ID) REFERENCES BR_FLIGHT(REFERENCE_ID):
  FOREIGN KEY (CUST_ID) REFERENCES CUSTOMER(CUST_ID);
  
  
  CREATE TABLE BR_FLIGHT (
  REFERENCE_ID NVARCHAR(10) NOT NULL ,
  FLIGHT_ID NVARCHAR (10) NOT NULL,
  PRIMARY KEY(REFERENCE_ID, FLIGHT_ID),
  FOREIGN KEY (REFERENCE_ID) REFERENCES BOOKING_REFERENCE(REFERENCE_ID)
  FOREIGN KEY (FLIGHT_ID) REFERENCES FLIGHT(FLIGHT_ID)
  
  );
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/DH9NE.jpg" alt="enter image description here"></p>
  
  <p>Would the above sql work??
  Thanks in advance and apologies for the shoddy diagram:)</p>