0

so far this is what i have code wise, but im getting an error 1239 . Is it not referencing something correctly .

CREATE TABLE CustomerDim
(
   C_CustomerID_Cu                INT(10) NOT NULL,
   C_FacilityReservationNumber_Cu INT(10) NOT NULL,
   I_EventCode_Cu                 INT(10) NOT NULL,

   CONSTRAINT C_CustomerID_Cu FOREIGN KEY (C_CustomerID_Cu) 
   REFERENCES CustomerDIM
);

CREATE TABLE RoomDim
(
   C_RoomNumber_Ro  INT(10) NOT NULL,
   C_RoomType_Ro    INT(5)  NOT NULL, 
   C_RegionID_Re    INT(4)  NOT NULL,
   C__ResortCode_Fa INT(10) NOT NULL,

   CONSTRAINTC_RoomNumber_Ro FOREIGN KEY(C_RoomType_Ro) 
   refereREFERENCES nces RoomDIM
);

CREATE TABLE ReservationFact
(
   C_RoomReservationNumber_Rr     INT (10) NOT NULL,
   C_CustomerID_Cu                INT (10) NOT NULL, 
   C__RoomType_Ro                 INT (10) NOT NULL, 
   C_D_ArrivalDate_Rr             DATE, 
   C_EmployeeNumber_Em            INT (5) NOT NULL 
   C_ResortCode_Rs                INT (10),

   CONSTRAINT C_RoomReservationNumber_Rr_pk PRIMARY KEY
   (C_RoomReservationNumber_Rr)
);
2
  • Referal table must be defined after referent table, and it must refer to an expression which is index expression or index prefix in referent table.
    – Akina
    Mar 30 '20 at 20:39
  • (unrelated comments) The (5) means nothing; change to SMALLINT. Add on UNSIGNED. Have PRIMARY KEYs on every table.
    – Rick James
    Apr 7 '20 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.